Tutorial by Examples: c

Using new String(String) to duplicate a string is inefficient and almost always unnecessary. String objects are immutable, so there is no need to copy them to protect against changes. In some older versions of Java, String objects can share backing arrays with other String objects. In those ver...
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...
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...
We can create it by two way. First from database properties designer mode: And by sql scripts: USE master; GO -- Create the database with the default data -- filegroup and a log file. Specify the -- growth increment and the max size for the -- primary data file. CREATE DATABASE TestDB ON...
CROSS APPLY enables you to "join" rows from a table with dynamically generated rows returned by some table-value function. Imagine that you have a Company table with a column that contains an array of products (ProductList column), and a function that parse these values and returns a set ...
CROSS APPLY enables you to "join" rows from a table with collection of JSON objects stored in a column. Imagine that you have a Company table with a column that contains an array of products (ProductList column) formatted as JSON array. OPENJSON table value function can parse these values...
Stop the MySQL (mysqld) server/daemon process. Start the MySQL server process the --skip-grant-tables option so that it will not prompt for a password: mysqld_safe --skip-grant-tables & Connect to the MySQL server as the root user: mysql -u root Change password: (5.7.6 and newer): ALT...
It is well known that you cannot use the same file for input and ouput in the same command. For instance, $ cat header.txt body.txt >body.txt doesn’t do what you want. By the time cat reads body.txt, it has already been truncated by the redirection and it is empty. The final result will be th...
On Julia, you can define more than one method for each function. Suppose we define three methods of the same function: foo(x) = 1 foo(x::Number) = 2 foo(x::Int) = 3 When deciding what method to use (called dispatch), Julia chooses the more specific method that matches the types of the argument...
The clauses in a SELECT have a specific order: SELECT ... FROM ... WHERE ... GROUP BY ... HAVING ... ORDER BY ... -- goes here LIMIT ... OFFSET ...; ( SELECT ... ) UNION ( SELECT ... ) ORDER BY ... -- for ordering the result of the UNION. SELECT ... GROUP_CONCAT(DISTINCT x ORDER B...
ORDER BY x x can be any datatype. NULLs precede non-NULLs. The default is ASC (lowest to highest) Strings (VARCHAR, etc) are ordered according the COLLATION of the declaration ENUMs are ordered by the declaration order of its strings.
ORDER BY x ASC -- same as default ORDER BY x DESC -- highest to lowest ORDER BY lastname, firstname -- typical name sorting; using two columns ORDER BY submit_date DESC -- latest first ORDER BY submit_date DESC, id ASC -- latest first, but fully specifying order. ASC = ASCENDING, DESC ...
ORDER BY FIND_IN_SET(card_type, "MASTER-CARD,VISA,DISCOVER") -- sort 'MASTER-CARD' first. ORDER BY x IS NULL, x -- order by `x`, but put `NULLs` last. Custom ordering SELECT * FROM some_table WHERE id IN (118, 17, 113, 23, 72) ORDER BY FIELD(id, 118, 17, 113, 23, 72); Returns th...
Memcache is a distributed object caching system and uses key-value for storing small data. Before you start calling Memcache code into PHP, you need to make sure that it is installed. That can be done using class_exists method in php. Once it is validated that the module is installed, you start with...

Page 471 of 826