Tutorial by Examples

You can destructure nested vectors: (def my-vec [[1 2] [3 4]]) (let [[[a b][c d]] my-vec] (println a b c d)) ;; 1 2 3 4

is

The is macro is the core of the clojure.test library. It returns the value of its body expression, printing an error message if the expression returns a falsey value. (defn square [x] (+ x x)) (require '[clojure.test :as t]) (t/is (= 0 (square 0))) ;;=> true (t/is (= 1 (square 1))) ...
Detailed instructions on getting openerp set up or installed in Debian/Ubuntu. To install from source code, we need Python 2.7, Git and a PostgreSQL database: $ sudo apt-get install git python-pip python2.7-dev -y $ sudo apt-get install postgresql -y $ sudo su -c "createuser -s $(whoami)&qu...
var alphabet:Vector.<String> = new <String>[ "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", &q...
6.0 Since C# 6.0 it is possible to use string interpolation in place of String.Format. string name = "John"; string lastname = "Doe"; Console.WriteLine($"Hello {name} {lastname}!"); Hello John Doe! More examples for this under the topic C# 6.0 features: Stri...
The Flex compiler (mxmlc) is one of the most important parts of the Flex SDK. You can edit AS3 code in any text editor you like. Create a main class file that extends from DisplayObject. You can trigger builds at the command line as follows: mxmlc -source-path="." -default-size [width in...
To round a value to the nearest multiple of x: function roundTo(value:Number, to:Number):Number { return Math.round(value / to) * to; } Example: roundTo(8, 5); // 10 roundTo(17, 3); // 18
Imagine the following XML: <root> <element>hello</element> <another> hello </another> <example>Hello, <nested> I am an example </nested>.</example> </root> The following XPath expression: //*[text() = 'hel...
To make a Haskell program executable you must provide a file with a main function of type IO () main :: IO () main = putStrLn "Hello world!" When Haskell is compiled it examines the IO data here and turns it into a executable. When we run this program it will print Hello world!. If y...
Output some information about a known remote: origin git remote show origin Print just the remote's URL: git config --get remote.origin.url With 2.7+, it is also possible to do, which is arguably better than the above one that uses the config command. git remote get-url origin
List all the existing remotes associated with this repository: git remote List all the existing remotes associated with this repository in detail including the fetch and push URLs: git remote --verbose or simply git remote -v
The static method Date.now returns the number of milliseconds that have elapsed since 1 January 1970 00:00:00 UTC. To get the number of milliseconds that have elapsed since that time using an instance of a Date object, use its getTime method. // get milliseconds using static method now of Date co...
This command is useful if you want to serve a single site in a directory and not the entire directory. cd ~/Projects/my-blog/ valet link awesome-blog Valet will create a symbolic link in ~/.valet/Sites which points to your current working directory. After running the link command, you can acce...
cd ~/Projects valet park This command will register your current working directory as a path that Valet should search for sites. Now, any Laravel project you create within your "parked" directory will automatically be served using the http://folder-name.dev convention.
Laravel allows access to a variety of classes called Services. Some services are available out of the box, but you can create them by yourself. A service can be used in multiple files of the application, like controllers. Let's imagine a Service OurService implementing a getNumber() method returnin...
In a Service Provider register method we can bind an interface to an implementation: public function register() { App::bind( UserRepositoryInterface::class, EloquentUserRepository::class ); } From now on, everytime the app will need an instance of UserRepositoryInterface, Larave...
We can use the Service Container as a Registry by binding an instance of an object in it and get it back when we'll need it: // Create an instance. $john = new User('John'); // Bind it to the service container. App::instance('the-user', $john); // ...somewhere and/or in another class... ...
We can bind a class as a Singleton: public function register() { App::singleton('my-database', function() { return new Database(); }); } This way, the first time an instance of 'my-database' will be requested to the service container, a new instance will be created. Al...
The Service Container is the main Application object. It can be used as a Dependency Injection Container, and a Registry for the application by defining bindings in the Service Providers Service Providers are classes where we define the way our service classes will be created through the applicatio...
Solution 1: $('#parent').prepend($('#child')); Solution 2: $('#child').prependTo($('#parent')); Both solutions are prepending the element #child (adding at the beginning) to the element #parent. Before: <div id="parent"> <span>other content</span> </di...

Page 233 of 1336