$1, $2, $3, ...
It's an array-like construct of all positional parameters, {$1, $2, $3 ...}.
"$@"
It's the IFS expansion of all positional parameters, $1 $2 $3 ....
"$*"
It's the number of positional parameters.
$#
current options set for the shell.
$-
pid of the current shell (not subshell).
$$
most recent parameter (or the abs path of the command to start the current shell immediately after startup).
$_
It's the (input) field separator.
$IFS
It's the most recent foreground pipeline exit status.
$?
It's the PID of the most recent background command.
$!
It's the name of the shell or shell script.
$0
http://stackoverflow.com/questions/5163 ... -variables
[ view entry ] ( 1365 views ) | print article
EXAMPLE A) Declaring a function in sum.sh script:
#!/usr/bin/bash
sum()
{
echo $1 + $2 | bc
}
# call function and pass cli
# parameters to function
sum $1 $2
Calling script:
[aesteban@localhost ~]$ ./sum.sh 1.4 1.3
2.7
EXAMPLE B) A different way to write sum.sh script:
#!/usr/bin/bash
sum()
{
RESULT=$(echo $1+$2 | bc) # or: RESULT=`echo $1+$2 | bc`
}
sum $1 $2
echo $RESULT
Calling modified script:
[aesteban@localhost ~]$ ./sum.sh 1.7 1.2
2.9
EXAMPLE C) Another way to write the same crap:
#!/usr/bin/bash
sum()
{
echo $1+$2 | bc
}
SUMRESULT=`sum $1 $2`
echo $SUMRESULT
Calling it:
[aesteban@localhost ~]$ ./sum.sh 2.9 3
5.9
[ view entry ] ( 1428 views ) | print article
#local variables
[aesteban@localhost ~]$ Name=Angel
[aesteban@localhost ~]$ echo $Name
Angel
[aesteban@localhost ~]$ Name="Angel Cool"
[aesteban@localhost ~]$ echo $Name
Angel Cool
[aesteban@localhost ~]$ #readonly
[aesteban@localhost ~]$ readonly Name
[aesteban@localhost ~]$ Name="Angel Esteban"
bash: Name: readonly variable
[aesteban@localhost ~]$
#index arrays
[aesteban@localhost ~]$ Fruits[0]=apple
[aesteban@localhost ~]$ Fruits[1]=orange
[aesteban@localhost ~]$ Fruits[2]=banana
[aesteban@localhost ~]$ Fruits[3]=grapes
[aesteban@localhost ~]$
[aesteban@localhost ~]$ States=("California" "Texas" "Florida")
[aesteban@localhost ~]$ echo ${States[1]}
Texas
[aesteban@localhost ~]$ echo ${Fruits[2]}
banana
[aesteban@localhost ~]$ echo ${Fruits[*]}
apple orange banana grapes
[aesteban@localhost ~]$ echo ${#Fruits[*]}
4
[aesteban@localhost ~]$ unset Fruits
[aesteban@localhost ~]$ echo ${!States[*]}
0 1 2
[aesteban@localhost ~]$
#associative arrays
[aesteban@localhost ~]$ declare -A INFO
[aesteban@localhost ~]$
[aesteban@localhost ~]$ INFO["name"]="Angel Esteban Cool"
[aesteban@localhost ~]$ echo ${INFO["name"]}
Angel Esteban Cool
[aesteban@localhost ~]$
[aesteban@localhost ~]$ INFO=([name]="Angel Cool" [website]="angelcool.net")
[aesteban@localhost ~]$
[aesteban@localhost ~]$ echo ${INFO["website"]}
angelcool.net
[aesteban@localhost ~]$
Loops
[aesteban@localhost ~]$ for i in $(seq 1 5); do echo This line corresponds to line $i.;done;
This line corresponds to line 1.
This line corresponds to line 2.
This line corresponds to line 3.
This line corresponds to line 4.
This line corresponds to line 5.
[aesteban@localhost ~]$
[aesteban@localhost ~]$
[aesteban@localhost ~]$ for i in {1..7}; do echo This is number $i.;done;
This is number 1.
This is number 2.
This is number 3.
This is number 4.
This is number 5.
This is number 6.
This is number 7.
[aesteban@localhost ~]$
[aesteban@localhost var]$ for i in `ls /var`;do echo $i;done;
...
[aesteban@localhost ~]$# looping through a list of servers
[aesteban@localhost ~]$for i in {1..5}; do ssh www-app0${i} "cd /var/www/html/barney.com && git pull origin live" ;done;
[ view entry ] ( 1486 views ) | print article
Basic Commands:
[acool@localhost ~]$ redis-server --version
Redis server v=2.8.18 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=94164e7f0a3c47c9
[acool@localhost ~]$
[acool@localhost ~]$ sudo systemctl start redis
[acool@localhost ~]$ redis-cli
127.0.0.1:6379>
127.0.0.1:6379> INFO
127.0.0.1:6379>
127.0.0.1:6379> SET fullName "Angel Cool"
OK
127.0.0.1:6379> GET fullName
"Angel Cool"
127.0.0.1:6379> DEL fullName
(integer) 1
127.0.0.1:6379> GET fullName
(nil)
127.0.0.1:6379> INCR attempts
(integer) 1
127.0.0.1:6379> INCR attempts
(integer) 2
127.0.0.1:6379> GET attempts
"2"
127.0.0.1:6379> SETNX attempts 25 //set if not exist
(integer) 0
127.0.0.1:6379> GET attempts
"2"
127.0.0.1:6379> SET token abc123
OK
127.0.0.1:6379> EXPIRE token 60
(integer) 1
127.0.0.1:6379> TTL token
(integer) 51
127.0.0.1:6379> TTL token
(integer) 44
127.0.0.1:6379> SETEX token 120 321abc //set & expire but atomic ;)
OK
127.0.0.1:6379> TTL token
(integer) 116
127.0.0.1:6379> TTL token
(integer) 114
127.0.0.1:6379> keys * //get all keys in redis
1) "friends"
2) "attempts"
3) "TOKEN"
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> type friends // get key type, possible types: string, list, set, zset, hash.
list
127.0.0.1:6379> type attempts
string
Lists:
127.0.0.1:6379> RPUSH friends Daniel //push a new value at the end of a list
(integer) 1
127.0.0.1:6379> RPUSH friends William
(integer) 2
127.0.0.1:6379> RPUSH friends Alex
(integer) 3
127.0.0.1:6379> RPUSH friends Rene
(integer) 4
127.0.0.1:6379> LRANGE friends 0 -1 //get all entries in list
1) "Daniel"
2) "William"
3) "Alex"
4) "Rene"
127.0.0.1:6379> LPUSH friends Elizabeth //push a new value at the start of a list
(integer) 5
127.0.0.1:6379> LLEN friends //returns the current lenght of a list
(integer) 5
127.0.0.1:6379> LRANGE friends 2 3 //returns a subset of a list
1) "William"
2) "Alex"
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> LPOP friends //removes the first element from the list and returns it
"Elizabeth"
127.0.0.1:6379> RPOP friends //removes the last element from the list and returns it
"Rene"
127.0.0.1:6379>
Sets:
127.0.0.1:6379> SADD countries Canada
(integer) 1
127.0.0.1:6379> SADD countries Chile
(integer) 1
127.0.0.1:6379> SADD countries Brazil
(integer) 1
127.0.0.1:6379> SADD countries Mexico
(integer) 1
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> SMEMBERS countries //output all members of a set
1) "Canada"
2) "Mexico"
3) "Brazil"
4) "Chile"
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> SISMEMBER countries Mexico //test if a value is in a set
(integer) 1
127.0.0.1:6379> SREM countries Mexico //removes a value from a set
(integer) 1
127.0.0.1:6379> SISMEMBER countries Mexico
(integer) 0
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> SMEMBERS cities
1) "London"
2) "Los Angeles"
3) "Merida"
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> SUNION cities countries //combines sets and returns all members
1) "Merida"
2) "London"
3) "Canada"
4) "Brazil"
5) "Los Angeles"
6) "Chile"
Sorted Sets:
127.0.0.1:6379> ZADD hackers 1940 "Alan Kay"
(integer) 1
127.0.0.1:6379> ZADD hackers 1906 "Grace Hopper"
(integer) 1
127.0.0.1:6379> ZADD hackers 1953 "Richard Stallman"
(integer) 1
127.0.0.1:6379> ZADD hackers 1965 "Yukihiro Matsumoyo"
(integer) 1
127.0.0.1:6379> ZADD hackers 1983 "Angel Cool"
(integer) 1
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> ZRANGE hackers 2 3 WITHSCORES
1) "Richard Stallman"
2) "1953"
3) "Yukihiro Matsumoyo"
4) "1965"
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> ZADD hackers 1980 "Karla Cool"
(integer) 1
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> ZRANGE hackers 0 -1 WITHSCORES //all scores, see how it's sorted by score (date of birth)
1) "Grace Hopper"
2) "1906"
3) "Alan Kay"
4) "1940"
5) "Richard Stallman"
6) "1953"
7) "Yukihiro Matsumoyo"
8) "1965"
9) "Karla Cool"
10) "1980"
11) "Angel Cool"
12) "1983"
127.0.0.1:6379>
127.0.0.1:6379> ZREVRANGE hackers 0 -1 withscores // reverse score
1) "Angel Cool"
2) "1983"
3) "Yukihiro Matsumoyo"
4) "1965"
5) "Richard Stallman"
6) "1953"
7) "Alan Kay"
8) "1940"
9) "Grace Hopper"
10) "1906"
127.0.0.1:6379>
127.0.0.1:6379> ZCOUNT hackers -inf +inf // returns the number of items in zset
(integer) 5
127.0.0.1:6379>
127.0.0.1:6379> ZREMRANGEBYSCORE hackers 1940 1960
(integer) 2
Hashes
127.0.0.1:6379> HSET user:1000 firstName Angel
(integer) 1
127.0.0.1:6379> HSET user:1000 lastName Cool
(integer) 1
127.0.0.1:6379> HSET user:1000 website angelcool.net
(integer) 1
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> HGET user:1000 firstName
"Angel"
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> HMSET user:2000 firstName Richard lastName Stallman website stallman.org
OK
127.0.0.1:6379>
127.0.0.1:6379> HGET user:2000 website
"stallman.org"
127.0.0.1:6379>
127.0.0.1:6379> HGETALL user:2000
1) "firstName"
2) "Richard"
3) "lastName"
4) "Stallman"
5) "website"
6) "stallman.org"
127.0.0.1:6379>
127.0.0.1:6379>
[ view entry ] ( 1512 views ) | print article
Amazing trick. This is one of the first thing to try if your CSV spreadsheet is not rendering how you expect.
Original Question:
======================================================
I have a line like this in my CSV:
"Samsung U600 24"","10000003409","1","10000003427"
Quote next to 24 is used to express inches, while the quote just next to that quote closes the field. I'm reading the line with fgetcsv but the parser makes a mistake and reads the value as:
Samsung U600 24",10000003409"
I tried putting a backslash before the inches quote, but then I just get a backslash in the name:
Samsung U600 24\"
Is there a way to properly escape this in the CSV, so that the value would be Samsung U600 24" , or do I have to regex it in the processor?
======================================================
Answer:
======================================================
Use 2 quotes:
"Samsung U600 24"""
======================================================
http://stackoverflow.com/questions/1780 ... ote-in-csv
[ view entry ] ( 1586 views ) | print article
http://jsfiddle.net/m4msmtdk/9/
if it's not fun why do it ? -ben & jerry ice cream
<canvas id="myCanvasNotYours"></canvas>
<script>
var myCanvas = document.getElementById('myCanvasNotYours');
var ctx = myCanvas.getContext('2d');
var img = new Image;
img.onload = function(){
//alert(img.width);
myCanvas.width = img.width
myCanvas.height = img.height
ctx.drawImage(img,0,-20); // Or at whatever offset you like
};
img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAkIAAADICAYAAAAEE46XAAAgAElEQVR4Xu2dT4xcxbWHf3cHUiAxrDKDFMAgzEsQRLKHtwnmT8DsxsOKh97z2MoKexAmQkpshDBCtoNEwFZssiJ4nAi8YsY7IJh4yCaMLQFyCEbYBCTGWRHzJxLs6uncmTbt7r7d93bf232r6iup5bHn3rrnfKfa/etTp6oS0SAAAQhAAAIQgECkBJJI/cZtCEAAAhCAAAQgIIQQgwACEIAABCAAgWgJIISiDT2OQwACEIAABCCAEGIMQAACEIAABCAQLQGEULShx3EIQAACEIAABBBCjAEIQAACEIAABKIlgBCKNvQ4DgEIQAACEIAAQogxAAEIQAACEIBAtAQQQtGGHschAAEIQAACEEAIMQYgAAEIQAACEIiWAEIo2tDjOAQgAAEIQAACCCHGAAQgAAEIQAAC0RJACEUbehyHAAQgAAEIQAAhxBiAAAQgAAEIQCBaAgihaEOP4xCAAAQgAAEIIIQYAxCAAAQgAAEIREsAIRRt6HEcAhCAAAQgAAGEEGMAAhCAAAQgAIFoCSCEog09jkNg2ATc1ZJ+JOkWST+QZH+3V6M1//1dSV+0WHh85e8rv0sWhu0Bz4MABMIjgBAKL6Z4BIEaEEhFz/oV0WPC5/aKjPpEkgkjex2XEEcVcaZbCARLACEUbGhxLJuAsw9oa3k+nBtZiPekpDVDAeQLBJxleCYlbVzhan8fVbOY2euolJhAokEAAhDIJIAQYnAETiDNTNgHtIkey0w0T8UU9d2EUFP2QSaOLCMRaUvFz7SkzSts68jB4jMvaX/csapjaLAJAvUggBCqRxywolQCqfhpfEAPInzyWNX4oLVpmaN5bvD/GmfC0sSPZX98apYlOiQlsz4Zja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NEGmwy4xAAAAAElFTkSuQmCC';
</script>
[ view entry ] ( 1641 views ) | print article
Postfix: sender-dependent SASL authentication — relay to multiple SMTP hosts, or relay to the same host but authenticate as different users (e.g., two Gmail accounts)
I would like to send mail from two different Gmail accounts using Postfix.
As a concrete example, here's how to set up two Gmail accounts (only relevant sections of the config files are listed below):
/etc/postfix/main.cf:
# sender-dependent sasl authentication
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
# default relayhost setting
relayhost = [smtp.gmail.com]:587
# smtp authentication settings
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_use_tls = yes
smtp_tls_security_level = encrypt
/etc/postfix/sasl_passwd:
# per-sender authentication
account1[@]gmail.com account1[@]gmail.com:passwd1
account2[@]gmail.com account2[@]gmail.com:passwd2
# default relayhost
[smtp.gmail.com]:587 default_account[@]gmail.com:default_passwd
/etc/postfix/sender_relay:
account1[@]gmail.com [smtp.gmail.com]:587
account2[@]gmail.com [smtp.gmail.com]:587
Create maps:
postmap sasl_passwd sender_relay
Restart postfix and test:
To send an email from account1[@]gmail.com, use sendmail with the -f sender option (set the envelope sender address):
sendmail -f account1[@]gmail.com -t <<EOF
To: barney[@]example.net
Subject: Hey, I successfully configured Postfix with sender-dependent SASL authentication!
Content-type: text/html
<b>Isn't this awesome?</b>
EOF
as of 2/2015:
https://gist.github.com/zmwangx/2c56aa32be68daf48c2f
[ view entry ] ( 1636 views ) | print article
// install express globally
$npm install -g express-generator
// create a new project using handlebars for views
$express -hbs "node-chat"
// cd into "node-chat" and execute:
$npm install
// add suport for socket.io
$npm install socket.io --save
// output versions
[acool@localhost node-chat]$ node --version
v0.10.33
[acool@localhost node-chat]$ npm --version
1.3.6
[acool@localhost node-chat]$ express --version
4.11.1
// make sure daemon (dev only) is installed and run:
// (I think you can also do npm start or node bin/www)
[acool@localhost node-chat]$ nodemon bin/www
// finally go to browser and type http://localhost:3000
// ...socket.io sample to come.
[ view entry ] ( 1506 views ) | print article
You can experiment with Gearman quickly right from the command line:
Launch the agent, the Gearman daemon:
$ sudo /usr/sbin/gearmand --daemon
Run a worker with the command-line utility gearman. The worker needs a name and can run any command-line utility. For example, you can create a worker to list the contents of a directory. The -f argument names the function the worker is providing:
$ gearman -w -f ls -- ls -lh
The last piece of the puzzle is a producer, or a job that generates lookup requests. You can generate a request with gearman, too. Again, use the -f option to spell out which service you want help from:
$ gearman -f ls < /dev/null
drwxr-xr-x@ 43 supergiantrobot staff 1.4K Nov 15 15:07 gearman-0.6.0
-rw-r--r--@ 1 supergiantrobot staff 29K Oct 1 04:44 gearman-0.6.0.tgz
-rw-r--r--@ 1 supergiantrobot staff 5.8K Nov 15 15:32 gearman.html
drwxr-xr-x@ 32 supergiantrobot staff 1.1K Nov 15 14:04 gearmand-0.10
-rw-r--r--@ 1 supergiantrobot staff 5.3K Jan 1 1970 package.xml
drwxr-xr-x 47 supergiantrobot staff 1.6K Nov 15 14:45 pecl-gearman
source (as of 25-10-2014)
http://www.ibm.com/developerworks/opens ... p-gearman/
[ view entry ] ( 1681 views ) | print article
/*********************************************************
|
| Creates Ajax-like request
|
*********************************************************/
function sendRequest($params,$url)
{
$postdata = http_build_query($params);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => "Content-type: application/x-www-form-urlencoded \r\n".
"X-Requested-With: XMLHttpRequest \r\n",
'content' => $postdata
)
);
$context = stream_context_create($opts);
return json_decode(
file_get_contents($url.time(), false, $context)
);
}
$params=array(
'email' => 'me[at]example.com',
'choCountry' => 'Mexico',
'zip' => '91744',
);
$url= 'http://www.barney-example.com/subscribe';
$data = sendRequest($params,$url);
[ view entry ] ( 1663 views ) | print article
<<First <Back | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Next> Last>>