Tutorial by Examples: c

When you deploy your app to a (Node.js-specific) hosted environment, this environment usually offers a PORT-environment variable that you can use to run your server on. Changing the port number to process.env.PORT allows you to access the application. For example, http.createServer(function(reques...
You can use the node-inspector. Run this command to install it via npm: npm install -g node-inspector Then you can debug your application using node-debug app.js The Github repository can be found here: https://github.com/node-inspector/node-inspector Debugging natively You can also debu...
strpos can be understood as the number of bytes in the haystack before the first occurrence of the needle. var_dump(strpos("haystack", "hay")); // int(0) var_dump(strpos("haystack", "stack")); // int(3) var_dump(strpos("haystack", "stackoverf...
The intrinsic pack function packs an array into a vector, selecting elements based on a given mask. The function has two forms PACK(array, mask) PACK(array, mask, vector) (that is, the vector argument is optional). In both cases array is an array, and mask of logical type and conformable with...
trait HelloWorld { public function sayHello() { echo 'Hello World!'; } } // Change visibility of sayHello class MyClass1 { use HelloWorld { sayHello as protected; } } // Alias method with changed visibility // sayHello visibility not changed class MyClass2 { u...
Any array can be quickly decomposed by assigning its elements into multiple variables. A simple example: arr = [1, 2, 3] # --- a = arr[0] b = arr[1] c = arr[2] # --- or, the same a, b, c = arr Preceding a variable with the splat operator (*) puts into it an array of all the elements that h...
Consider this broken snippet: def foo bar = [1, 2, 3, 4].map do |x| return 0 if x.even? x end puts 'baz' bar end foo # => 0 One might expect return to yield a value for map's array of block results. So the return value of foo would be [1, 0, 3, 0]. Instead, return retu...
The following compares two files with diff using process substitution instead of creating temporary files. diff <(curl http://www.example.com/page1) <(curl http://www.example.com/page2)
This feeds a while loop with the output of a grep command: while IFS=":" read -r user _ do # "$user" holds the username in /etc/passwd done < <(grep "hello" /etc/passwd)
Problem: Some data needs to be passed to a scene loaded from a fxml. Solution Specify a controller using the fx:controller attribute and get the controller instance created during the loading process from the FXMLLoader instance used to load the fxml. Add methods for passing the data to the contr...
Problem: Some data needs to be passed to a scene loaded from a fxml. Solution Set the controller using the FXMLLoader instance used later to load the fxml. Make sure the controller contains the relevant data before loading the fxml. Note: in this case the fxml file must not contain the fx:contro...
Problem: Some data needs to be passed to a scene loaded from a fxml. Solution Specify a controller factory that is responsible for creating the controllers. Pass the data to the controller instance created by the factory. FXML <?xml version="1.0" encoding="UTF-8"?> &...
LinqPad is a great tool that allows you to learn and test features of .Net languages (C#, F# and VB.Net.) Install LinqPad Create a new Query (Ctrl + N) Under language, select "C# statements" Type the following code and hit run (F5) string hw = "Hello World&quo...
In elm-repl, type a piece of code to get its value and inferred type. Try the following to learn about the various types that exist: > 42 42 : number > 1.987 1.987 : Float > 42 / 2 21 : Float > 42 % 2 0 : Int > 'e' 'e' : Char > "e" "e" : St...
Sometimes a column should show different content than just the toString value of the cell item. In this case the TableCells created by the cellFactory of the TableColumn is customized to change the layout based on the item. Important Note: TableView only creates the TableCells that are shown in the...
A common task is to convert all columns of a data.frame to character class for ease of manipulation, such as in the cases of sending data.frames to a RDBMS or merging data.frames containing factors where levels may differ between input data.frames. The best time to do this is when the data is read ...
1i # => (0+1i) 1.to_c # => (1+0i) rectangular = Complex(2, 3) # => (2+3i) polar = Complex('1@2') # => (-0.4161468365471424+0.9092974268256817i) polar.rectangular # => [-0.4161468365471424, 0.9092974268256817] rectangular.polar # => [3.605551275463989, 0.9827937232...
Metaclass syntax Python 2.x2.7 class MyClass(object): __metaclass__ = SomeMetaclass Python 3.x3.0 class MyClass(metaclass=SomeMetaclass): pass Python 2 and 3 compatibility with six import six class MyClass(six.with_metaclass(SomeMetaclass)): pass
A do construct is a looping construct which has a number of iterations governed by a loop control integer i do i=1, 5 print *, i end do print *, i In the form above, the loop variable i passes through the loop 5 times, taking the values 1 to 5 in turn. After the construct has completed th...
<!--- Define collection ---> <cfset attributes = { "name": "Sales", "type": "text", "value": "Connection" }> <!--- cfloop tag with attribute collection can be used to loop through the elements of a struc...

Page 205 of 826