Tutorial by Examples: c

For branching The short-circuiting conditional operators && and || can be used as lightweight replacements for the following constructs: x && y is equivalent to x ? y : x x || y is equivalent to x ? x : y One use for short-circuit operators is as a more concise way to test a ...
d = Dates.dayofweek(now()) if d == 7 println("It is Sunday!") elseif d == 6 println("It is Saturday!") elseif d == 5 println("Almost the weekend!") else println("Not the weekend yet...") end Any number of elseif branches may be used...
shift(x) = ifelse(x > 10, x + 1, x - 1) Usage: julia> shift(10) 9 julia> shift(11) 12 julia> shift(-1) -2 The ifelse function will evaluate both branches, even the one that is not selected. This can be useful either when the branches have side effects that must be evaluat...
A simplest Oozie application is consists of a workflow logic file (workflow.xml), workflow properties file (job.properties/job.xml) and required JAR files, scripts and configuration files. Except the workflow properties file, all the other files should to be stored in a HDFS location. The workflow p...
Here is a class (Dog) creating its own dependency (Food): class Dog { public Dog() { var food = new Food(); this.eat(food); } } Here is the same class being injected with its dependency using constructor injection: class Dog { public Dog(Food food) { ...
Overview Create a queue that we can send a message to. Oracle will notify our stored procedure that a message has been enqueued and should be worked. We'll also add some subprograms we can use in an emergency to stop messages from being deqeued, allow dequeuing again, and run a simple batch job t...
Once your project has been created, you can launch the app by typing $ sails lift By default, you can access the app in the browser on port 1337. The URL with the port is shown in the terminal. Another way to start the Sails app is with the node command: $ node app.js However, you lose some...
The next function is useful even without iterating. Passing a generator expression to next is a quick way to search for the first occurrence of an element matching some predicate. Procedural code like def find_and_transform(sequence, predicate, func): for element in sequence: if predi...
If you want to change an attribute of a control such as a textbox or label from another thread than the GUI thread that created the control, you will have to invoke it or else you might get an error message stating: "Cross-thread operation not valid: Control 'control_name' accessed from a th...
using System; using System.IO; public class Program { public static void Main() { string filePath = "somePath"; if(File.Exists(filePath)) { Console.WriteLine("Exists"); } else ...
Many functions in Ruby accept a block as an argument. E.g.: [0, 1, 2].map {|i| i + 1} => [1, 2, 3] If you already have a function that does what you want, you can turn it into a block using &method(:fn): def inc(num) num + 1 end [0, 1, 2].map &method(:inc) => [1, 2, 3]...
There are three basic rules of semicolon insertion: When, as the program is parsed from left to right, a token (called the offending token) is encountered that is not allowed by any production of the grammar, then a semicolon is automatically inserted before the offending token if one or more o...
empty statement var statement expression statement do-while statement continue statement break statement return statement throw statement Examples: When the end of the input stream of tokens is encountered and the parser is unable to parse the input token stream as a single complete Pro...
$string = "a;b;c\nd;e;f"; // $1, $2 and $3 represent the first, second and third capturing groups echo preg_replace("(^([^;]+);([^;]+);([^;]+)$)m", "$3;$2;$1", $string); Outputs c;b;a f;e;d Searches for everything between semicolons and reverses the order.
Cursors enable you to itterate results of query one by line. DECLARE command is used to init cursor and associate it with a specific SQL query: DECLARE student CURSOR FOR SELECT name FROM studend; Let's say we sell products of some types. We want to count how many products of each type are exis...
WPF introduces a very handy concept: The ability to store data as a resource, either locally for a control, locally for the entire window or globally for the entire application. The data can be pretty much whatever you want, from actual information to a hierarchy of WPF controls. This allows you to ...
Sharing a simple string was easy, but you can do much more. In this example, I'll also store a complete array of strings, along with a gradient brush to be used for the background. This should give you a pretty good idea of just how much you can do with resources: <Window x:Class="WPFApplic...
If you only need a given resource for a specific control, you can make it more local by adding it to this specific control, instead of the window. It works exactly the same way, the only difference being that you can now only access from inside the scope of the control where you put it: <StackPa...
In this example, we'll be accessing three different resources from Code-behind, each stored in a different scope App.xaml: <Application x:Class="WpfSamples.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http:/...
in this way '0' representing the known values ​​are ranked first, '1' representing the NULL values ​​are sorted by the last: SELECT ID ,REGION ,CITY ,DEPARTMENT ,EMPLOYEES_NUMBER FROM DEPT ORDER BY CASE WHEN REGION IS NULL THEN 1 ELSE 0 END, REGION ...

Page 366 of 826