Tutorial by Examples: ti

Sometimes a term is defined in multiple sections of the manual. By default, man will only display the first page it finds, which can be annoying for programmers because C functions are documented in a later section than commands and system calls. Use the following to display all pages that match a...
You can use the Substring method to get any number of characters from a string at any given location. However, if you only want a single character, you can use the string indexer to get a single character at any given index like you do with an array: string s = "hello"; char c = s[1]; //...
Let us build a simple control, a rating widget, intended to be used as: <rating min="0" max="5" nullifier="true" ng-model="data.rating"></rating> No fancy CSS for now; this would render as: 0 1 2 3 4 5 x Clicking on a number selects that ra...
When you need to pass a collection into a Java method: import scala.collection.JavaConverters._ val scalaList = List(1, 2, 3) JavaLibrary.process(scalaList.asJava) If the Java code returns a Java collection, you can turn it into a Scala collection in a similar manner: import scala.collectio...
To create minification-safe angular controllers, you will change the controller function parameters. The second argument in the module.controller function should be passed an array, where the last parameter is the controller function, and every parameter before that is the name of each injected val...
.gitignore ignores files locally, but it is intended to be committed to the repository and shared with other contributors and users. You can set a global .gitignore, but then all your repositories would share those settings. If you want to ignore certain files in a repository locally and not make t...
In Elixir, a common practice is to use anonymous functions. Creating an anonymous function is simple: iex(1)> my_func = fn x -> x * 2 end #Function<6.52032458/1 in :erl_eval.expr/5> The general syntax is: fn args -> output end For readability, you may put parenthesis around t...
A metatable defines a set of operations which alter the behaviour of a lua object. A metatable is just an ordinary table, which is used in a special way. local meta = { } -- create a table for use as metatable -- a metatable can change the behaviour of many things -- here we modify the 'tostrin...
To create a background session // Swift: let mySessionID = "com.example.bgSession" let bgSessionConfig = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(mySessionID) let session = NSURLSession(configuration: bgSessionConfig) // add tasks here //...
Ionic Framework A Cross-platform mobile application development framework using Angular JS and Front End web technologies. Official website: http://ionicframework.com/ Documentation: http://ionicframework.com/docs/ Installation and Setup Installation Ionic required NPM(Node Package Manager) an...
import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; /** * A very simple Swing example. */ public class SwingExample { /** * The number of times the ...
import std.stdio; void main() { int[] arr = [1, 2, 3, 4]; writeln(arr.length); // 4 writeln(arr[2]); // 3 // type inference still works auto arr2 = [1, 2, 3, 4]; writeln(typeof(arr2).stringof); // int[] }
import std.stdio; void main() { int[] arr = [1, 2, 3]; // concatenate arr ~= 4; writeln(arr); // [1, 2, 3, 4] // per element operations arr[] += 10 writeln(arr); // [11, 12, 13, 14] }
By default a property is a primary key if a property on a class is named “ID” (not case sensitive), or the class name followed by "ID". If the type of the primary key property is numeric or GUID it will be configured as an identity column. Simple Example: public class Room { // Pri...
SQL Server 2012 You can utilize the new function: FORMAT(). Using this you can transform your DATETIME fields to your own custom VARCHAR format. Example DECLARE @Date DATETIME = '2016-09-05 00:01:02.333' SELECT FORMAT(@Date, N'dddd, MMMM dd, yyyy hh:mm:ss tt') Monday, September 05, 2016 ...
The Windows API documentation for functions taking one or more string as argument will usually look like this: BOOL WINAPI CopyFile( _In_ LPCTSTR lpExistingFileName, _In_ LPCTSTR lpNewFileName, _In_ BOOL bFailIfExists ); The datatype for the two string parameters is made of several ...
When you have an input with well defined boundaries and are expecting more than one match in your string, you have two options: Using lazy quantifiers; Using a negated character class. Consider the following: You have a simple templating engine, you want to replace substrings like $[foo] whe...
Dynamic scoping means that variable lookups occur in the scope where a function is called, not where it is defined. $ x=3 $ func1 () { echo "in func1: $x"; } $ func2 () { local x=9; func1; } $ func2 in func1: 9 $ func1 in func1: 3 In a lexically scoped language, func1 would alway...
Suppose we want to receive a function as a parameter, we can do it like this: function foo(otherFunc: Function): void { ... } If we want to receive a constructor as a parameter: function foo(constructorFunc: { new() }) { new constructorFunc(); } function foo(constructorWithParams...
local Class = {} -- objects and classes will be tables local __meta = {__index = Class} -- ^ if an instance doesn't have a field, try indexing the class function Class.new() -- return setmetatable({}, __meta) -- this is shorter and equivalent to: local new_instance = {} setmetatabl...

Page 118 of 505