Tutorial by Examples: ad

If you have already added a file to your Git repository and now want to stop tracking it (so that it won't be present in future commits), you can remove it from the index: git rm --cached <file> This will remove the file from the repository and prevent further changes from being tracked by...
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 module can be "imported", or otherwise "required" by the require() function. For example, to load the http module that ships with Node.js, the following can be used: const http = require('http'); Aside from modules that are shipped with the runtime, you can also require mod...
When an exception object is created (i.e. when you new it), the Throwable constructor captures information about the context in which the exception was created. Later on, this information can be output in the form of a stacktrace, which can be used to help diagnose the problem that caused the excep...
To load a properties file bundled with your application: public class Defaults { public static Properties loadDefaults() { try (InputStream bundledResource = Defaults.class.getResourceAsStream("defaults.properties")) { Properties defaults = new ...
First, establish if the device is capable of accepting Touch ID input. if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError)) If it does then we can display the Touch ID UI by using: context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometri...
Streams provide the most direct access to the binary content, so any InputStream / OutputStream implementations always operate on ints and bytes. // Read a single byte from the stream int b = inputStream.read(); if (b >= 0) { // A negative value represents the end of the stream, normal values ...
There are two types of events emitted by a Preferences object: PreferenceChangeEvent and NodeChangeEvent. PreferenceChangeEvent A PreferenceChangeEvent gets emitted by a Properties object every time one of the node's key-value-pairs changes. PreferenceChangeEvents can be listened for with a Prefer...
This uses the Dropbox Python SDK to upload a file to the Dropbox API from the local file as specified by file_path to the remote path as specified by dest_path. It also chooses whether or not to use an upload session based on the size of the file: f = open(file_path) file_size = os.path.getsize(fi...
This example uses the Dropbox .NET library to try to get the metadata for an item at a particular path, and checks for a NotFound error: try { var metadata = await this.client.Files.GetMetadataAsync("/non-existant path"); Console.WriteLine(metadata.Name); } catch (Dropbox.Api.A...
Dim input as String = Console.ReadLine() Console.ReadLine() will read the console input from the user, up until the next newline is detected (usually upon pressing the Enter or Return key). Code execution is paused in the current thread until a newline is provided. Afterwards, the next line of co...
Create a snapshot of a whole database: mysqldump [options] db_name > filename.sql Create a snapshot of multiple databases: mysqldump [options] --databases db_name1 db_name2 ... > filename.sql mysqldump [options] --all-databases > filename.sql Create a snapshot of one or more tables...
mysql [options] db_name < filename.sql Note that: db_name needs to be an existing database; your authenticated user has sufficient privileges to execute all the commands inside your filename.sql; The file extension .sql is fully a matter of style. Any extension would work. You cannot spe...
For any file operations, you will need the filesystem module: const fs = require('fs'); Reading a String fs.readFileSync behaves similarly to fs.readFile, but does not take a callback as it completes synchronously and therefore blocks the main thread. Most node.js developers prefer the asynch...
import shutil source='//192.168.1.2/Daily Reports' destination='D:\\Reports\\Today' shutil.copytree(source, destination) The destination directory must not exist already.
This uses the Dropbox .NET SDK to download a file from the Dropbox API at the remote path /Homework/math/Prime_Numbers.txt to the local file Prime_Numbers.txt: using (var response = await client.Files.DownloadAsync("/Homework/math/Prime_Numbers.txt")) { using (var fileStream = File....
Syntax for accessing rows and columns: [, [[, and $ This topic covers the most common syntax to access specific rows and columns of a data frame. These are Like a matrix with single brackets data[rows, columns] Using row and column numbers Using column (and row) names Like a list: Wi...
fetch('/example.json', { headers: new Headers({ 'Accept': 'text/plain', 'X-Your-Custom-Header': 'example value' }) });
The Basics The simplist way to convert one date format into another is to use strtotime() with date(). strtotime() will convert the date into a Unix Timestamp. That Unix Timestamp can then be passed to date() to convert it to the new format. $timestamp = strtotime('2008-07-01T22:35:17.02'); $new_...
Background CSS colors may also be represented as a hex triplet, where the members represent the red, green and blue components of a color. Each of these values represents a number in the range of 00 to FF, or 0 to 255 in decimal notation. Uppercase and/or lowercase Hexidecimal values may be used (i...

Page 7 of 114