Skip to content

Instantly share code, notes, and snippets.

daz / gist:10010044378bf49224d5
Created May 23, 2014
grep and awk to get the local network IP from ifconfig
View gist:10010044378bf49224d5
ifconfig | grep 'inet ' | grep -v '' | awk '{print $2}'
daz /
Created Sep 12, 2014
Check URL for changes in a loop
while true
do sleep 20
HASH=$(curl -s "$URL" | shasum)
echo -n "."
if [ "$HASH" != "$OLD_HASH" ] && [ "$OLD_HASH" != "" ]; then
echo "UPDATED - $(date)"

Deploy your own PaaS!

Setting up Dokku with DigitalOcean and Namecheap

..or how I made my own heroku in a few hours for $3.98.

This write-up owes a great deal to dscape's Node.js Deployments with Docker, Dokku, & Digital Ocean, the dokku project itself, and the fine folks working on dokku's issues. I took dscape's article as a starting point when trying this out but found some details lacking so I documented my own process for getting dokku up and running.

1. Get a domain

View geo_world_map_migration.rb
class CreatePlaces < ActiveRecord::Migration
# Rails migration for GeoWorldMap db into postgresql db
# (inspired by post)
# extract files from archive from here
# and place them into #{Rails.root}/db/migrate/
# the archive has 'cities.txt' file, rename it 'Cities.txt'
daz / gist:a30780946cbaf32ea59a
Created Apr 4, 2015
Capistrano task to export and import Wordpress database
View gist:a30780946cbaf32ea59a
# Requires WP-CLI on the client and server
namespace :db do
desc 'Backup Wordpress database to shared/backup/timestamp.sql.gz and create a latest.sql.gz symlink'
task :backup do
stamp ='%Y%m%d%H%M%S')
filename = "#{fetch(:application)}_#{stamp}.sql.gz"
backup_path = "#{shared_path}/backup/#{filename}"
on roles(:app) do
execute "mkdir -p #{shared_path}/backup"
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}']);