Tutorial by Examples: bas

The datetime module contains three primary types of objects - date, time, and datetime. import datetime # Date object today = datetime.date.today() new_year = datetime.date(2017, 01, 01) #datetime.date(2017, 1, 1) # Time object noon = datetime.time(12, 0, 0) #datetime.time(12, 0) # Curr...
C++11 for loops can be used to iterate over the elements of a iterator-based range, without using a numeric index or directly accessing the iterators: vector<float> v = {0.4f, 12.5f, 16.234f}; for(auto val: v) { std::cout << val << " "; } std::cout <<...
If you want to squash the previous x commits into a single one, you can use the following commands: git reset --soft HEAD~x git commit Replacing x with the number of previous commits you want to be included in the squashed commit. Mind that this will create a new commit, essentially forgetting...
Commits can be squashed during a git rebase. It is recommended that you understand rebasing before attempting to squash commits in this fashion. Determine which commit you would like to rebase from, and note its commit hash. Run git rebase -i [commit hash]. Alternatively, you can type HE...
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...
In this example, we can use GROUP BY not only determined the sort of the rows returned, but also what rows are returned, since we're using TOP to limit the result set. Let's say we want to return the top 5 highest reputation users from an unnamed popular Q&A site. Without ORDER BY This query ...
To use an accordion, one must have headers and content inside the headers in their HTML. Then one must instantiate the accordion() method of jQuery UI. <script> $(function() { $( "#accordion" ).accordion(); }); </script> In the HTML: <div id="accordion&quot...
A typical email has three main components: A recipient (represented as an email address) A subject A message body Sending mail in PHP can be as simple as calling the built-in function mail(). mail() takes up to five parameters but the first three are all that is required to send an email (al...
A positive lookahead (?=123) asserts the text is followed by the given pattern, without including the pattern in the match. Similarly, a positive lookbehind (?<=123) asserts the text is preceded by the given pattern. Replacing the = with ! negates the assertion. Input: 123456 123(?=456) mat...
The pipe operator, %>%, is used to insert an argument into a function. It is not a base feature of the language and can only be used after attaching a package that provides it, such as magrittr. The pipe operator takes the left-hand side (LHS) of the pipe and uses it as the first argument of the ...
A group is a section of a regular expression enclosed in parentheses (). This is commonly called "sub-expression" and serves two purposes: It makes the sub-expression atomic, i.e. it will either match, fail or repeat as a whole. The portion of text it matched is accessible in the remai...
Before publishing a package you have to version it. npm supports semantic versioning, this means there are patch, minor and major releases. For example, if your package is at version 1.2.3 to change version you have to: patch release: npm version patch => 1.2.4 minor release: npm version min...
for (x <- 1 to 10) println("Iteration number " + x) This demonstrates iterating a variable, x, from 1 to 10 and doing something with that value. The return type of this for comprehension is Unit.
This demonstrates a filter on a for-loop, and the use of yield to create a 'sequence comprehension': for ( x <- 1 to 10 if x % 2 == 0) yield x The output for this is: scala.collection.immutable.IndexedSeq[Int] = Vector(2, 4, 6, 8, 10) A for comprehension is useful when you need to crea...
A CLOS class is described by: a name a list of superclasses a list of slots further options like documentation Each slot has: a name an initialization form (optional) an initialization argument (optional) a type (optional) a documentation string (optional) accessor, reader and/or wr...
Go is a statically typed language, meaning you generally have to declare the type of the variables you are using. // Basic variable declaration. Declares a variable of type specified on the right. // The variable is initialized to the zero value of the respective type. var x int var s string va...
A database snapshot is a read-only, static view of a SQL Server database (the source database). It is similar to backup, but it is available as any other database so client can query snapshot database. CREATE DATABASE MyDatabase_morning -- name of the snapshot ON ( NAME=MyDatabase_data, -- l...
If data in a source database becomes damaged or some wrong data is written into database, in some cases, reverting the database to a database snapshot that predates the damage might be an appropriate alternative to restoring the database from a backup. RESTORE DATABASE MYDATABASE FROM DATABASE_SNAP...
The first two arguments to format are an output stream and a control string. Basic use does not require additional arguments. Passing t as the stream writes to *standard-output*. > (format t "Basic Message") Basic Message nil That expression will write Basic Message to standard ou...

Page 5 of 65