Tutorial by Examples: c

Because data is sensitive when dealt with between two threads (think concurrent read and concurrent write can conflict with one another, causing race conditions), a set of unique objects were made in order to facilitate the passing of data back and forth between threads. Any truly atomic operation c...
PHP is able to parse a number of date formats. If you want to parse a non-standard format, or if you want your code to explicitly state the format to be used, then you can use the static DateTime::createFromFormat method: Object oriented style $format = "Y,m,d"; $time = "2009,2,26&...
Messages can be written with; Write-Verbose "Detailed Message" Write-Information "Information Message" Write-Debug "Debug Message" Write-Progress "Progress Message" Write-Warning "Warning Message" Each of these has a preference variable; $Ve...
Utilizing .Net System.Security.Cryptography.HashAlgorithm namespace to generate the message hash code with the algorithms supported. $example="Nobody expects the Spanish Inquisition." #calculate $hash=[System.Security.Cryptography.HashAlgorithm]::Create("sha256").ComputeHas...
Here is an example of how to define a different action for each Marker's InfoWindow click event. Use a HashMap in which the marker ID is the key, and the value is the corresponding action it should take when the InfoWindow is clicked. Then, use a OnInfoWindowClickListener to handle the event of a ...
zsh loads configuration from the ~/.zshrc file on startup. If you make changes to that file, you can either restart zsh or run the following command to reload the configuration. . ~/.zshrc You can alias this useful command in your ~/.zshrc like this: alias reload=". ~/.zshrc"
Some Java programmers have a general aversion to throwing or propagating exceptions. This leads to code like the following: public Reader getReader(String pathname) { try { return new BufferedReader(FileReader(pathname)); } catch (IOException ex) { System.out.println(&q...
ExecutorService ExecutorService executor = Executors.newFixedThreadPool(50); It is simple and easy to use. It hides low level details of ThreadPoolExecutor. I prefer this one when number of Callable/Runnable tasks are small in number and piling of tasks in unbounded queue does not increase m...
Let's have a look at various options to wait for completion of tasks submitted to Executor ExecutorService invokeAll() Executes the given tasks, returning a list of Futures holding their status and results when everything is completed. Example: import java.util.concurrent.*; import ja...
Entity class @Entity @Table(name = "USER") public class User { @Id @Column(name = "ID") private Long id; @Column(name = "USERNAME") private String username; @ManyToOne @JoinColumn("ORGANIZATION_ID") pr...
If a class is intended to be used polymorphically, with derived instances being stored as base pointers/references, its base class' destructor should be either virtual or protected. In the former case, this will cause object destruction to check the vtable, automatically calling the correct destruc...
We can also specify that a virtual function is pure virtual (abstract), by appending = 0 to the declaration. Classes with one or more pure virtual functions are considered to be abstract, and cannot be instantiated; only derived classes which define, or inherit definitions for, all pure virtual fun...
Consider these two micro-benchmarks: The first benchmark simply creates, starts and joins threads. The thread's Runnable does no work. public class ThreadTest { public static void main(String[] args) throws Exception { while (true) { long start = System.nanoTime(); ...
Starting with a binary image, bwImg, which contains a number of connected objects. >> bwImg = imread('blobs.png'); >> figure, imshow(bwImg), title('Binary Image') To measure properties (e.g., area, centroid, etc) of every object in the image, use regionprops: >> stats = reg...
Conditions can also be expressions: $myInput = 0 switch($myInput) { # because the result of the expression, 4, # does not equal our input this block should not be run. (2+2) { 'True. 2 +2 = 4' } # because the result of the expression, 0, # does equal our input this ...
Given the following CSV-file String,DateTime,Integer First,2016-12-01T12:00:00,30 Second,2015-12-01T12:00:00,20 Third,2015-12-01T12:00:00,20 One can import the CSV rows in PowerShell objects using the Import-Csv command > $listOfRows = Import-Csv .\example.csv > $listOfRows String ...
By default, Import-CSV imports all values as strings, so to get DateTime- and integer-objects, we need to cast or parse them. Using Foreach-Object: > $listOfRows = Import-Csv .\example.csv > $listOfRows | ForEach-Object { #Cast properties $_.DateTime = [datetime]$_.DateTime $...
The simple and most obvious way to use recursion to get the Nth term of the Fibonnaci sequence is this int get_term_fib(int n) { if (n == 0) return 0; if (n == 1) return 1; return get_term_fib(n - 1) + get_term_fib(n - 2); } However, this algorithm does not scale for higher ...
Most Rails developers start by modifying their model information within the template itself: <h1><%= "#{ @user.first_name } #{ @user.last_name }" %></h1> <h3>joined: <%= @user.created_at.in_time_zone(current_user.timezone).strftime("%A, %d %b %Y %l:%M %p&q...
To install and run jboss AS standalone you can follow the processes described below(assuming that you already have java 7 and jdk installed on your mac): Download the jboss application server from here. Unzip the package and extract the folders Set up the your bash_profile like the fo...

Page 491 of 826