Skip to content

Instantly share code, notes, and snippets.

@daz
daz / gist:10010044378bf49224d5
Created May 23, 2014 06:35
grep and awk to get the local network IP from ifconfig
ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}'
@daz
daz / check-url-for-changes.sh
Created September 12, 2014 07:57
Check URL for changes in a loop
#!/bin/bash
URL="http://store.apple.com/au/buy-iphone/iphone6/5.5-inch-display-64gb-space-grey-unlocked?proceed=proceed&step=select&product=MGAH2X%2FA&cppart=UNLOCKED%2FWW&step=select"
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

class CreatePlaces < ActiveRecord::Migration
# Rails migration for GeoWorldMap db into postgresql db
# (inspired by http://blog.inspired.no/populate-your-database-with-free-world-cities-countries-regions-in-2-minutes-using-a-rails-migration-273/ post)
# extract files from GeoWorldMap.zip archive from here
# http://www.geobytes.com/GeoWorldMap.zip
#
# and place them into #{Rails.root}/db/migrate/
# the archive has 'cities.txt' file, rename it 'Cities.txt'
#
@daz
daz / gist:a30780946cbaf32ea59a
Created April 4, 2015 07:43
Capistrano task to export and import Wordpress database
# 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 = Time.now.utc.strftime('%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
daz / Mellow Black.terminal
Created May 6, 2010 06:36
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 http://imgur.com/alhUa.png
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGFRZYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKMHCA9VJG51bGzTCQoLDA0OViRjbGFzc1xOU0NvbG9yU3BhY2VVTlNSR0KAAhAB
TxARMCAwIDAgMC44OTk5OTk5OADSEBESE1okY2xhc3NuYW1lWCRjbGFzc2VzV05TQ29s
b3KiEhRYTlNPYmplY3RfEA9OU0tleWVkQXJjaGl2ZXLRFxhUcm9vdIABCBEaIy0yNztB
@daz
daz / Rakefile
Created May 6, 2010 06:43 — forked from adamstac/Rakefile
ssh_user = "user@domain.com" # 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/*"
end
desc "Generate styles"
@daz
daz / skype_status.rb
Created December 16, 2010 05:32
Skype status checker for Ruby
# Check Skype status. You need to enable 'Show my status on the web' in Skype prefs
#
# skype = SkypeStatus.new('some.username')
# skype.online?
# => true
require 'net/http'
require 'uri'
class SkypeStatus
@daz
daz / gist:818065
Last active September 24, 2015 22:18
Google Analytics Rails helper
# <%= 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}']);
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