Skip to content

Instantly share code, notes, and snippets.

View jwood's full-sized avatar

John Wood jwood

View GitHub Profile
@jwood
jwood / backup.rb
Created July 12, 2010 18:35
A simple backup script that FTPs files to some safe place
#!/usr/bin/ruby
#
# Usage: ftp-backup.rb <directory> <filename>
# Example: ftp-backup.rb /home/jwood/backup/ my_important_file
require 'net/ftp'
NUM_BACKUPS = 7
directory_name = ARGV[0]
@jwood
jwood / fetch_pgbackups.rb
Created November 17, 2010 14:28
Create a pgbackup on Heroku for a given project, and then download it for local storage
#!/usr/bin/ruby
#
# This script assumes that you have either 0 or 1 pgbackups stored
# on Heroku, and that you already have the heroku gem installed
# and configured on your system.
#
PROJECT_DIRECTORY = "/home/jwood/dev/myproj"
BACKUP_FILE = "/home/jwood/backup/myproj.dump"
@jwood
jwood / tenacity_example.rb
Created December 24, 2010 15:12
An example using the Tenacity gem
class Car
include MongoMapper::Document
include Tenacity
t_has_many :wheels
t_has_one :dashboard
end
class Wheel < ActiveRecord::Base
include Tenacity
@jwood
jwood / campfire_audio_notification.user.js
Created March 25, 2011 02:10
Enable audio notifications via Campfire
// ==UserScript==
// @name Campfire Audio Notification
// @namespace http://johnpwood.net
// @description Play a sound when a message is received from a specific user or when it contains a specific word.
// @author John Wood
// @homepage http://johnpwood.net
// @include *.campfirenow.com/room*
// ==/UserScript==
try { if ( typeof(Campfire) != "undefined" ) {
@jwood
jwood / clear-log-files.sh
Created July 14, 2011 18:11
Script to clear out log files in development project directores
#!/bin/bash
dev_dir=/Users/jwood/dev
for d in `ls $dev_dir`; do
test -d $dev_dir/$d/log
if [ $? -eq 0 ]; then
for f in `ls $dev_dir/$d/log/*.log`; do
> $f
done
@jwood
jwood / proby
Created October 17, 2011 16:32
Proby command line wrapper script
#!/bin/bash
#
# This script surrounds the command passed in with start and finish notifications
# to the Proby task monitoring application.
#
#
# === SETUP
#
# * Make sure the proby script is executable.
#
@jwood
jwood / fade.sh
Created October 21, 2011 19:23
Slowly delete a file by truncating it by a small amount every half second until the file is eventually deleted
#!/bin/bash
#
# DESCRIPTION
# Slowly delete a file by truncating it by a small amount every half second
# until the file is eventually deleted. This should prevent the system from
# freaking out when attempting to delete a single, large file.
#
# USAGE
# fade.sh <file>
#
@jwood
jwood / proby.php
Created June 25, 2012 13:56
Sending Proby notifications using PHP
<?php
$PROBY_API_KEY = 'secret';
function do_post_request($url, $data, $headers) {
$postdata = http_build_query($data);
$header_string = "";
foreach ($headers as $key => $value) {
$header_string .= $key . ": " . $value . "\n";
@jwood
jwood / capssh_usage
Created April 19, 2013 15:47
capssh Usage
# SSH to one of the production servers
capssh -e production
# Shortcut for SSHing into one of the production servers
capssh production
# SSH to the production server that is in the db role
capssh -e production -r db
# If you only have one server defined, you can connect to it by simply running capssh
@jwood
jwood / bad_spec.rb
Last active August 29, 2015 14:17
Fix Flakey Feature Tests by Using Capybara's APIs Properly - 1
first("#foo").click
expect(first(".message").value).to eql("Loaded successfully")