Tutorial by Examples: c

# Process substitution with paste command is common # To compare the contents of two directories paste <( ls /path/to/directory1 ) <( ls /path/to/directory1 )
To write data to a file using Channel we need to have the following steps: First, we need to get an object of FileOutputStream Acquire FileChannel calling the getChannel() method from the FileOutputStream Create a ByteBuffer and then fill it with data Then we have to call the flip() method of ...
Blueprint actions (not to be confused with blueprint action routes) are generic actions designed to work with any of your controllers that have a model of the same name (e.g. ParrotController would need a Parrot model). Think of them as the default behavior for your application. For instance, if...
set alpha 1 proc myproc {} { puts $alpha } myproc This code doesn't work because the two alphas are in different scopes. The command set alpha 1 creates a variable in the global scope (which makes it a global variable). The command puts $alpha is executed in a scope that is created ...
To print the value of a pointer to an object (as opposed to a function pointer) use the p conversion specifier. It is defined to print void-pointers only, so to print out the value of a non void-pointer it needs to be explicitly converted ("casted*") to void*. #include <stdlib.h> /*...
Sometimes we need to fetch and print the value of a TensorFlow variable to guarantee our program is correct. For example, if we have the following program: import tensorflow as tf import numpy as np a = tf.Variable(tf.random_normal([2,3])) # declare a tensorflow variable b = tf.random_normal([2...
Create a select list that can be used to choose a single or multiple items from a list of values. library(shiny) ui <- fluidPage( selectInput("id_selectInput", label = HTML('<B><FONT size="3">What is your favorite color ?</FONT></B&g...
When dealing with an unbalanced design and/or non-orthogonal contrasts, Type II or Type III Sum of Squares are necessary. The Anova() function from the car package implements these. Type II Sum of Squares assumes no interaction between main effects. If interactions are assumed, Type III Sum of Squar...
An SKView does not need to fill the whole screen and can share space with other UI controls. You can even have more than one SKView displayed at once if you wish. To create a smaller SKView amongst other controls with Interface Builder, first create a normal ViewController, then drag and drop a new...
When a function returns an object (as opposed to using one that's passed in by the caller), be careful an exception doesn't cause the object to leak. function MakeStrings: TStrings; begin // Create a new object before entering the try-block. Result := TStringList.Create; try // Execu...
A try-finally block may be nested inside a try-except block. try AcquireResources; try UseResource; finally ReleaseResource; end; except on E: EResourceUsageError do begin HandleResourceErrors; end; end; If an exception occurs inside UseResource, then execution...
A try-except block may be nested inside a try-finally block. AcquireResource; try UseResource1; try UseResource2; except on E: EResourceUsageError do begin HandleResourceErrors; end; end; UseResource3; finally ReleaseResource; end; If an EResourceUsageE...
The angular.copy function takes an object, array or a value and creates a deep copy of it. angular.copy() Example: Objects: let obj = {name: "vespa", occupation: "princess"}; let cpy = angular.copy(obj); cpy.name = "yogurt" // obj = {name: "vespa", ...
Navigation controller can be embed in each tabs using storyboard it self. It can be like in the screenshot added. To add a Navigation Controller to a View Controller connecting from Tab Bar Controller, here are the flow Select the view controller for which we need to add navigation controller. H...
Consider following html code <ul> <li id=“one” class=“main”>Item 1</li> <li id=“two” class=“main”>Item 2</li> <li id=“three” class=“main”>Item 3</li> <li id=“four”>Item 4</li> </ul> Following dom tree will be constructed ba...
The tr method returns a copy of a string where the characters of the first argument are replaced by the characters of the second argument. "string".tr('r', 'l') # => "stling" To replace only the first occurrence of a pattern with with another expression use the sub method ...
We can use org.apache.commons.lang3.RandomUtils to generate random numbers using a single line. int x = RandomUtils.nextInt(1, 1000); The method nextInt(int startInclusive, int endExclusive) takes a range. Apart from int, we can generate random long, double, float and bytes using this class. R...
Any project that targets netstandard1.X can be packed into a NuGet package by running: dotnet pack The resulting package can be uploaded to NuGet, MyGet, or hosted in a local package source.
This example describes how to create a SurfaceView with a dedicated drawing thread. This implementation also handles edge cases such as manufacture specific issues as well as starting/stopping the thread to save cpu time. import android.content.Context; import android.graphics.Canvas; import and...
If you want to write strings containing other languages (JSON, regexes), it's hard to keep up with escaping symbols, and it would be nice to get some code assist. Put your cursor inside an empty string ALT + ENTER Pick "Inect language or reference" Pick the desirable language (...

Page 311 of 826