Ruby one-liner to find external IP address across NAT router.
my_ip = (require 'open-uri' ; open("http://myip.dk") { |f| /([0-9]{1,3}\.){3}[0-9]{1,3}/.match(f.read)[0].to_a[0] })
11391 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
my_ip = (require 'open-uri' ; open("http://myip.dk") { |f| /([0-9]{1,3}\.){3}[0-9]{1,3}/.match(f.read)[0].to_a[0] })
#! /usr/bin/env bash # execute some bash scripting commands here sqlite3 mydatabase <<SQL_ENTRY_TAG_1 SELECT * FROM mytable WHERE somecondition='somevalue'; SQL_ENTRY_TAG_1 # execute other bash scripting commands here sqlite3 mydatabase <<SQL_ENTRY_TAG_2 SELECT * FROM myothertable WHERE someothercondition='someothervalue'; SQL_ENTRY_TAG_2
#! /usr/bin/env bash # execute some bash scripting commands here mysql mydatabase <<SQL_ENTRY_TAG_1 SELECT * FROM mytable WHERE somecondition='somevalue'; SQL_ENTRY_TAG_1 # execute other bash scripting commands here mysql mydatabase <<SQL_ENTRY_TAG_2 SELECT * FROM myothertable WHERE someothercondition='someothervalue'; SQL_ENTRY_TAG_2
mysql -e "SELECT * FROM mytable WHERE somecondition='somevalue'"
mysql -H -e "SELECT * FROM mytable WHERE somecondition='somevalue'"
mysql -H < myqueries.sql
# Function to force a command to try until it works. # Name means "JUST #@$% DO IT!" JFDI () { COMMAND=$* while ! $COMMAND ; do echo "Retrying..." ; done }
# command that can fail and annoy rsync -avz /my/local/directory/ myuser@host:~/my/remote/directory/ # command that won't give up ever JFDI rsync -avz /my/local/directory/ myuser@host:~/my/remote/directory/