Tutorial by Examples: al

If you've got multiple implementations of the same interface, Spring can autowire them all into a collection object. I'm going to use an example using a Validator pattern1 Foo Class: public class Foo { private String name; private String emailAddress; private String errorMessage;...
private static void explicitTaskParallism() { Thread.CurrentThread.Name = "Main"; // Create a task and supply a user delegate by using a lambda expression. Task taskA = new Task(() => Console.WriteLine($"Hello from task {nameof(taskA)}.")...
private static void Main(string[] args) { var a = new A(); var b = new B(); //implicit task parallelism Parallel.Invoke( () => a.DoSomeWork(), () => b.DoSomeOtherWork() ); }
Installing Rails on Ubuntu On a clean ubuntu, installation of Rails should be straight forward Upgrading ubuntu packages sudo apt-get update sudo apt-get upgrade Install Ruby and Rails dependecies sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyam...
Add the following dependency to your project level build.gradle file. dependencies { classpath "io.realm:realm-gradle-plugin:3.1.2" } Add the following right at the top of your app level build.gradle file. apply plugin: 'realm-android' Complete a gradle sync and you now have ...
Realm models must extend the RealmObject base class, they define the schema of the underlying database. Supported field types are boolean, byte, short, int, long, float, double, String, Date, byte[], links to other RealmObjects, and RealmList<T extends RealmModel>. public class Person extend...
Realm currently does not support storing a list of primitives. It is on their todo list (GitHub issue #575), but for the meantime, here is a workaround. Create a new class for your primitive type, this uses Integer, but change it for whatever you want to store. public class RealmInteger extends Re...
Detailed instructions on getting unicode set up or installed.
In C, all function parameters are passed by value, so modifying what is passed in callee functions won't affect caller functions' local variables. #include <stdio.h> void modify(int v) { printf("modify 1: %d\n", v); /* 0 is printed */ v = 42; printf("modify 2:...
Ruby has an or-equals operator that allows a value to be assigned to a variable if and only if that variable evaluates to either nil or false. ||= # this is the operator that achieves this. this operator with the double pipes representing or and the equals sign representing assigning of a valu...
This example shows how to open a default dialer (an app that makes regular calls) with a provided telephone number already in place: Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse("tel:9988776655")); //Replace with valid phone number. Remember to add the tel: pr...
def foobar(foo=None, bar=None): return "{}{}".format(foo, bar) values = {"foo": "foo", "bar": "bar"} foobar(**values) # "foobar"
You can force deallocate objects even if their refcount isn't 0 in both Python 2 and 3. Both versions use the ctypes module to do so. WARNING: doing this will leave your Python environment unstable and prone to crashing without a traceback! Using this method could also introduce security problems ...
When using prompt a user can always click Cancel and no value will be returned. To prevent empty values and make it more persistent: <h2>Welcome <span id="name"></span>!</h2> <script> // Persistent Prompt modal var userName; while(!userName) { userN...
This example shows how to use two audio sources, and alter one of them based on the other. In this case we create an audio Ducker, that will lower the volume of the primary track if the secondary track produces sound. The ScriptProcessorNode will send regular events to its audioprocess handler. In ...
A whole circle is 360 degrees or Math.PI * 2 radians. Half of those values follows to be 180 degrees or Math.PI radians. A quarter is then 90 degrees or Math.PI / 2 radians. To get a segment as a percentage of a whole circle in radians: function getSegment(percent:Number):Number { retur...
Assuming you have the angle you'd like to move in and an object with x and y values you want to move: var position:Point = new Point(10, 10); var angle:Number = 1.25; You can move along the x axis with Math.cos: position.x += Math.cos(angle); And the y axis with Math.sin: position.y += Mat...
Prerequesites Grunt requires Node.js and npm to be installed. If you don’t have Node.js and/or npm installed on your machine, go to https://nodejs.org and download the installer or package for your operating system. First-time install If you're installing Grunt for the first time, you'll first ha...
Place your test classes here: /src/test/<pkg_name>/ Example test class public class ExampleUnitTest { @Test public void addition_isCorrect() throws Exception { int a=4, b=5, c; c = a + b; assertEquals(9, c); // This test passes assertEquals(10, c...
A slider element can have its value set on initialization by providing a value option. This option is a number: $( "#slider" ).slider({ value: 5 }); A range slider can also have its values set in this way by providing a values option. This option is an array of numbers: $( &qu...

Page 84 of 269