Tutorial by Examples: du

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...
In a module (library or application) where you need the aar file you have to add in your build.gradle the repository: repositories { flatDir { dirs 'libs' } } and add the dependency: dependencies { compile(name:'nameOfYourAARFileWithoutExtension', ext:'aar') } Pay a...
Creating a custom ImplicitNamingStrategy allows you to tweak how Hibernate will assign names to non-explicitly named Entity attributes, including Foreign Keys, Unique Keys, Identifier Columns, Basic Columns, and more. For example, by default, Hibernate will generate Foreign Keys which are hashed an...
The most recent versions of Meteor ship with support for ecmascript, aka ES6 or ES2015. Instead of packages, Javascript now supports import statements and modules, which replaces the need for package-only applications. The latest directory structure is similar to the package-only structure, but us...
We can use the :: syntax to dispatch on the type of an argument. describe(n::Integer) = "integer $n" describe(n::AbstractFloat) = "floating point $n" Usage: julia> describe(10) "integer 10" julia> describe(1.0) "floating point 1.0" Unlike m...
A class, functions as a template that defines the basic characteristics of a particular object. Here's an example: class Person(object): """A simple class.""" # docstring species = "Homo Sapiens" ...
Using sw As New System.IO.StreamWriter("path\to\file.txt") sw.WriteLine("Hello world") End Using The use of a Using block is recommended good practice when using an object that Implements IDisposable
/** * returns a array of random numbers with no duplicates * @param range the range of possible numbers for ex. if 100 then it can be anywhere from 1-100 * @param length the length of the array of random numbers * @return array of random numbers with no duplicates. */ public static int[] ...
Example from the standard library (core.clj:807): (defmacro and "Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last e...
A module is a single Python file that can be imported. Using a module looks like this: module.py def hi(): print("Hello world!") my_script.py import module module.hi() in an interpreter >>> from module import hi >>> hi() # Hello world!
int[string] wordCount(string[] wordList) { int[string] words; foreach (word; wordList) { words[word]++; } return words; } void main() { int[string] count = wordCount(["hello", "world", "I", "say", "hello"]); ...
Reducing a list to a single value is easy when you have _.reduce. Let's say we wanted to see if a group of people could afford a cab ride. We'd want to look at all the money they have together as a group, which means we'd want to reduce a list of objects to a single value, in this case the sum ...
A sequence is a series of elements that can be enumerated. It is an alias of System.Collections.Generic.IEnumerable and lazy. It stores a series of elements of the same type (can be any value or object, even another sequence). Functions from the Seq.module can be used to operate on it. Here is a s...
Typically, when using UIControl or UIButton, we add a selector as a callback action for when an event occurs on a button or control, such as the user pressing the button or touching the control. For example, we would do the following: import UIKit class ViewController: UIViewController { @...
The dot function can also be used to compute vector dot products between two one-dimensional numpy arrays. >>> v = np.array([1,2]) >>> w = np.array([1,2]) >>> v.dot(w) 5 >>> np.dot(w,v) 5 >>> np.dot(v,w) 5
Using the Authors table in the Library Database CREATE PROCEDURE GetName ( @input_id INT = NULL, --Input parameter, id of the person, NULL default @name VARCHAR(128) = NULL --Input parameter, name of the person, NULL default ) AS BEGIN SELECT Name + ' is from ' + Country...
History The first computers Early computers had a block of memory that the programmer put code and data into, and the CPU executed within this environment. Given that the computers then were very expensive, it was unfortunate that it would do one job, stop and wait for the next job to be loaded in...
Employees table : | ID | FirstName | LastName | Gender | Salary | +------+-----------+----------+--------+--------+ | 1 | Mark | Hastings | Male | 60000 | | 1 | Mark | Hastings | Male | 60000 | | 2 | Mary | Lambeth | Female | 30000 | | 2 | Mary | Lambe...
DELIMITER $$ DROP PROCEDURE IF EXISTS sp_nested_loop$$ CREATE PROCEDURE sp_nested_loop(IN i INT, IN j INT, OUT x INT, OUT y INT, INOUT z INT) BEGIN DECLARE a INTEGER DEFAULT 0; DECLARE b INTEGER DEFAULT 0; DECLARE c INTEGER DEFAULT 0; WHILE a < i DO WHILE b <...
In normal mode, move the cursor to any word then press * to search forwards for the next occurrence of the word under the cursor, or press # to search backwards. * or # search for the exact word under the cursor: searching for big would only find big and not bigger. Under the hood, Vim uses a sim...

Page 13 of 47