Tutorial by Examples: cs

String html = "<!DOCTYPE html>" + "<html>" + "<head>" + "<title>Hello world!</title>" + "</head>" + "<body>" + ...
Properties can be added to a class or struct (technically enums too, see "Computed Properties" example). These add values that associate with instances of classes/structs: class Dog { var name = "" } In the above case, instances of Dog have a property named name of type...
Using the threading module, a new thread of execution may be started by creating a new threading.Thread and assigning it a function to execute: import threading def foo(): print "Hello threading!" my_thread = threading.Thread(target=foo) The target parameter references the fun...
A typical email has three main components: A recipient (represented as an email address) A subject A message body Sending mail in PHP can be as simple as calling the built-in function mail(). mail() takes up to five parameters but the first three are all that is required to send an email (al...
A positive lookahead (?=123) asserts the text is followed by the given pattern, without including the pattern in the match. Similarly, a positive lookbehind (?<=123) asserts the text is preceded by the given pattern. Replacing the = with ! negates the assertion. Input: 123456 123(?=456) mat...
Before publishing a package you have to version it. npm supports semantic versioning, this means there are patch, minor and major releases. For example, if your package is at version 1.2.3 to change version you have to: patch release: npm version patch => 1.2.4 minor release: npm version min...
Razor code can be inserted anywhere within HTML code. Razor code blocks are enclosed in @{ ... }. Inline variable and functions start with @. Code inside the Razor brackets follow the normal C# or VB rules. Single line statement: @{ var firstNumber = 1; } Multi-line code block: @{ var sec...
Many IDEs provide support for generating HTML from Javadocs automatically; some build tools (Maven and Gradle, for example) also have plugins that can handle the HTML creation. However, these tools are not required to generate the Javadoc HTML; this can be done using the command line javadoc tool. ...
<link rel="stylesheet" href="path/to.css" type="text/css"> The standard practice is to place CSS <link> tags inside the <head> tag at the top of your HTML. This way the CSS will be loaded first and will apply to your page as it is loading, rather th...
You can embed another template body into your template via {{template "mysharedtemplate" .}} to reuse shared components. Here is an example that creates a header template that can be reused at the top of all other template bodies. It also uses CSS to stylize the output so that it is easier...
Swift's C interoperability allows you to use functions and types from the C standard library. On Linux, the C standard library is exposed via the Glibc module; on Apple platforms it's called Darwin. #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) import Darwin #elseif os(Linux) import Glibc...
What is Serialization Serialization is the process of converting an object's state (including its references) to a sequence of bytes, as well as the process of rebuilding those bytes into a live object at some future time. Serialization is used when you want to persist the object. It is also used b...
If a selection on multiple arguments for a type generic expression is wanted, and all types in question are arithmetic types, an easy way to avoid nested _Generic expressions is to use addition of the parameters in the controlling expression: int max_int(int, int); unsigned max_unsigned(unsigned, ...
Example for reading file data_file.csv such as: File: index,header1,header2,header3 1,str_data,12,1.4 3,str_data,22,42.33 4,str_data,2,3.44 2,str_data,43,43.34 7, str_data, 25, 23.32 Code: pd.read_csv('data_file.csv') Output: index header1 header2 header3 0 1 str_dat...
Java 8 provides classes called IntSummaryStatistics, DoubleSummaryStatistics and LongSummaryStatistics which give a state object for collecting statistics such as count, min, max, sum, and average. Java SE 8 List<Integer> naturalNumbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); IntSu...
There are 4 looping constructs in Rust. All examples below produce the same output. Infinite Loops let mut x = 0; loop { if x > 3 { break; } println!("{}", x); x += 1; } While Loops let mut x = 0; while x <= 3 { println!("{}", x); x += 1; ...
A new thread separate from the main thread's execution, can be created using Thread.new. thr = Thread.new { sleep 1 # 1 second sleep of sub thread puts "Whats the big deal" } This will automatically start the execution of the new thread. To freeze execution of the main Thread, ...
fn main() { // Statically allocated string slice let hello = "Hello world"; // This is equivalent to the previous one let hello_again: &'static str = "Hello world"; // An empty String let mut string = String::new(); // An empty String ...
This example use the default boxplot() function and the irisdata frame. > head(iris) Sepal.Length Sepal.Width Petal.Length Petal.Width Species 1 5.1 3.5 1.4 0.2 setosa 2 4.9 3.0 1.4 0.2 setosa 3 4.7 3.2 ...
foo = 1 bar = 'bar' baz = 3.14 You can use str.format to format output. Bracket pairs are replaced with arguments in the order in which the arguments are passed: print('{}, {} and {}'.format(foo, bar, baz)) # Out: "1, bar and 3.14" Indexes can also be specified inside the bracket...

Page 2 of 24