$ time ./countlargenumber.pl
500000000500000000
real 0m43.157s
user 0m43.013s
sys 0m0.019s
Executable written in C counting from 1 to 1,000,000,000:
$ time ./countlargenumber.out
500000000500000000
real 0m2.057s
user 0m2.028s
sys 0m0.002s
$ time ./countlargenumber.pl
500000000500000000
real 0m43.157s
user 0m43.013s
sys 0m0.019s
$ time ./countlargenumber.out
500000000500000000
real 0m2.057s
user 0m2.028s
sys 0m0.002s
awk -F'|' '{print $2}' ./lines.txt
md5 -s "test string"
MD5 ("test string") = 6f8db599de986fab7a21625b7916589c
echo -n test string | md5
6f8db599de986fab7a21625b7916589c
echo test string | md5
f299060e0383392ebeac64b714eca7e3
cat ./lines.txt | sed s/\|/,/g
awk '{print $0"|"}' ./input.txt > ./output.txt
/bin/sh: -c: line 0: unexpected EOF while looking for matching `]'
/bin/sh: -c: line 1: syntax error: unexpected end of file
*/10 * * * * perl -le 'sleep rand 60' && head -$[${RANDOM} % `wc -l < /Users/username/lines.txt` + 1] /Users/username/lines.txt | tail -1 | ruby /Users/username/tweet.rb
The entire command portion of the line, up to a newline or % character, will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-signs (%) in the command, unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the command as standard input.
*/10 * * * * perl -le 'sleep rand 60' && head -$[${RANDOM} \% `wc -l < /Users/username/lines.txt` + 1] /Users/username/lines.txt | tail -1 | ruby /Users/username/tweet.rb
*/10 * * * * perl -le 'sleep rand 540' && head -$[${RANDOM} \% `wc -l < /Users/username/lines.txt` + 1] /Users/username/lines.txt | tail -1 | ruby /Users/username/lines.rb
require 'json'
require 'oauth'
consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
consumer = OAuth::Consumer.new(
consumer_key,
consumer_secret,
site:'https://api.twitter.com/'
)
endpoint = OAuth::AccessToken.new(consumer, access_token, access_token_secret)
# STATUS
status = STDIN.gets
# POST
response = endpoint.post('https://api.twitter.com/1.1/statuses/update.json', status: status )
result = JSON.parse(response.body)
echo $(ruby -e 'print rand') $(wc -l < "./lines.txt") | awk '{printf("%d\n", $1*$2)}'
Henry E. Baker |
Benjamin Banneker |
James Forten |
Ben Montgomery |
Norbert Rillieux |
Jan Ernst Matzeliger |
Elijah McCoy |
George Franklin Grant |
Lewis Howard Latimer |
Granville Woods |
Garrett Morgan |
George Washington Carver |
Madam C. J. Walker |
gem install oauth
require 'json'
require 'oauth'
consumer_key = '' # Your consumer key
consumer_secret = '' # Your consumer secret
access_token = '' # Your access token
access_token_secret = '' # Your access token secret
consumer = OAuth::Consumer.new(
consumer_key,
consumer_secret,
site:'https://api.twitter.com/'
)
endpoint = OAuth::AccessToken.new(consumer, access_token, access_token_secret)
# STATUS
status = ARGV[0]
# POST
response = endpoint.post('https://api.twitter.com/1.1/statuses/update.json', status: status )
result = JSON.parse(response.body)
ruby ./tweet.rb "Good morning! (おはようございます。)"
$ cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
$ cat /dev/urandom | env LC_CTYPE=C tr -dc '[:alnum:]' | fold -w 32 | head -n 1
$ cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z0-9' | fold -w 15 | head -n 1
$ $ cat /dev/urandom | env LC_CTYPE=C tr -cd '[:lower:][:digit:]' | fold -w 15 | head -n 1