Skip to content

Instantly share code, notes, and snippets.

View jwood's full-sized avatar

John Wood jwood

View GitHub Profile
@jwood
jwood / application.html.erb
Last active March 15, 2021 16:03
Disable animations
<!-- app/views/layouts/application.html.erb -->
<!DOCTYPE html>
<html lang="en">
<head>
<!-- ... -->
<% if Rails.application.config.disable_animations %>
<%= stylesheet_link_tag('disable_animations') %>
<!-- Turn off animations in jQuery -->
<script>$.fx.off = true;</script>
after_filter -> { sleep(0.25) }
@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 / questions.rake
Created July 13, 2015 14:03
Example of rake task that migrates production data
namespace :question do
desc "Update Questions and Tasks to support newly added validations"
task :update_for_validations => :environment do
ActiveRecord::Base.transaction do
# Set question_type to "yesno" for following questions:
%w(need_long_term_rental need_short_term_rental find_eye_doctor cleaning need_home).each do |identifier|
q = Question.find_by_identifier(identifier)
q.update_attributes!(question_type: "yesno") if q.present?
end
@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
Installing cocaine 0.5.7
Installing crack 0.4.2
Installing chronic 0.10.2
Installing hitimes 1.2.2 with native extensions
Installing bourbon 4.2.3
@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 / 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
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 / 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