Tutorial by Examples

Microsoft.CodeAnalysis.CSharp.Scripting.CSharpScript is a new C# script engine. var code = "(1 + 2).ToString()"; var run = await CSharpScript.RunAsync(code, ScriptOptions.Default); var result = (string)run.ReturnValue; Console.WriteLine(result); //output 3 You can compile and run an...
Microsoft.CSharp.CSharpCodeProvider can be used to compile C# classes. var code = @" public class Abc { public string Get() { return ""abc""; } } "; var options = new CompilerParameters(); options.GenerateExecutable = false; options.GenerateInMe...
A module is a single Python file that can be imported. Using a module looks like this: module.py def hi(): print("Hello world!") my_script.py import module module.hi() in an interpreter >>> from module import hi >>> hi() # Hello world!
A package is made up of multiple Python files (or modules), and can even include libraries written in C or C++. Instead of being a single file, it is an entire folder structure which might look like this: Folder package __init__.py dog.py hi.py __init__.py from package.dog import woof fro...
This example shows how Stopwatch can be used to benchmark a block of code. using System; using System.Diagnostics; public class Benchmark : IDisposable { private Stopwatch sw; public Benchmark() { sw = Stopwatch.StartNew(); } public voi...
C-style bit-manipulation x = -1; // -1 == 1111 1111 ... 1111b (See here for an explanation of why this works and is actually the best approach.) Using std::bitset std::bitset<10> x; x.set(); // Sets all bits to '1'
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...
Installing the haystack package pip install django-haystack Configuration Add haystack to your project's INSTALLED_APPS inside of your settings.py file: # settings.py INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', # Put...
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...
HTTP/1.0 was described in RFC 1945. HTTP/1.0 does not have some features that are today de-facto required on the Web, such as the Host header for virtual hosts. However, HTTP clients and servers sometimes still declare they use HTTP/1.0 if they have incomplete implementation of the HTTP/1.1 protoc...
HTTP/1.1 has originally been specified in 1999 in RFC 2616 (protocol) and RFC 2617 (authentication), but these documents are now obsolete and should not be used as a reference: Don’t use RFC2616. Delete it from your hard drives, bookmarks, and burn (or responsibly recycle) any copies that are pri...
HTTP/2 (RFC 7540) changed on-the-wire format of HTTP from a simple text-based request and response headers to binary data format sent in frames. HTTP/2 supports compression of the headers (HPACK). This reduced overhead of requests, and enabled receiving of multiple responses simultaneously over a s...
The option -v followed by an assignment of the form variable=value can be used to pass parameters to an awk program. This is illustrated by the punishment program below, whose job is to write count times the sentence “I shall not talk in class.” on standard output. The following example uses the v...
The awk language does not directly support variables local to functions. It is however easy emulate them by adding extra arguments to functions. It is traditional to prefix these variables by a _ to indicate that they are not actual parameters. We illustrate this technique with the definition of a...
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...
ng-model-options allows to change the default behavior of ng-model, this directive allows to register events that will fire when the ng-model is updated and to attach a debounce effect. This directive accepts an expression that will evaluate to a definition object or a reference to a scope value. ...
// 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); } }

Page 409 of 1336