Tutorial by Examples: f

In order to dynamically decide what beans to inject, we can use FactoryBeans. These are classes which implement the factory method pattern, providing instances of beans for the container. They are recognized by Spring and can be used transparently, without need to know that the bean comes from a fac...
Sometimes you want to have a file held in Git but ignore subsequent changes. Tell Git to ignore changes to a file or directory using update-index: git update-index --assume-unchanged my-file.txt The above command instructs Git to assume my-file.txt hasn't been changed, and not to check or repor...
This is a nice trick to add a link to code, so it will be easy to jump to the code that issued the log. With the following code, this call: MyLogger.logWithLink("MyTag","param="+param); Will result in: 07-26...012/com.myapp D/MyTag: MyFrag:onStart(param=3) (MyFrag.java:236...
Current updates the branch on the remote repository that shares a name with the current working branch. git config push.default current Simple pushes to the upstream branch, but will not work if the upstream branch is called something else. git config push.default simple Upstream pushes to t...
This is the basic way to insert data from another table with the SELECT statement. INSERT INTO `tableA` (`field_one`, `field_two`) SELECT `tableB`.`field_one`, `tableB`.`field_two` FROM `tableB` WHERE `tableB`.clmn <> 'someValue' ORDER BY `tableB`.`sorting_clmn`; You can...
We can change the style of the placeholder by setting attributedPlaceholder (a NSAttributedString). var placeholderAttributes = [String: AnyObject]() placeholderAttributes[NSForegroundColorAttributeName] = color placeholderAttributes[NSFontAttributeName] = font if let placeholder = textField.p...
Reflection is useful but fragile. Consider this: let mi = typeof<System.String>.GetMethod "StartsWith" The problems with this kind of code are: The code doesn't work because there are several overloads of String.StartsWith Even if there wouldn't be any overloads right now la...
Starting a File Chooser Activity public void showFileChooser() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); // Update with mime types intent.setType("*/*"); // Update with additional mime types here using a String[]. intent.putExtra(Intent.EXTRA_M...
Here is a basic example form with one required text field and one submit button, which submits to a custom function: class Page_Controller extends ContentController { private static $allowed_actions = array( 'ExampleForm' ); public function ExampleForm() { $fiel...
The os module provides an interface to determine what type of operating system the code is currently running on. os.name This can return one of the following in Python 3: posix nt ce java More detailed information can be retrieved from sys.platform
Sometimes you need to determine the target of a symlink. os.readlink will do this: print(os.readlink(path_to_symlink))
os.chmod(path, mode) where mode is the desired permission, in octal.
The AUROC is one of the most commonly used metric to evaluate a classifier's performances. This section explains how to compute it. AUC (Area Under the Curve) is used most of the time to mean AUROC, which is a bad practice as AUC is ambiguous (could be any curve) while AUROC is not. Overview – Abb...
This query will return all columns from the table sales where the values in the column amount is greater than 10 and the data in the region column in "US". SELECT * FROM sales WHERE amount > 10 AND region = "US" You can use regular expressions to select the columns you wan...
A compound literal is an unnamed object which is created in the scope where is defined. The concept was first introduced in C99 standard. An example for compound literal is Examples from C standard, C11-§6.5.2.5/9: int *p = (int [2]){ 2, 4 }; p is initialized to the address of the first ele...
The normal way to create an array of numbers: numbers = [1, 2, 3, 4, 5] Range objects can be used extensively to create an array of numbers: numbers = Array(1..10) # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] numbers = (1..10).to_a # => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] #step and #map methods...
Download and install, either via Homebrew, or from website. For Brew, brew install git-lfs git lfs install Often you will also need to do some setup on the service that hosts your remote to allow it to work with lfs. This will be different for each host, but will likely just be checking a box sa...
A common workflow for using Git LFS is to declare which files are intercepted through a rules-based system, just like .gitignore files. Much of time, wildcards are used to pick certain file-types to blanket track. e.g. git lfs track "*.psd" When a file matching the above pattern is adde...
7.0 OrElse Sub Main() Dim elements As List(Of Integer) = Nothing Dim average As Double = AverageElementsOrElse(elements) Console.WriteLine(average) ' Writes 0 to Console Try 'Throws ArgumentNullException average = AverageElementsOr(elements) Catch ex ...
Joseph Fourier showed that any periodic wave can be represented by a sum of simple sine waves. This sum is called the Fourier Series. The Fourier Series only holds while the system is linear. If there is, eg, some overflow effect (a threshold where the output remains the same no matter how much inpu...

Page 183 of 457