Code Language: bash

Curl a page with Canada IP.

Language: Bash

curl --header "X-Forwarded-For:  24.235.32.1" http://www.cambio.com > index.html
Reveal More
Added 7 months ago by 2699425249_32de9cf0fc_o_normal codemariner

What's my pulic IP address?

Language: Bash

curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

curl -s http://whatismyip.org/
Reveal More
Added 8 months ago by 2699425249_32de9cf0fc_o_normal codemariner

Duplicate MySQL DB directly to another

Language: Bash

mysqldump --opt --compress --user=USERHERE --password=PWHERE --host=SOURCE.HOST.HERE SOURCE_DB_NAME | 
mysql --user=USERHERE --password=PWHERE --host=TARGET.HOST.HERE -D TARGET_DB_NAME -C TARGET_DB_NAME
Reveal More
Added almost 2 years ago by Atclub_256_normal scottymac

upstart script for couchdb-lucene that creates a pidfile for monit, god, etc

Language: Bash

# /etc/init/couchdb-lucene.conf

description "CouchDB-Lucene server"
script
  cd /PATH/TO/couchdb_lucene
  exec sudo -u couchdb ./bin/run
end script
post-start script
  # hack to create a pid file
  CDB_PID=`status couchdb-lucene |egrep -oi '([0-9]+)$' |head -n1` 
  echo $CDB_PID >/var/run/couchdb-lucene.pid
end script

# monit

check process couchdb_lucene with pidfile /var/run/couchdb-lucene.pid
group database
start program = start couchdb-lucene
stop  program = stop couchdb-lucene
if failed host 127.0.0.1 port 5985 then restart
if cpu is greater than 40% for 2 cycles then alert
if cpu > 60% for 5 cycles then restart
if 10 restarts within 10 cycles then timeout
depends on couchdb
Reveal More
Added almost 2 years ago by Costco_normal trevorturk

Deploying node.js applications

Language: Bash

# Origin: http://howtonode.org/deploying-node-upstart-monit
#

# 1.) in /etc/event.d/yourprogram (old) or /etc/init/yourprogram.conf (new)

description "node.js server"
author      "joe"

start on startup
stop on shutdown

script
  export HOME="/root"
  exec sudo -u username /usr/local/bin/node /where/yourprogram.js 2>&1 >> /var/log/node.log
end script

# 2.) /etc/monitrc

set logfile /var/log/monit.log

check host nodejs with address 127.0.0.1
  start program = "/sbin/start yourprogram"
  stop program  = "/sbin/stop yourprogram"
  if failed port 8000 protocol HTTP
      request /
      with timeout 10 seconds
      then restart
Reveal More
Added almost 2 years ago by Twitterprofilephoto_normal zh

Skip building of the not needed erlang OTP parts

Language: Bash

wget http://erlang.org/download/otp_src_R13B03.tar.gz
tar -xzf otp_src_R13B03.tar.gz
cd otp_src_R13B03

X="webtool tv toolbar test_server snmp pman percept otp_mibs orber \
      odbc observer megaco jinterface inviso ic gs et cos* common_test asn1"
for a in `cd lib ; echo $X` ;do touch lib/$a/SKIP ; done

./configure && make && sudo make install
Reveal More
Added almost 2 years ago by Twitterprofilephoto_normal zh

Apache self-signed certificates

Language: Bash

# generate
openssl genrsa -out mydomain.key 1024
openssl req -new -key mydomain.key -x509 -out mydomain.crt -days 3650

# check
openssl s_client -state -quiet -connect mail.mydomain.com:443
Reveal More
Added almost 2 years ago by Twitterprofilephoto_normal zh

Easy way to setup a private remote GIT repository

Language: Bash

# http://www.rubynaut.net/articles/2008/03/04/git-easy-way-to-setup-a-private-remote-repository#comments

cd my_app
git init
git add .
git commit -m 'initial import'
scp -rp ./.git me@remote.com://data/git/my_app.git
git remote add remote_repo ssh://me@remote.com/data/git/my_app.git
git push remote_repo
cd .. && rm -rf my_app
git clone ssh://me@remote.com/data/git/my_app.git
cd my_app
Reveal More
Added almost 2 years ago by Twitterprofilephoto_normal zh

Install gitosis on ubuntu/debian

Language: Bash

sudo apt-get install build-essential fakeroot debhelper python-support
git clone git://eagain.net/gitosis.git
cd gitosis.git
./debian/rules generate
dpkg-checkbuilddeps
dpkg-buildpackage -us -uc -rfakeroot
sudo dpkg -i gitosis_0.2_all.deb
Reveal More
Added almost 2 years ago by Twitterprofilephoto_normal zh

Heroku Backup

Language: Bash

alias herokubackup='cd ~/code/backups &&
heroku db:pull sqlite://my_app.db --app my_app &&
heroku db:pull sqlite://my_other_app.db --app my_other_app &&
DATE=`date +%Y-%m-%d` &&
mkdir $DATE &&
mv *.db $DATE'
Reveal More
Added over 2 years ago by Costco_normal trevorturk