echo $(ruby -e 'print rand') $(wc -l < "./lines.txt") | awk '{printf("%d\n", $1*$2)}'
Friday, January 29, 2016
Getting Random Line Number -1
Bash line to generate random line number from 1 to max - 1.
African American Inventors
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 |
ラベル:
African Americans,
Invention,
People,
アフリカ系アメリカ人,
発明
Thursday, January 28, 2016
Ruby: Tweeting Using OAuth gem
Package needed:
Ruby script: tweet.rb
Execute the ruby script:
gem install oauth
Ruby script: tweet.rb
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)
Execute the ruby script:
ruby ./tweet.rb "Good morning! (おはようございます。)"
Generating Random Password
Generating 32-character random password
This is the same:
$ cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
This is the same:
$ cat /dev/urandom | env LC_CTYPE=C tr -dc '[:alnum:]' | fold -w 32 | head -n 1
Generating Random 15-Character User Name
Generating random 15-character:
$ cat /dev/urandom | env LC_CTYPE=C tr -dc 'a-z0-9' | fold -w 15 | head -n 1
This is the same:
$ $ cat /dev/urandom | env LC_CTYPE=C tr -cd '[:lower:][:digit:]' | fold -w 15 | head -n 1
Subscribe to:
Posts (Atom)