Tutorial by Examples

NIO appeared in Java 1.4 and introduced the concept of "Channels", which are supposed to be faster than regular I/O. Network-wise, the SelectableChannel is the most interesting as it allows to monitor different states of the Channel. It works in a similar manner as the C select() system ca...
It is very common to get a StackOverflowError error while calling recursive function. Scala standard library offers TailCall to avoid stack overflow by using heap objects and continuations to store the local state of the recursion. Two examples from the scaladoc of TailCalls import scala.util.cont...
NSLog is good, but you can also log by appending to a file instead, using code like: NSFileHandle* fh = [NSFileHandle fileHandleForWritingAtPath:path]; if ( !fh ) { [[NSFileManager defaultManager] createFileAtPath:path contents:nil attributes:nil]; fh = [NSFileHandle fileHandleForWriting...
C# allows using pointer variables in a function of code block when it is marked by the unsafe modifier. The unsafe code or the unmanaged code is a code block that uses a pointer variable. A pointer is a variable whose value is the address of another variable i.e., the direct address of the memory l...
You can retrieve the data stored at the located referenced by the pointer variable, using the ToString() method. The following example demonstrates this: using System; namespace UnsafeCodeApplication { class Program { public static void Main() { unsafe { ...
You can pass a pointer variable to a method as parameter. The following example illustrates this: using System; namespace UnsafeCodeApplication { class TestPointer { public unsafe void swap(int* p, int *q) { int temp = *p; *p = *q; *q = temp; ...
In C#, an array name and a pointer to a data type same as the array data, are not the same variable type. For example, int *p and int[] p, are not same type. You can increment the pointer variable p because it is not fixed in memory but an array address is fixed in memory, and you can't increment th...
For compiling unsafe code, you have to specify the /unsafe command-line switch with command-line compiler. For example, to compile a program named prog1.cs containing unsafe code, from command line, give the command: csc /unsafe prog1.cs If you are using Visual Studio IDE then you need to enabl...
$ gzip extremelylargefile.txt & $ bg $ disown %1 This allows a long running process to continue once your shell (terminal, ssh, etc) is closed.
Simple single port RAM with async read/write operations module ram_single_port_ar_aw #( parameter DATA_WIDTH = 8, parameter ADDR_WITDH = 3 )( input we, // write enable input oe, // output enable input [(ADDR_WITDH-1):0] waddr, // ...
The PATH environment variable is generally defined in ~/.bashrc or ~/.bash_profile or /etc/profile or ~/.profile or /etc/bash.bashrc (distro specific Bash configuration file) $ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jv...
a Character evaluates to true if it's value is not zero, false if zero assert ! new Character((char)0) assert ! new Character('\u0000Hello Zero Char'.charAt(0)) assert new Character('Hello'.charAt(0))
a Matcher evaluates to true if it can find at least one match, false if no match is found // a match is found => true assert 'foo' =~ /[a-z]/ // the regexp does not match fully => no match => false assert !( 'foo' ==~ /[a-z]/ ) // a match is found => true assert 'foo' =~ /o/ // no...
The evaluation of a closure is the evaluation of the result of the closure. All rules applies : if the closure returns a null , zero number or empty String, Collection, Map or Array it evaluates to false otherwise to true. // Closure return non zero number => true assert { 42 }() // closure ...
There are frequent behavior patterns that can result in a lot of boilerplate code. By declaring a method that takes a Closure as a parameter, you can simplify your program. As an example, it is a common pattern to retrieve a database connection, start a transaction, do work, and then either commit ...
To remove a PATH from a PATH environment variable, you need to edit ~/.bashrc or ~/.bash_profile or /etc/profile or ~/.profile or /etc/bash.bashrc (distro specific) file and remove the assignment for that particular path. Instead of finding the exact assignment, you could just do a replacement in t...
Detailed instructions on getting apache-poi set up or installed.
<button class="btn btn-default" type="button">Default</button> <button class="btn btn-primary" type="button">Primary</button> <button class="btn btn-success" type="button">Success</button> <button c...
app.ts import {Component} from '@angular/core'; import {Platform, ionicBootstrap} from 'ionic-angular'; import {StatusBar} from 'ionic-native'; import {LoginPage} from './pages/login/login'; import {FIREBASE_PROVIDERS, defaultFirebase, AuthMethods, AuthProviders, firebaseAuthConfig} from 'angul...
Model: public class SampleViewModel { public HttpPostedFileBase file {get;set;} } View: @model HelloWorldMvcApp.SampleViewModel @using (Html.BeginForm("Index","Home",FormMethod.Post, new { enctype = "multipart/form-data" })) { <div class="fo...

Page 770 of 1336