Tutorial by Examples: and

The function angular.isDefined tests a value if it is defined angular.isDefined(someValue) This is the equivalent of performing value !== undefined; // will evaluate to true is value is defined Examples angular.isDefined(42) // true angular.isDefined([1, 2]) // true angular.isDefined(un...
Get the window height and width var width = window.innerWidth var height = window.innerHeight
3.0 let someString = " Swift Language \n" let trimmedString = someString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()) // "Swift Language" Method stringByTrimmingCharactersInSet returns a new string made by removing from both ends of t...
SleekXMPP (Python) import sleekxmpp client = sleekxmpp.Client("[email protected]", "password") client.connect() client.process(blocking=False) client.send_message(mto="[email protected]", mbody=self.msg) Smack (Java / Android) XMPPTCPConnection connectio...
Early Bound (with a reference to Microsoft Scripting Runtime) Sub EnumerateFilesAndFolders( _ FolderPath As String, _ Optional MaxDepth As Long = -1, _ Optional CurrentDepth As Long = 0, _ Optional Indentation As Long = 2) Dim FSO As Scripting.FileSystemObject Set ...
#include <iostream> #include <functional> using std::placeholders::_1; // to be used in std::bind example int stdf_foobar (int x, std::function<int(int)> moo) { return x + moo(x); // std::function moo called } int foo (int x) { return 2+x; } int foo_2 (int x, in...
While if performs an action only when its condition evaluate to true, if / else allows you to specify the different actions when the condition true and when the condition is false. Example: if (a > 1) puts("a is larger than 1"); else puts("a is not larger than 1"...
In Java, parent and child class both can have static methods with the same name. But in such cases implementation of static method in child is hiding parent class' implementation, it's not method overriding. For example: class StaticMethodTest { // static method and inheritance public stati...
Make project (compile modifed and dependent) Windows: Ctrl + F9 OS X / macOS: Cmd + F9 Compile selected file, package or module This is useful to know, as when debugging this shortcut can be used to quickly reload / hotswap classes. Windows: Ctrl + Shift + F9 OS X / macOS: Cmd + Shift + F9 Se...
A basic AppComponent that depends on a single AppModule to provide application-wide singleton objects. @Singleton @Component(modules = AppModule.class) public interface AppComponent { void inject(App app); Context provideContext(); Gson provideGson(); } A module to use to...
Say you want to print variables in a 3 character column. Note: doubling { and } escapes them. s = """ pad {{:3}} :{a:3}: truncate {{:.3}} :{e:.3}: combined {{:>3.3}} :{a:>3.3}: {{:3.3}} :{a:3.3}: {{:3.3}} :{c:3...
We can omit the argument in the call if that argument is an Optional Argument Every Optional Argument has its own default value It will take default value if we do not supply the value A default value of a Optional Argument must be a Constant expression. Must be a value type such as enum or s...
While System.Diagnostics.Contracts is included within the .Net Framework. To use Code Contracts you must install the Visual Studio extensions. Under Extensions and Updates search for Code Contracts then install the Code Contracts Tools After the tools are installed you must enable Code Contract...
Docker volumes are not automatically removed when a container is stopped. To remove associated volumes when you stop a container: docker rm -v <container id or name> If the -v flag is not specified, the volume remains on-disk as a 'dangling volume'. To delete all dangling volumes: docker ...
K&R void* is a catch all type for pointers to object types. An example of this in use is with the malloc function, which is declared as void* malloc(size_t); The pointer-to-void return type means that it is possible to assign the return value from malloc to a pointer to any other type of ob...
Like many Java objects, all String instances are created on the heap, even literals. When the JVM finds a String literal that has no equivalent reference in the heap, the JVM creates a corresponding String instance on the heap and it also stores a reference to the newly created String instance in th...
With Clipping and Masking you can make some specified parts of elements transparent or opaque. Both can be applied to any HTML element. Clipping Clips are vector paths. Outside of this path the element will be transparent, inside it's opaque. Therefore you can define a clip-path property on elemen...
A declaration introduces an identifier and describes its type, be it a type, object, or function. A declaration is what the compiler needs to accept references to that identifier. These are declarations: extern int bar; extern int g(int, int); double f(int, double); /* extern can be omitted for f...
The following embeds an untrusted web page with all restrictions enabled <iframe sandbox src="http://example.com/"></iframe> To allow the page to run scripts and submit forms, add allow-scripts and allow-forms to the sandbox attribute. <iframe sandbox="allow-script...
import std.stdio; void main() { auto s = "hello world"; auto a = [1, 2, 3, 4]; foreach (c; s) { write(c, "!"); // h!e!l!l!o! !w!o!r!l!d! } writeln(); foreach (x; a) { write(x * x, ", "); // 1, 4, 9, 16, } } ...

Page 44 of 153