Tutorial by Examples

We're all used to the while syntax, that executes its body while the condition is evaluated to true. What if we want to implement an until loop, that executes a loop until the condition is evaluated to true? In Julia, we can do this by creating a @until macro, that stops to execute its body when th...
A statement is constructed with a function such as sqlite3_prepare_v2(). A prepared statement object must be cleaned up with sqlite3_finalize(). Do not forget this in case of an error. If parameters are used, set their values with the sqlite3_bind_xxx() functions. The actual execution happens whe...
A SELECT query is executed like any other statement. To read the returned data, call sqlite3_step() in a loop. It returns: SQLITE_ROW: if the data for the next row is available, or SQLITE_DONE: if there are no more rows, or any error code. If a query does not return any rows, the very first...
Once we have Odoo installed, we need to create a server instance. A server instance is an Odoo service listening on a specific port, 8060, by default, and using a database to store data. The minimal command to start an Odoo instance using the mydb database: $ ./odoo.py -d mydb If the database ...
gnu-cobol is available via the homebrew system. Open a terminal window from /Applications/Utilities/Terminal or use the keypress Command+Space and type "Terminal". If you do not have the homebrew system installed, add it by typing, or copying and pasting into your terminal: ruby -e &quo...
PHP has built in function pcntl_fork for creating child process. pcntl_fork is same as fork in unix. It does not take in any parameters and returns integer which can be used to differentiate between parent and child process. Consider the following code for explanation <?php // $pid is the P...
Interprocess communication allows programmers to communicate between different processes. For example let us consider we need to write an PHP application that can run bash commands and print the output. We will be using proc_open , which will execute the command and return a resource that we can com...
# This uses the 'sample.xml' given in the XML::Twig example. # Module requirements (1.70 and above for use of load_xml) use XML::LibXML '1.70'; # let's be a good perl dev use strict; use warnings 'all'; # Create the LibXML Document Object my $xml = XML::LibXML->new(); # Where ...
Standalone Common Lisp binaries can be built with buildapp. Before we can use it to generate binaries, we need to install and build it. The easiest way I know how is using quicklisp and a Common Lisp (this example uses [sbcl], but it shouldn't make a difference which one you've got). $ sbcl Thi...
The simplest possible binary you could build Has no dependencies Takes no command line arguments Just writes "Hello world!" to stdout After you've built buildapp, you can just... $ buildapp --eval '(defun main (argv) (declare (ignore argv)) (write-line "Hello, world!"))'...
A more realistic example involves a project you're building with multiple files on disk (rather than an --eval option passed to buildapp), and some dependencies to pull in. Because arbitrary things can happen during the finding and loading of asdf systems (including loading other, potentially unrel...
One example per topic may be pinned by clicking the pin icon in the bottom left corner of the example. So long as a topic is pinned, it will stay at the top of a topic's example collection.
Aside from pinned examples, it is not possible to enforce the order of examples. Instead, order is naturally selected in descending order of total votes. The most popular example will therefore bubble to the top of the collection of examples.
HTML Form Use a file type input and the browser will provide a field that lets the user select a file to upload. Only forms with the post method can send file data. Make sure to set the form's enctype=multipart/form-data attribute. Otherwise the file's name will be sent but not the file's data...
Uploaded files are available in request.files, a MultiDict mapping field names to file objects. Use getlist — instead of [] or get — if multiple files were uploaded with the same field name. request.files['profile'] # single file (even if multiple were sent) request.files.getlist('charts') # li...
WTForms provides a FileField to render a file type input. It doesn't do anything special with the uploaded data. However, since Flask splits the form data (request.form) and the file data (request.files), you need to make sure to pass the correct data when creating the form. You can use a Combine...
It may be useful to have one catch-all view where you handle complex logic yourself based on the path. This example uses two rules: The first rule specifically catches / and the second rule catches arbitrary paths with the built-in path converter. The path converter matches any string (including sl...
An enumerations value in no way needs to be unique: #include <stdlib.h> /* for EXIT_SUCCESS */ #include <stdio.h> /* for printf() */ enum Dupes { Base, /* Takes 0 */ One, /* Takes Base + 1 */ Two, /* Takes One + 1 */ Negative = -1, AnotherZero /* Takes Negativ...
SQL Server 2008 R2 SET TRANSACTION ISOLATION LEVEL REPEATABLE READ This transaction isolation level is slightly less permissive than READ COMMITTED, in that shared locks are placed on all data read by each statement in the transaction and are held until the transaction completes, as opposed to b...
SQL Server 2008 R2 SET TRANSACTION ISOLATION LEVEL SNAPSHOT Specifies that data read by any statement in a transaction will be the transactionally consistent version of the data that existed at the start of the transaction, i.e., it will only read data that has been committed prior to the transa...

Page 761 of 1336