Tutorial by Examples: f

Basic usage of dependency injection is done by the annotations. When you need to tweak things a little bit, you need custom code to further specify how you want some classes to be instantiated and injected. This code goes in what is called a Module. import com.google.inject.AbstractModule // Pla...
PBKDF2 ("Password-Based Key Derivation Function 2") is one of the recommended hash-functions for password-hashing. It is part of rfc-2898. .NET's Rfc2898DeriveBytes-Class is based upon HMACSHA1. using System.Security.Cryptography; ... public const int SALT_SIZE = 24; //...
Abilities are defined in the Ability class using can and cannot methods. Consider the following commented example for basic reference: class Ability include CanCan::Ability def initialize(user) # for any visitor or user can :read, Article if user if user.admin? ...
Once the number of abilities definitions start to grow in number, it becomes more and more difficult to handle the Ability file. The first strategy to handle these issue is to move abilities into meaningful methods, as per this example: class Ability include CanCan::Ability def initialize(...
Step 1: Create the controller, set the delegate, and conform to the protocol //Swift class ImageUploadViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate { let imagePickerController = UIImagePickerController() override func viewDi...
LISP and Scheme's greatest advantage over other mainstream programming language is their macro system. Unlike the C preprocessor and other macro languages, Scheme macros take parsed code as input and return expanded code as output. This is one of the applications of Scheme's “code is data” phrase, a...
Download the Atlassian conversion utility here. This utility requires Java, so please ensure that you have the Java Runtime Environment JRE installed on the machine you plan to do the conversion. Use the command java -jar svn-migration-scripts.jar verify to check if your machine is missing any of t...
The macro WITH-INPUT-FROM-STRING can be used to make a stream from a string. (with-input-from-string (str "Foobar") (loop for i from 0 for char = (read-char str nil nil) while char do (format t "~d: ~a~%" i char))) ; 0: F ; 1: o ; 2: o ; 3: b ;...
A file can be opened for reading as a stream using WITH-OPEN-FILE macro. (with-open-file (file #P"test.file") (loop for i from 0 for line = (read-line file nil nil) while line do (format t "~d: ~a~%" i line))) ; 0: Foobar ; 1: Barfoo ; 2: Quuxbar...
A file can be opened for writing as a stream using WITH-OPEN-FILE macro. (with-open-file (file #P"test.file" :direction :output :if-exists :append :if-does-not-exist :create) (dolist (line '("Foobar" &q...
Whatever you do to customize Vim, it should NEVER happen outside of $HOME: on Linux, BSD and Cygwin, $HOME is usually /home/username/, on Mac OS X, $HOME is /Users/username/, on Windows, $HOME is usually C:\Users\username\. The canonical location for your vimrc and your vim directory is at ...
Don't forget the bang to allow Vim to overwrite that function next time you reload the script where the function is defined. Custom functions must start either with an uppercase character (global functions), or with s: (script local functions), or they must be prefixed with the name associated to...
Some formats can take additional parameters, such as the width of the formatted string, or the alignment: >>> '{:.>10}'.format('foo') '.......foo' Those can also be provided as parameters to format by nesting more {} inside the {}: >>> '{:.>{}}'.format('foo', 10) '.......
Using natural language Functions calls should be close to natural English language. Example: list.insert(element, at: index) instead of list.insert(element, position: index) Naming Factory Methods Factory methods should begin with the prefix `make`. Example: factory.makeObject() ...
In case we want to use enum with more information and not just as constant values, and we want to be able to compare two enums. Consider the following example: public enum Coin { PENNY(1), NICKEL(5), DIME(10), QUARTER(25); private final int value; Coin(int value){ this....
<cfloop list="#myFile#" index="FileItem" delimiters="#chr(10)##chr(13)#"> <cfoutput> #FileItem#<br /> </cfoutput> </cfloop>
The aar file doesn't contain the transitive dependencies and doesn't have a pom file which describes the dependencies used by the library. It means that, if you are importing a aar file using a flatDir repo you have to specify the dependencies also in your project. You should use a maven repositor...
JsonReader reads a JSON encoded value as a stream of tokens. public List<Message> readJsonStream(InputStream in) throws IOException { JsonReader reader = new JsonReader(new InputStreamReader(in, "UTF-8")); try { return readMessagesArray(reader); } finall...
The filesystem configuration file is located at config/filesystems.php. Within this file you may configure all of your "disks". Each disk represents a particular storage driver and storage location. Example configurations for each supported driver is included in the configuration file. So,...
Laravel's Flysystem integration provides drivers for several "drivers" out of the box; however, Flysystem is not limited to these and has adapters for many other storage systems. You can create a custom driver if you want to use one of these additional adapters in your Laravel application....

Page 127 of 457