Tutorial by Examples

In most cases, it is illegal to access an object of one type as though it were a different type (disregarding cv-qualifiers). Example: float x = 42; int y = reinterpret_cast<int&>(x); The result is undefined behavior. There are some exceptions to this strict aliasing rule: An obj...
Consider writing a "hello world!" program in c. Lets say our source code is in a file called source.c, now in order to run our program we need to compile it, typically on Linux (using gcc) we would need to type $> gcc source.c -o output where output is the name of the executable to be g...
This example will call the windows calculator. It's important to notice that the exit code will vary accordingly to the program/script that is being called. package process.example; import java.io.IOException; public class App { public static void main(String[] args) { try { ...
The ProcessBuilder class makes it easy to send a command through the command line. All it requires is a List of Strings that make up the commands to be entered. You simply call the start() method on your ProcessBuilder instance to execute the command. If you have a program called Add.exe which take...
In general when making a call to the command line, the program will send the command and then continue its execution. However you may want to wait for the called program to finish before continuing your own execution (ex. The called program will write data to a file and your program needs that to a...
Launching external processes from Java using the raw java.lang.ProcessBuilder API directly can be a little cumbersome. The Apache Commons Exec library makes it a little easier. The ch.vorburger.exec library further extends upon Commons Exec to make it truly convenient: ManagedProcess proc = new ...

!!

(read as bangbang) is a shortcut to repeat the last command entered in console. It is especially useful to run previous command with some changes adduser tom adduser: Only root may add a user or group to the system. Oh snap, what now? Well you could retype the command with sudo in front or...
The ngCopy directive specifies behavior to be run on a copy event. Prevent a user from copying data <p ng-copy="blockCopy($event)">This paragraph cannot be copied</p> In the controller $scope.blockCopy = function(event) { event.preventDefault(); console.log(&quo...
The ngPaste directive specifies custom behavior to run when a user pastes content <input ng-paste="paste=true" ng-init="paste=false" placeholder='paste here'> pasted: {{paste}}
var recordType = 'customer'; // The type of record to load. The string internal id. var recordID = 100; // The specific record instances numeric internal id. var initializeValues = null; /* The first two parameters are required but the third -- * in this case the variable initializeValues -- i...
This example assumes that the record module is set to the variable RECORDMODULE, as shown below. require(['N/record'], function(RECORDMODULE){ var recordType = RECORDMODULE.Type.SALES_ORDER; //The type of record to load. var recordID = 100; //The internal ID of the existing record insta...
This proxy simply appends the string " went through proxy" to every string property set on the target object. let object = {}; let handler = { set(target, prop, value){ // Note that ES6 object syntax is used if('string' === typeof value){ target[prop] = valu...
Laravel's events allows to implement the Observer pattern. This can be used to send a welcome email to a user whenever they register on your application. New events and listeners can be generated using the artisan command line utility after registering the event and their particular listener in App...
Here's a way to show a GIF preloader while an AJAX call is executing. We need to prepare our add and remove preloader functions: function addPreloader() { // if the preloader doesn't already exist, add one to the page if(!document.querySelector('#preloader')) { var preloaderHTML = '<...
Get current time: Time.now Time.new # is equivalent if used with no parameters Get specific time: Time.new(2010, 3, 10) #10 March 2010 (Midnight) Time.new(2015, 5, 3, 10, 14) #10:14 AM on 3 May 2015 Time.new(2050, "May", 3, 21, 8, 16, "+10:00") #09:08:16 PM on 3 May 2050...
DATA: <TABLE NAME> TYPE <SORTED|STANDARD|HASHED> TABLE OF <TYPE NAME> WITH <UNIQUE|NON-UNIQUE> KEY <FIELDS FOR KEY>. Standard Table This table has all of the entries stored in a linear fashion and records are accessed in a linear way. For large table sizes, ...
Notice, this is only for angular-cli up to 1.0.0-beta.10 version ! Some libraries or plugins may not have typings. Without these, TypeScript can't type check them and therefore causes compilation errors. These libraries can still be used but differently than imported modules. Include a scr...
For example: ActiveRecord::Base.transaction do david.withdrawal(100) mary.deposit(100) end This example will only take money from David and give it to Mary if neither withdrawal nor deposit raise an exception. Exceptions will force a ROLLBACK that returns the database to the state before ...
Though the transaction class method is called on some ActiveRecord class, the objects within the transaction block need not all be instances of that class. This is because transactions are per-database connection, not per-model. In this example a balance record is transactionally saved even though ...
A transaction acts on a single database connection. If you have multiple class-specific databases, the transaction will not protect interaction among them. One workaround is to begin a transaction on each class whose models you alter: Student.transaction do Course.transaction do course.enro...

Page 638 of 1336