# 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 ...
We can use PrintStream class to write a file. It has several methods that let you print any data type values. println() method appends a new line.
Once we are done printing, we have to flush the PrintStream.
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.time.Local...
When you run sails lift with blueprints enabled, the framework inspects your
controllers, models, and configuration in order to bind certain routes automatically. These implicit blueprint routes allow your app to respond
to certain requests without you having to bind those routes manually in your
...
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...
Global basis:
Blueprint API configuration is defined in /config/blueprint.js file. You can
enable or disable all three types of blueprint routes for all controllers from
there. As example, if you want to disable blueprint shortcut routes for all of
your controllers but want to keep both acti...
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 ...
PHP provides support for the HTTP PUT method used by some clients to store files on a server. PUT requests are much simpler than a file upload using POST requests and they look something like this:
PUT /path/filename.html HTTP/1.1
Into your PHP code you would then do something like this:
<?p...
Python programs can read from unix pipelines. Here is a simple example how to read from stdin:
import sys
for line in sys.stdin:
print(line)
Be aware that sys.stdin is a stream. It means that the for-loop will only terminate when the stream has ended.
You can now pipe the output of anot...
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...
Consider the following three equations:
x0 + 2 * x1 + x2 = 4
x1 + x2 = 3
x0 + x2 = 5
We can express this system as a matrix equation A * x = b with:
A = np.array([[1, 2, 1],
[0, 1, 1],
[1, 0, 1]])
b = np.array([4, 3, 5])
Then, use np.linalg....
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...
The current frame rate (in FPS, Frames Per Second) and total number of SKNodes in the scene (nodeCount, each sprite is an SKNode but other objects in the scene are also SKNodes) can be shown in the bottom right hand corner of the view.
These can be useful when turned on (set to true) for debugging ...
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...
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
...