Tutorial by Examples

Because LINQ uses deferred execution, we can have a query object that doesn't actually contain the values, but will return the values when evaluated. We can thus dynamically build the query based on our control flow, and evaluate it once we are finished: IEnumerable<VehicleModel> BuildQuery(i...
While RODBC is restricted to Windows computers with compatible architecture between R and any target RDMS, one of its key flexibilities is to work with Excel files as if they were SQL databases. require(RODBC) con = odbcConnectExcel("myfile.xlsx") # open a connection to the Excel file s...
Current version (log4j2) Using Maven: Add the following dependency to your POM.xml file: <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>2.6.2</version> </de...
First need to create a final static logger object: final static Logger logger = Logger.getLogger(classname.class); Then, call logging methods: //logs an error message logger.info("Information about some param: " + parameter); // Note that this line could throw a NullPointerException!...
Log4j gives you posibility to log data into console and file at same time. Create a log4j.properties file and put inside this basic configuration: # Root logger option log4j.rootLogger=DEBUG, stdout, file # Redirect log messages to console log4j.appender.stdout=org.apache.log4j.ConsoleAppende...
If the help function is called in the console without any arguments, Python presents an interactive help console, where you can find out about Python modules, symbols, keywords and more. >>> help() Welcome to Python 3.4's help utility! If this is your first time using Python, you sho...
To get the value of the last result from your last expression in the console, use an underscore _. >>> 2 + 2 4 >>> _ 4 >>> _ + 6 10 This magic underscore value is only updated when using a python expression that results in a value. Defining functions or for loops ...
The console for the primary version of Python can usually be opened by typing py into your windows console or python on other platforms. $ py Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32 Type "help", "copyright", "credits&...
You can set an environment variable called PYTHONSTARTUP for Python's console. Whenever you enter the Python console, this file will be executed, allowing for you to add extra functionality to the console such as importing commonly-used modules automatically. If the PYTHONSTARTUP variable was set t...
Python has a variety of command-line switches which can be passed to py. These can be found by performing py --help, which gives this output on Python 3.4: Python Launcher usage: py [ launcher-arguments ] [ python-arguments ] script [ script-arguments ] Launcher arguments: -2 : Launch ...
The Python console adds a new function, help, which can be used to get information about a function or object. For a function, help prints its signature (arguments) and its docstring, if the function has one. >>> help(print) Help on built-in function print in module builtins: print(.....
A simple static file server would look like this: package main import ( "net/http" ) func main() { muxer := http.NewServeMux() fileServerCss := http.FileServer(http.Dir("src/css")) fileServerJs := http.FileServer(http.Dir("src/js")) file...
Install the SDK Download & unzip the SDK Make sure you are using the latest version of Xcode (7.0+) and targeting iOS 7.0 or highe Download SDK Add the SDKs to your app Drag the Parse.framework and Bolts.framework you downloaded into your Xcode project folder target. Make sure th...
The For Each loop construct is ideal for iterating all elements of a collection. Public Sub IterateCollection(ByVal items As Collection) 'For Each iterator must always be variant Dim element As Variant For Each element In items 'assumes element can be converted to a stri...
Public Sub DoLoop() Dim entry As String entry = "" 'Equivalent to a While loop will ask for strings until "Stop" in given 'Prefer using a While loop instead of this form of Do loop Do While entry <> "Stop" entry = InputBox("...
'Will return whether an element is present in the array Public Function IsInArray(values() As String, ByVal whatToFind As String) As Boolean Dim i As Integer i = 0 While i < UBound(values) And values(i) <> whatToFind i = i + 1 Wend IsInArray = valu...
The For loop is used to repeat the enclosed section of code a given number of times. The following simple example illustrates the basic syntax: Dim i as Integer 'Declaration of i For i = 1 to 10 'Declare how many times the loop shall be executed Debug.Print i 'Th...
Sometimes you need to keep a linear (non-branching) history of your code commits. If you are working on a branch for a while, this can be tricky if you have to do a regular git pull since that will record a merge with upstream. [alias] up = pull --rebase This will update with your upstream so...
You can use the star * when writing a function to collect all positional (ie. unnamed) arguments in a tuple: def print_args(farg, *args): print("formal arg: %s" % farg) for arg in args: print("another positional arg: %s" % arg) Calling method: print_args(1, &...
You can define a function that takes an arbitrary number of keyword (named) arguments by using the double star ** before a parameter name: def print_kwargs(**kwargs): print(kwargs) When calling the method, Python will construct a dictionary of all keyword arguments and make it available in ...

Page 308 of 1336