Skip to content

Instantly share code, notes, and snippets.

daz /
Created Apr 26, 2010
My Ubuntu web server rsync backup scripts
for i in /var/lib/mysql/*/; do
dbname=`basename $i`
if [ $dbname != "mysql" ]; then
mysqldump -u$user -p$pass $dbname > $dir/db/$dbname.sql
daz / Mellow Black.terminal
Created May 6, 2010
Mellow Black OS X Terminal theme. Save this file as "Mellow Black.terminal" and open it, then set it to default if you like it. Screenshot
View Mellow Black.terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
View Rakefile
ssh_user = "" # for rsync deployment
remote_root = "~/path/to/remote/" # for rsync deployment
namespace :styles do
desc "Clear styles"
task :clear do
puts "*** Clearing styles ***"
system "rm -Rfv css/*"
desc "Generate styles"
daz / f1-results.rb
Created May 30, 2010
Formula 1 results scraper using Mechanize
View f1-results.rb
# Gets race and quali info from and returns an array table with Position, Driver, Team, Time/Retired, Laps
# Eg
# [
# ["1", "Jenson Button", "McLaren-Mercedes", "1:34:09.565", "58"],
# ["2", "Sebastian Vettel", "Red Bull Racing-Renault", "+2.1 secs", "58"],
# ["3", "Lewis Hamilton", "McLaren-Mercedes", "+4.0 secs", "58"],
# ...
require 'rubygems'
daz / skype_status.rb
Created Dec 16, 2010
Skype status checker for Ruby
View skype_status.rb
# Check Skype status. You need to enable 'Show my status on the web' in Skype prefs
# skype ='some.username')
# => true
require 'net/http'
require 'uri'
class SkypeStatus
daz / gist:818065
Last active Sep 24, 2015
Google Analytics Rails helper
View gist:818065
# <%= google_analytics 'UA-XXXXXX-XX' %>
# </body>
# application_helper.rb
module ApplicationHelper
def google_analytics(id)
content_tag :script, :type => 'text/javascript' do
"var _gaq = _gaq || [];
_gaq.push(['_setAccount', '#{id}']);
View gist:879260
status = "Text message you don't want from Telstra when you're overseas: YOU HAVE USED 60MB ON INTERNATIONAL ROAMING AT A COST OF UP TO $15.00 PER MB... Oooops :("
status.length.to_f / 1024 / 1024 * 15 * 100
=> 0.217437744140625
View 3.1.0.rc1.html
<form accept-charset="UTF-8" action="/suppliers/6/products/38" class="edit_product" data-remote="true" id="edit_product_38" method="post" name="edit_product_38">
<div style="margin:0;padding:0;display:inline">
<input name="utf8" type="hidden" value="&acirc;&oelig;&ldquo;"><input name="_method" type="hidden" value="put"><input name="authenticity_token" type="hidden" value="K5dKVuoTllzbCT5uJkWuHAoUsayE4Z5irFjXcuP2dME=">
<p><label for="product_name">Name</label> <input id="product_name" name="product[name]" size="30" type="text" value="Bacon Streaky Precooked"></p>
<p><label for="product_item_number">Item number</label> <input id="product_item_number" name="product[item_number]" size="30" type="text" value="40656"></p>
<p><label for="product_carton_quantity">Carton quantity</label> <input id="product_carton_quantity" name="product[carton_quantity]" size="30" type="text" value="4x1kg"></p>
<p><label for="product_uom">UOM</label> <input id="product_uom" name="product[uom]" si
daz / gist:1136395
Created Aug 10, 2011
Using Ruby to schedule jobs with UNIX `at` command
View gist:1136395
time = + 60
queue_command = <<-CMD
at -t #{time.strftime('%Y%m%d%H%M')} <<-AT
echo "ran at #{time}" > output.txt
system queue_command
daz / php-cgi.rb
Created Sep 24, 2011 — forked from ambethia/php-cgi.rb
Homebrew Formula for PHP 5.2.17 as php-cgi (for nginx, etc.)
View php-cgi.rb
# Homebrew Formula for PHP 5.2.17 as php-cgi (for nginx, etc.)
require 'formula'
class PhpCgi <Formula