Tutorial by Examples

Inline assembly will only be supported in nightly versions of Rust until it is stabilized. To enable usage of the asm! macro, use the following feature attribute at the top of the main file (a feature gate): #![feature(asm)] Then use the asm! macro in any unsafe block: fn do_nothing() { u...
Use conditional compilation to ensure that code only compiles for the intended instruction set (such as x86). Otherwise code could become invalid if the program is compiled for another architecture, such as ARM processors. #![feature(asm)] // Any valid x86 code is valid for x86_64 as well. Be ca...
#![feature(asm)] #[cfg(any(target_arch="x86", target_arch="x86_64"))] fn subtract(first: i32, second: i32) { unsafe { // Output values must either be unassigned (let result;) or mutable. let result: i32; // Each value that you pass in will b...
The export tool exports a set of files from HDFS back to an RDBMS. The target table must already exist in the database. The input files are read and parsed into a set of records according to the user-specified delimiters. Example : sqoop export \ --connect="jdbc:<databaseconnector>&quo...
One implementation of the io.Reader interface can be found in the bytes package. It allows a byte slice to be used as the source for a Reader. In this example the byte slice is taken from a string, but is more likely to have been read from a file or network connection. message := []byte("Hello...
Send a Razor part to a @helper, for example a HTML div. @helper WrapInBox(Func<Object, HelperResult> content) { <div class="box">@content(null) </div> } //call @WrapInBox(@<div> I'm a inner div </div>)
@Helpers could be shared between views. They should be created in the folder App_Code @helper CreatePrimaryBootstrapButton(string label) { <button type="button" class="btn btn-primary">@label</button> } //call @MenuHelpers.CreatePrimaryBootstrapButton...
Sometimes it may be required to find out which directory consuming how much disk space especially when you are used df -h and realized your available disk space is low. du: du command summarizes disk usage of the set of FILEs, recursively for directories. It's often uses with -sh option: -s, --s...
First, ensure you have installed mongodb and express via npm. Then, in a file conventionally titled db.js, use the following code: var MongoClient = require('mongodb').MongoClient var state = { db: null, } exports.connect = function(url, done) { if (state.db) return done() M...
The following example is high level coverage of the key concepts and basic skeletal setup:- Collects credentials from the user (Usually from a login screen you've created) Authenticates the credentials with the server (stores custom authentication) Stores the credentials on the device Exte...
A frequent reason why your read operation may not work is because your security rules reject the operation, for example because you're not authenticated (by default a database can only be accessed by an authenticated user). You can see these security rule violations in the JavaScript console of you...
Add a -behaviour directive to your module to indicate that it follows a behaviour: -behaviour(gen_server). The American spelling is also accepted: -behavior(gen_server). Now the compiler will give a warning if you've forgotten to implement and export any of the functions required by the beha...
You can define your own behaviour by adding -callback directives in your module. For example, if modules implementing your behaviour need to have a foo function that takes an integer and returns an atom: -module(my_behaviour). -callback foo(integer()) -> atom(). If you use this behaviour in...
It's easiest to show a binary search on numbers using pseudo-code int array[1000] = { sorted list of numbers }; int N = 100; // number of entries in search space; int high, low, mid; // our temporaries int x; // value to search for low = 0; high = N -1; while(low < high) { mid = (...
In this iText 5 example, we'll create a text field and we'll add it to a PDF: public void manipulatePdf(String src, String dest) throws DocumentException, IOException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); T...
In this iText 7 example, we'll create a text field and we'll add it to a PDF: public void manipulatePdf(String src, String dest) throws IOException { PdfReader reader = new PdfReader(src); PdfDocument pdf = new PdfDocument(reader, new PdfWriter(dest)); PdfAcroForm form = PdfAcroFor...
In this iText 5 example, we'll change the properties and the value of a text field: public void manipulatePdf(String src, String dest) throws DocumentException, IOException { PdfReader reader = new PdfReader(src); PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest)); ...
In this iText 7 example, we'll change the properties and the value of a text field: public void manipulatePdf(String src, String dest) throws IOException { PdfReader reader = new PdfReader(src); PdfDocument pdf = new PdfDocument(reader, new PdfWriter(dest)); PdfAcroForm form = PdfA...
To show you how work the views, we will assume that we want to query the document of type people. To do so, we will first need a design document that will hold our views. Note: for the purpose of the example, we will use many views inside of 1 design document. Therefore, in a production environment...
Integer Basics Standard ML of New Jersey v110.78 [built: Thu Jul 23 11:21:58 2015] - 6; val it = 6 : int - ~6; val it = ~6 : int - 6 + ~6; val it = 0 : int Integer Division - 6 div 3; val it = 2 : int - 6 div 4; val it = 0 : int - 3 div 6; val it = 0 : int Integer Value Bounds Us...

Page 945 of 1336