Tutorial by Examples

docker run --restart=always -d <container> By default, Docker will not restart containers when the Docker daemon restarts, for example after a host system reboot. Docker provides a restart policy for your containers by supplying the --restart command line option. Supplying --restart=always ...
Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Sub FsoExample() Dim fso As Object ' declare variable Set fso = CreateObject("Scripting.FileSystemObject") ' Set it to be a File System Object ' now use it to check if a file exists Dim myFilePath A...
Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Sub ReadTextFileExample() Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") Dim sourceFile As Object Dim myFilePath As String Dim myFileText As String myFilePath = &...
Sub CreateTextFileExample() Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject") Dim targetFile As Object Dim myFilePath As String Dim myFileText As String myFilePath = "C:\mypath\to\myfile.txt" Set targetFile = fso.CreateT...
Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Sub WriteTextFileExample() Dim oFso Set oFso = CreateObject("Scripting.FileSystemObject") Dim oFile as Object Dim myFilePath as String Dim myFileText as String myFilePath = "C:\my...
traverse_ executes an Applicative action for every element in a Foldable structure. It ignores the action's result, keeping only the side-effects. (For a version which doesn't discard results, use Traversable.) -- using the Writer applicative functor (and the Sum monoid) ghci> runWriter $ trave...
In Python you can define a series of conditionals using if for the first one, elif for the rest, up until the final (optional) else for anything not caught by the other conditionals. number = 5 if number > 2: print("Number is bigger than 2.") elif number < 2: # Optional cl...
The ternary operator is used for inline conditional expressions. It is best used in simple, concise operations that are easily read. The order of the arguments is different from many other languages (such as C, Ruby, Java, etc.), which may lead to bugs when people unfamiliar with Python's "s...
Lens operators have useful variants that operate in stateful contexts. They are obtained by replacing ~ with = in the operator name. (+~) :: Num a => ASetter s t a a -> a -> s -> t (+=) :: (MonadState s m, Num a) => ASetter' s a -> a -> m () Note: The stateful variants ar...
Here is some sample XML against which example XPaths can be written: <r> <e a="1"/> <f a="2" b="1">Text 1</f> <f/> <g> <i c="2">Text 2</i> Text 3 <j>Text 4</j> </g&gt...
For the sample XML (without namespaces): This XPath, /r/f/text() will select the text node with this string value: "Text 1" And this XPath, string(/r/f) will return the string value of f, which is also: "Text 1"
For the sample XML (without namespaces): This XPath, /r/e will select this element: <e a="1"/>
JavaScript will try to automatically convert variables to more appropriate types upon use. It's usually advised to do conversions explicitly (see other examples), but it's still worth knowing what conversions take place implicitly. "1" + 5 === "15" // 5 got converted to string. ...
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, ...
Python 2.x2.3 Objects of different types can be compared. The results are arbitrary, but consistent. They are ordered such that None is less than anything else, numeric types are smaller than non-numeric types, and everything else is ordered lexicographically by type. Thus, an int is less than a st...
Any type can be declared as an array using either the dimension attribute or by just indicating directly the dimension(s) of the array: ! One dimensional array with 4 elements integer, dimension(4) :: foo ! Two dimensional array with 4 rows and 2 columns real, dimension(4, 2) :: bar ! Three...
def say_hello_to(name) puts "Hello #{name}" end say_hello_to('Charles') # Hello Charles
def greet(greeting, name) puts "#{greeting} #{name}" end greet('Hi', 'Sophie') # Hi Sophie
def make_animal_sound(sound = 'Cuack') puts sound end make_animal_sound('Mooo') # Mooo make_animal_sound # Cuack It's possible to include defaults for multiple arguments: def make_animal_sound(sound = 'Cuack', volume = 11) play_sound(sound, volume) end make_animal_so...
def welcome_guests(*guests) guests.each { |guest| puts "Welcome #{guest}!" } end welcome_guests('Tom') # Welcome Tom! welcome_guests('Rob', 'Sally', 'Lucas') # Welcome Rob! # Welcome Sally! # W...

Page 121 of 1336