Tutorial by Examples: f

Programming in general often requires a decision or a branch within the code to account for how the code operates under different inputs or conditions. Within the C# programming language (and most programming languages for this matter), the simplest and sometimes the most useful way of creating a br...
Following on from the If-Else Statement example, it is now time to introduce the Else If statement. The Else If statement follows directly after the If statement in the If-Else If-Else structure, but intrinsically has has a similar syntax as the If statement. It is used to add more branches to the c...
In order to check whether a value is NaN, isnull() or notnull() functions can be used. In [1]: import numpy as np In [2]: import pandas as pd In [3]: ser = pd.Series([1, 2, np.nan, 4]) In [4]: pd.isnull(ser) Out[4]: 0 False 1 False 2 True 3 False dtype: bool Note that n...
The following command imports CSV files into a MySQL table with the same columns while respecting CSV quoting and escaping rules. load data infile '/tmp/file.csv' into table my_table fields terminated by ',' optionally enclosed by '"' escaped by '"' lines terminated by '\n' ignore 1...
Create custom class for calling multipart/form-data HttpURLConnection request MultipartUtility.java public class MultipartUtility { private final String boundary; private static final String LINE_FEED = "\r\n"; private HttpURLConnection httpConn; priva...
The slice() method returns a copy of a portion of an array. It takes two parameters, arr.slice([begin[, end]]) : begin Zero-based index which is the beginning of extraction. end Zero-based index which is the end of extraction, slicing up to this index but it's not included. If the end is a neg...
// Returns the nth number in the Fibonacci sequence function fibonacci(n) { if (n === 1 || n === 0) { return 1; } else { return fibonacci(n - 1) + fibonacci(n - 2); } }
// Checks a string to see if it is a palindrome bool function IsPalindrome(string input) { if (input.size() <= 1) { return true; } else if (input[0] == input[input.size() - 1]) { return IsPalindrome(input.substr(1,input.size() - 2)); } else { r...
If you have a list, and you want to use the elements of that list as the arguments to a function, what you want is apply: > (apply string-append (list "hello" " " "and hi" " " "are both words")) "hello and hi are both words" > (app...
Functions in Racket can be created with the lambda form. The form takes a list of arguments and a body. (lambda (x y) (* x y)) In the example above, the function takes in two arguments and returns the result of multiplying them. > ((lambda (x y) (* x y)) 4 4) 16 > ((lambda (x y) (* x y)...
Download and install Visual Studio Community 2015 Open Visual Studio Community Click File -> New -> Project Click Templates -> Visual C++ -> Win32 Console Application and then name the project MyFirstProgram. Click Ok Click Next in the following window. Check the Empty proj...
In many instances, you will want to send data from the R server to the JS client. Here is a very simple example: library(shiny) runApp( list( ui = fluidPage( tags$script( "Shiny.addCustomMessageHandler('message', function(params) { alert(params); });" ), ...
To get a value in NSUserDefaults you can use the following functions: Swift arrayForKey(_:) boolForKey(_:) dataForKey(_:) dictionaryForKey(_:) floatForKey(_:) integerForKey(_:) objectForKey(_:) stringArrayForKey(_:) stringForKey(_:) doubleForKey(_:) URLForKey(_:) Objective-C -(nullab...
One of the most useful queries for end users of large RDBMS's is a search of an information schema. Such a query allows users to rapidly find database tables containing columns of interest, such as when attempting to relate data from 2 tables indirectly through a third table, without existing knowl...
REM This is a comment REM is the official comment command.
There are use cases when you might want to rename your app directory to something else. In Laravel4 you could just change a config entry, here's one way to do it in Laravel5. In this example we'll be renaming the app directory to src. Override Application class The directories name app is hardcod...
The function angular.isFunction determines and returns true if and only if the value passed to is a reference to a function. The function returns a reference to the now extended destination object angular.isFunction(fn) Examples var onClick = function(e) {return e}; angular.isFunction(onCli...
The function angular.fromJson will deserialize a valid JSON string and return an Object or an Array. angular.fromJson(string|object) Note that this function is not limited to only strings, it will output a representation of any object passed to it. Examples: angular.fromJson("{\"yo...
Downloading a file from the internet is a very common task required by almost every application your likely to build. To accomplish this, you can use the "System.Net.WebClient" class. The simplest use of this, using the "using" pattern, is shown below: using (var webClient = n...
var A var is a reference variable, similar to variables in languages like Java. Different objects can be freely assigned to a var, so long as the given object has the same type that the var was declared with: scala> var x = 1 x: Int = 1 scala> x = 2 x: Int = 2 scala> x = "foo...

Page 133 of 457