Tutorial by Examples: al

XML elements often nest, have data in attributes and/or as character data. The way to capture this data is by using ,attr and ,chardata respectively for those cases. var doc = ` <parent> <child1 attr1="attribute one"/> <child2>and some cdata</child2> </p...
Pointer Methods Pointer methods can be called even if the variable is itself not a pointer. According to the Go Spec, . . . a reference to a non-interface method with a pointer receiver using an addressable value will automatically take the address of that value: t.Mp is equivalent to (&t)....
You can mix normal parameters and parameter arrays: public class LotteryTicket : IEnumerable{ public int[] LuckyNumbers; public string UserName; public void Add(string userName, params int[] luckyNumbers){ UserName = userName; Lottery = luckyNumbers; } } ...
import "reflect" value := reflect.ValueOf(4) // Interface returns an interface{}-typed value, which can be type-asserted value.Interface().(int) // 4 // Type gets the reflect.Type, which contains runtime type information about // this value value.Type().Name() // int value.SetInt(5)...
import "reflect" // this is effectively a pointer dereference x := 5 ptr := reflect.ValueOf(&x) ptr.Type().Name() // *int ptr.Type().Kind() // reflect.Ptr ptr.Interface() // [pointer to x] ptr.Set(4) // panic value := ptr.Elem() // this is a deref value.Type().Name() // int...
Package can have init methods which are run only once before main. package usefull func init() { // init code } If you just want to run the package initialization without referencing anything from it use the following import expression. import _ "usefull"
Directives comes with the AngularJS library itself. A sample directive can be created as: angular.module('simpleDirective', []) .directive('helloData', function() { return { template: 'Hello, {{data}}' }; }); And can be used as: JS: angular.module('app', ['simpleDirective']) .con...
You can install Json.Net into your Visual Studio Project in 1 of 2 ways. Install Json.Net using the Package Manager Console. Open the Package Manager Console window in Visual Studio either by typing package manager console in the Quick Launch box and selecting it or by clicking View -> O...
serialize() returns a string containing a byte-stream representation of any value that can be stored in PHP. unserialize() can use this string to recreate the original variable values. To serialize an object serialize($object); To Unserialize an object unserialize($object) Example $array =...
Introduction Classes that implement this interface no longer support __sleep() and __wakeup(). The method serialize is called whenever an instance needs to be serialized. This does not invoke __destruct() or has any other side effect unless programmed inside the method. When the data is unseriali...
Helpful when you want to grab a copy of a production database to play around with locally. mongodump --host some-mongo-host.com:1234 -d DATABASE_NAME -u DATABASE_USER -p DATABASE_PASSWORD This will create a local dump directory; within that directory you'll see a directory with your DATABASE_NAME...
While your Meteor app is running locally: meteor mongo --url
Set the MONGO_URL environment variable before starting your local Meteor app. Linux/MacOS Example: MONGO_URL="mongodb://some-mongo-host.com:1234/mydatabase" meteor or export MONGO_URL="mongodb://some-mongo-host.com:1234/mydatabase" meteor Windows Example Note: don't u...
Requirements Python (2.7, 3.2, 3.3, 3.4, 3.5, 3.6) Django (1.7+, 1.8, 1.9, 1.10, 1.11) Install You can either use pip to install or clone the project from github. Using pip: pip install djangorestframework Using git clone: git clone [email protected]:tomchristie/django-rest-framew...
A dotfile is a file whose names begin with a .. These are normally hidden by ls and not listed unless requested. For example the following output of ls: $ ls bin pki The -a or --all option will list all files, including dotfiles. $ ls -a . .ansible .bash_logout .bashrc .lesshst ...
The factorial function is a Haskell "Hello World!" (and for functional programming generally) in the sense that it succinctly demonstrates basic principles of the language. Variation 1 fac :: (Integral a) => a -> a fac n = product [1..n] Live demo Integral is the class of in...
It is possible to await multiple calls concurrently by first invoking the awaitable tasks and then awaiting them. public async Task RunConcurrentTasks() { var firstTask = DoSomethingAsync(); var secondTask = DoSomethingElseAsync(); await firstTask; await secondTask; } Alt...
Matplotlib axes are two-dimensional by default. In order to create three-dimensional plots, we need to import the Axes3D class from the mplot3d toolkit, that will enable a new kind of projection for an axes, namely '3d': import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fi...
If you want two or more arguments to be mutually exclusive. You can use the function argparse.ArgumentParser.add_mutually_exclusive_group(). In the example below, either foo or bar can exist but not both at the same time. import argparse parser = argparse.ArgumentParser() group = parser.add_mut...
Only when the foreach statement moves to the next item does the iterator block evaluate up to the next yield statement. Consider the following example: private IEnumerable<int> Integers() { var i = 0; while(true) { Console.WriteLine("Inside iterator: " + i...

Page 46 of 269