Tutorial by Examples: ch

os.access is much better solution to check whether directory exists and it's accesable for reading and writing. import os path = "/home/myFiles/directory1" ## Check if path exists os.access(path, os.F_OK) ## Check if path is Readable os.access(path, os.R_OK) ## Check if path i...
The charset attribute specifies the character encoding for the HTML document and needs to be a valid character encoding (examples include windows-1252, ISO-8859-2, Shift_JIS, and UTF-8). UTF-8 (Unicode) is the most widely used and should be used for any new project. 5 <meta charset="UTF-8...
git diff 1234abc..6789def # old new E.g.: Show the changes made in the last 3 commits: git diff @~3..@ # HEAD -3 HEAD Note: the two dots (..) is optional, but adds clarity. This will show the textual difference between the commits, regardless of where they are in the tree.
Strings in Elixir are "binaries". However, in Erlang code, strings are traditionally "char lists", so when calling Erlang functions, you may have to use char lists instead of regular Elixir strings. While regular strings are written using double quotes ", char lists are wr...
Each time you use a selector in jQuery the DOM is searched for elements that match your query. Doing this too often or repeatedly will decrease performance. If you refer to a specific selector more than once you should add it to the cache by assigning it to a variable: var nav = $('#navigation'); ...
The basics After making changes to your source code, you should stage those changes with Git before you can commit them. For example, if you change README.md and program.py: git add README.md program.py This tells git that you want to add the files to the next commit you do. Then, commit your...
If an object is defined with static, thread, or automatic storage duration, and it has a character type, either: char, unsigned char, or signed char, it may not be accessed by a non-character type. In the below example a char array is reinterpreted as the type int, and the behavior is undefined on e...
Forms can be defined, in a similar manner to models, by subclassing django.forms.Form. Various field input options are available such as CharField, URLField, IntegerField, etc. Defining a simple contact form can be seen below: from django import forms class ContactForm(forms.Form): contac...
Channels can be used to send data from one thread to another. Below is an example of a simple producer-consumer system, where the main thread produces the values 0, 1, ..., 9, and the spawned thread prints them: use std::thread; use std::sync::mpsc::channel; fn main() { // Create a channel...
9.0 // Since the anchor system simply returns constraints, you still need to add them somewhere. View.AddConstraints( new[] { someLabel.TopAnchor.ConstraintEqualTo(TopLayoutGuide.GetBottomAnchor()), anotherLabel.TopAnchor.ConstraintEqualTo(someLabel.BottomAnchor, 6), ...
Note: Uses the Python 3.5+ async/await syntax asyncio supports the use of Executor objects found in concurrent.futures for scheduling tasks asynchronously. Event loops have the function run_in_executor() which takes an Executor object, a Callable, and the Callable's parameters. Scheduling a task f...
A simple way of selecting between functions at compile time is to dispatch a function to an overloaded pair of functions that take a tag as one (usually the last) argument. For example, to implement std::advance(), we can dispatch on the iterator category: namespace details { template <clas...
Python makes it very simple to check whether an item is in a list. Simply use the in operator. lst = ['test', 'twest', 'tweast', 'treast'] 'test' in lst # Out: True 'toast' in lst # Out: False Note: the in operator on sets is asymptotically faster than on lists. If you need to use it ...
Pattern matching can be useful to handle Options: let result = Some("Hello World") match result with | Some(message) -> printfn message | None -> printfn "Not feeling talkative huh?"
Given the text: foo: bar I would like to replace anything following "foo: " with "baz", but I want to keep "foo: ". This could be done with a capturing group like this: s/(foo: ).*/$1baz/ Which results in the text: foo: baz Example 1 or we could use \K,...
A simple switch statement: switch a + b { case c: // do something case d: // do something else default: // do something entirely different } The above example is equivalent to: if a + b == c { // do something } else if a + b == d { // do something else } else { ...
Table Setup CREATE TABLE dbo.Employees ( EmployeeID INT NOT NULL PRIMARY KEY, FirstName NVARCHAR(50) NOT NULL, LastName NVARCHAR(50) NOT NULL, ManagerID INT NULL ) GO INSERT INTO Employees VALUES (101, 'Ken', 'Sánchez', NULL) INSERT INTO Employees VALUES (102, 'Keith', ...
Switch statement make use of partial matching. let coordinates: (x: Int, y: Int, z: Int) = (3, 2, 5) switch (coordinates) { case (0, 0, 0): // 1 print("Origin") case (_, 0, 0): // 2 print("On the x-axis.") case (0, _, 0): // 3 print("On the y-axis.") ca...
All these are shell commands. docker-machine env to get the current default docker-machine configuration eval $(docker-machine env) to get the current docker-machine configuration and set the current shell environment up to use this docker-machine with . If your shell is set up to use a proxy, yo...
All these are shell commands If you need to log onto a running docker-machine directly, you can do that: docker-machine ssh to ssh into the default docker-machine docker-machine ssh machinename to ssh into a non-default docker-machine If you just want to run a single command, you can do so...

Page 13 of 109