Skip to content

Instantly share code, notes, and snippets.

mysqldump -u root --password='YOURPASSSORD' \
--all-databases --add-drop-database \
> /tmp/databases.sql
mysql -u root -p
mysql> source /path/to/databases.sql
s3cmd mb s3://yournewbucket #Create a new bucket
s3cmd ls s3://yournewbucket/ #List the contents of the bucket
s3cmd put databases.sql s3://yournewbucket/ #Upload the SQL file
#!/bin/env bash
TMPFILE=/tmp/`hostname`.databases.`date '+%Y-%m-%d'`.sql
TMPGZFILE=$TMPFILE.gz
mysqldump -u root --password='PASSWORD' \
--all-databases --add-drop-database \
> $TMPFILE
gzip $TMPFILE #This will make a file with the $TMPGZFILE filename.
s3cmd put $TMPGZFILE s3://YOURBUCKET/
rm -f $TMPFILE $TMPGZFILE
@markcaudill
markcaudill / stardate_bash_prompt.sh
Created April 27, 2011 17:44
Some code that can be used to have your timestamp in your Bash prompt be a stardate.
function stardate()
{
# There's apparently no cannon way to calculate the startdate
# but here goes.
# Add up all the minutes so far in the day, divide by minutes in 24 hours and format it nicely.
DECIMAL=$(echo $(( $(date -u '+%H') * 60 + $(date -u '+%M') )) | awk '{printf("%.2f", $1/1440)}' | sed 's/^0*//')
# Get the number of days since epoch.
DATE=$(( $(date -u '+%s') / 60 / 60 / 24 ))
echo "$DATE$DECIMAL"
@markcaudill
markcaudill / ntp_ssh.cron
Created April 27, 2011 17:49
A dirty way to update your system time via SSH.
# Sync the time ninja style
0 0 * * * /bin/date `ssh -i /home/username/.ssh/id_rsa -p 443 [email protected] "date '+%m%d%H%M%Y.%S'"`
@markcaudill
markcaudill / gist:969249
Created May 12, 2011 19:25
Install Skype on Fedora 10-14 x86_64
su -c wget http://www.skype.com/go/getskype-linux-beta-fc10
su -c yum install libXScrnSaver.i?86 libX11.i?86 \
libv4l.i?86 alsa-plugins-pulseaudio.i?86 \
qt-x11.i?86
su -c yum localinstall skype-*.rpm --nogpgcheck
sudo rpm --import http://commondatastorage.googleapis.com/xenodecdn/RPM-GPG-KEY-rpmfusion-free-fedora-15
sudo rpm --import http://commondatastorage.googleapis.com/xenodecdn/RPM-GPG-KEY-rpmfusion-nonfree-fedora-15
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm'
sqlite3 database.db "SELECT * FROM table_name;" | sed 's/|/,/g'
for i in `seq 0 32`; do echo $i Processes; START=`date +%s.%N`; seq 2 10000 | xargs -n1 -P$i python is_prime.py >/dev/null; END=`date +%s.%N`; echo $(echo "scale=9; $END - $START" | bc) seconds; echo; done