Tutorial by Examples

System.IO.Compression.ZipFile.ExtractToDirectory("archive.zip", "myfolder") Extracts archive.zip to myfolder directory. In example paths are relative to program working directory. You can specify absolute paths.
' Create filestream to file Using fileStream = New IO.FileStream("archive.zip", IO.FileMode.Create) ' open zip archive from stream Using archive = New System.IO.Compression.ZipArchive(fileStream, IO.Compression.ZipArchiveMode.Create) ' create file_in_archive.txt in arch...
Self types can be used in traits and classes to define constraints on the concrete classes it is mixed to. It is also possible to use a different identifier for the this using this syntax (useful when outer object has to be referenced from an inner object). Assume you want to store some objects. Fo...
#!/bin/bash FILENAME="/etc/passwd" while IFS=: read -r username password userid groupid comment homedir cmdshell do echo "$username, $userid, $comment $homedir" done < $FILENAME In unix password file, user information is stored line by line, each line consisting of i...
In Object Oriented Programming a common task is to compose objects (values). In Functional Programming it is as common task to compose values as well as functions. We are used to compose values from our experience of other programming languages using operators like +, -, *, / and so on. Value co...
In a statically typed language like F# we work with types well-known at compile-time. We consume external data sources in a type-safe manner using type providers. However, occassionally there's need to use late binding (like dynamic in C#). For instance when working with JSON documents that have...
let seq = seq {0..10} s |> Seq.map (fun x -> x * 2) > val it : seq<int> = seq [2; 4; 6; 8; ...] Apply a function to every element of a sequence using Seq.map
Assumptions: TableView - reference to the TableView DataSource - is a class which inherits UITableViewSource DataSource.Objects - is a public List< object >(), accessible to the UIViewController private UIRefreshControl refreshControl; public override void ViewDidLoad() { base.V...
Named Types Dim someInstance As New SomeClass(argument) With { .Member1 = value1, .Member2 = value2 '... } Is equivalent to Dim someInstance As New SomeClass(argument) someInstance.Member1 = value1 someInstance.Member2 = value2 '... Anonymous Types (Option...
Arrays Dim names = {"Foo", "Bar"} ' Inferred as String() Dim numbers = {1, 5, 42} ' Inferred as Integer() Containers (List(Of T), Dictionary(Of TKey, TValue), etc.) Dim names As New List(Of String) From { "Foo", "Bar" '... ...
A for loop iterates from the starting value to the ending value inclusive. program SimpleForLoop; {$APPTYPE CONSOLE} var i : Integer; begin for i := 1 to 10 do WriteLn(i); end. Output: 1 2 3 4 5 6 7 8 9 10
You might expect a Python dictionary to be sorted by keys like, for example, a C++ std::map, but this is not the case: myDict = {'first': 1, 'second': 2, 'third': 3} print(myDict) # Out: {'first': 1, 'second': 2, 'third': 3} print([k for k in myDict]) # Out: ['second', 'third', 'first'] Py...
This example demonstrates POSIX Timer usage with CLOCK_REALTIME clock and SIGEV_THREAD notification method. #include <stdio.h> /* for puts() */ #include <string.h> /* for memset() */ #include <unistd.h> /* for sleep() */ #include <stdlib.h> /* for EXIT_SUCCESS */ #inc...
C# using OpenQA.Selenium using OpenQA.Selenium.Chrome; using System.Threading; namespace WebDriver Tests { class WebDriverWaits { static void Main() { IWebDriver driver = new ChromeDriver(@"C:\WebDriver"); driver.Na...
scrollViewDidEndDecelerating: this tells the delegate that the scroll view has ended decelerating the scrolling movement. Objective C: - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self stoppedScrolling]; } - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView w...
This example shows how to define a simple model in Sails.js You can generate an empty model file by typing sails generate model car You'll find the new file Car.js in api/models/. Next, you fill in some details. modules.exports = { tableName : 'cars', connection : 'mongodb', attr...
Using sync.Pool structure we can pool objects and reuse them. package main import ( "bytes" "fmt" "sync" ) var pool = sync.Pool{ // New creates an object when the pool has nothing available to return. // New must return an interface{} to...
The main app file loads any routes files in which you would like to define routes. To do so we need the following directory structure: app.js routes/index.js routes/users.js app.js var express = require('express'); var app = express(); app.use('/', require('./routes/index')); app.use('/us...
Methods that perform asynchronous operations don't need to use await if: There is only one asynchronous call inside the method The asynchronous call is at the end of the method Catching/handling exception that may happen within the Task is not necessary Consider this method that returns a Ta...

Page 631 of 1336