Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am markcaudill on github.
  • I am mcaudill (https://keybase.io/mcaudill) on keybase.
  • I have a public key whose fingerprint is 105C 4606 25A9 0BA4 7367 38DA B1CC CB0A 8630 0137

To claim this, I am signing this object:

#!/bin/bash
LAST=/tmp/last_public_ip
NOTIFY="you@domain.tld"
ip=$(curl -s https://mrkc.me/ip)
if [[ ! -e $LAST ]] || [[ "$ip" != "$(cat $LAST)" ]]; then
cat $LAST
echo -n "$ip" > $LAST
#!/bin/bash
# Analyze your schedulers. Don't use this. 2nasty4u
# Usage: $0 [sda sdb ...] | tee -a schedulers.csv
devs=$*
for dev in $devs; do
# Save the current scheduler
active_scheduler=`cat /sys/block/$dev/queue/scheduler | grep -Eo '\[[a-z]+\]' | sed 's/\[//g' | sed 's/\]//g'`
for scheduler in `cat /sys/block/$dev/queue/scheduler | sed 's/\[//g' | sed 's/\]//g'`; do
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
mysqldump -u root --password='YOURPASSSORD' \
--all-databases --add-drop-database \
> /tmp/databases.sql
#!/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"
mysql -u root -p
mysql> source /path/to/databases.sql
@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 username@remote.hostname.tld "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