As with docopt, with [docopt_dispatch] you craft your --help in the __doc__ variable of your entry-point module. There, you call dispatch with the doc string as argument, so it can run the parser over it.
That being done, instead of handling manually the arguments (which usually ends up in a high c...
If you're just getting started with Chef, we recommend starting off with our Learn Chef tutorial at http://learn.chef.io/.
If you have questions during or after that, check out or discussion forum/mailing list at https://discourse.chef.io/ or our public Slack team at https://community-slack.chef.io...
This example shows how to create a table, insert data, and select from the database using the SQLAlchemy ORM. For information re: SQLAlchemy Core, see here.
First things first, we need to connect to our database, which is identical to how we would connect using SQLAlchemy Core (Core).
from sqlalch...
Unzipping a zip archive is done with unzip function from the utils package (which is included in base R).
unzip(zipfile = "bar.zip", exdir = "./foo")
This will extract all files in "bar.zip" to the "foo" directory, which will be created if necessary. Tilde...
Listing files in a zip archive is done with unzip function from the utils package (which is included in base R).
unzip(zipfile = "bar.zip", list = TRUE)
This will list all files in "bar.zip" and extract none. Tilde expansion is done automatically from your working directory. ...
Listing files in a tar archive is done with untar function from the utils package (which is included in base R).
untar(zipfile = "bar.tar", list = TRUE)
This will list all files in "bar.tar" and extract none. Tilde expansion is done automatically from your working directory. ...
Extracting files from a tar archive is done with untar function from the utils package (which is included in base R).
untar(tarfile = "bar.tar", exdir = "./foo")
This will extract all files in "bar.tar" to the "foo" directory, which will be created if nece...
Chaining and Chainable is a design methodology used to design object behaviors so that calls to object functions return references to self, or another object, providing access to additional function calls allowing the calling statement to chain together many calls without the need to reference the v...
Join parent objects with their child entities, for example we want a relational table of each person and their hobbies
DECLARE @json nvarchar(1000) =
N'[
{
"id":1,
"user":{"name":"John"},
"hobbies":[
{...
Scope guards allow executing statements at certain conditions if the current block is left.
import core.stdc.stdlib;
void main() {
int* p = cast(int*)malloc(int.sizeof);
scope(exit) free(p);
}
Here we have a simple class to be tested that returns a Promise based on the results of an external ResponseProcessor that takes time to execute.
For simplicty we'll assume that the processResponse method won't ever fail.
import {processResponse} from '../utils/response_processor';
const ping =...
Assertions are used not to perform testing of input parameters, but to verify that program flow is corect -- i.e., that you can make certain assumptions about your code at a certain point in time. In other words: a test done with Debug.Assert should always assume that the value tested is true.
Debu...
For multiple quotechars use regex in place of sep:
df = pd.read_csv(log_file,
sep=r'\s(?=(?:[^"]*"[^"]*")*[^"]*$)(?![^\[]*\])',
engine='python',
usecols=[0, 3, 4, 5, 6, 7, 8],
names=['ip', 'time', 'request', 'statu...
This function executes an AJAX request using the HEAD method allowing us to check whether a file exists in the directory given as an argument. It also enables us to launch a callback for each case (success, failure).
function fileExists(dir, successCallback, errorCallback) {
var xhttp = new XM...
d = Dates.dayofweek(now())
if d == 7
println("It is Sunday!")
elseif d == 6
println("It is Saturday!")
elseif d == 5
println("Almost the weekend!")
else
println("Not the weekend yet...")
end
Any number of elseif branches may be used...
Once your project has been created, you can launch the app by typing
$ sails lift
By default, you can access the app in the browser on port 1337. The URL with the port is shown in the terminal.
Another way to start the Sails app is with the node command:
$ node app.js
However, you lose some...
The next function is useful even without iterating. Passing a generator expression to next is a quick way to search for the first occurrence of an element matching some predicate. Procedural code like
def find_and_transform(sequence, predicate, func):
for element in sequence:
if predi...