Wrapper script is a script that wraps another script or command to provide extra functionalities or just to make something less tedious.
For example, the actual egrep in new GNU/Linux system is being replaced by a wrapper script named egrep. This is how it looks:
#!/bin/sh
exec grep -E "$@&q...
You can have functions in the PS1 variable, just make sure to single quote it or use escape for special chars:
gitPS1(){
gitps1=$(git branch 2>/dev/null | grep '*')
gitps1="${gitps1:+ (${gitps1/#\* /})}"
echo "$gitps1"
}
PS1='\u@\h:\w$(gitPS1)$ '
It will...
timeNow(){
echo "$(date +%r)"
}
PS1='[$(timeNow)] \u@\h:\w$ '
It will give you a prompt like this:
[05:34:37 PM] user@Host:/path$
Notes:
Make the changes in ~/.bashrc or /etc/bashrc or ~/.bash_profile or ~./profile file (depending on the OS) and save it.
Run source ~/.ba...
This is how the author sets their personal PS1 variable:
gitPS1(){
gitps1=$(git branch 2>/dev/null | grep '*')
gitps1="${gitps1:+ (${gitps1/#\* /})}"
echo "$gitps1"
}
#Please use the below function if you are a mac user
gitPS1ForMac(){
git branch 2> ...
class ImageCreationExample {
static Image createSampleImage() {
// instantiate a new BufferedImage (subclass of Image) instance
BufferedImage img = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB);
//draw something on the image
paintOnI...
We can just do simple replacement of separators from space to new line, as following example.
echo $sentence | tr " " "\n"
It'll split the value of the variable sentence and show it line by line respectively.
Create a simple DataFrame.
import numpy as np
import pandas as pd
# Set the seed so that the numbers can be reproduced.
np.random.seed(0)
df = pd.DataFrame(np.random.randn(5, 3), columns=list('ABC'))
# Another way to set column names is "columns=['column_1_name','column_2_name','c...
To transfer a file securely to another machine - type:
scp file1.txt tom@server2:$HOME
This example presents transferring file1.txt from our host to server2's user tom's home directory.
scp can also be used to transfer multiple files from one server to another. Below is example of transferring all files from my_folder directory with extension .txt to server2. In Below example all files will be transferred to user tom home directory.
scp /my_folder/*.txt tom@server2:$HOME
There is a mantra that some Java experts are wont to recite:
"Exceptions should only be used for exceptional cases."
(For example: http://programmers.stackexchange.com/questions/184654 )
The essence of this is that is it is a bad idea (in Java) to use exceptions and exception handli...
Use same UIImage with multiple theme base app by just applying UIColor to UIImage instance as following.
// *** Create an UIImage instance with RenderingMode AlwaysTemplate ***
UIImage *imgMenu = [[UIImage imageNamed:@"iconMenu"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]...
A for loop iterates from the starting value down to the ending value inclusive, as a "count-down" example.
program CountDown;
{$APPTYPE CONSOLE}
var
i : Integer;
begin
for i := 10 downto 0 do
WriteLn(i);
end.
Output:
10
9
8
7
6
5
4
3
2
1
0
Internal Table Declaration Based on Local Type Definition
" Declaration of type
TYPES: BEGIN OF ty_flightb,
id TYPE fl_id,
dat TYPE fl_date,
seatno TYPE fl_seatno,
firstname TYPE fl_fname,
lastname TYPE fl_lname,
fl...