This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# zsh alias: | |
# return commit hash if your current branch's HEAD revision is the deployed revision, i.e., its deployed! | |
# if deployed, hash is returned | |
# if not deployed, no value is returned | |
alias deployed="echo $(heroku releases | head -2 | tail -n 1 | cut -d' ' -f4) | grep $(git rev-parse HEAD | cut -c 1-8)" | |
# troubleshooting | |
# be sure that your local branch is set to the branch corresponding to the remote Heroku deployment | |
# be sure that your heroku remote is pointed at the correct app, e.g. heroku git:remote -a <appname> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'deepsort' | |
require 'json' | |
# you've got a nested array of hashes of arrays of hashes ... of arrays of hashes | |
# and you want to sort hash entries by a specific attribute, like a label used for display. | |
json = '' # TODO: Add example | |
data = JSON.parse(json) | |
sorted_data = data.deep_sort_by{|obj| obj['label'] if (obj.is_a?(Hash) && obj.key?('label')) } | |
sorted_data.to_json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_configs(identifier, cfg_xml) | |
device = Device.find_by_identifier_nwa(identifier) | |
@hostname = device.ip_address | |
@port = 18466 | |
@timeout = 60 | |
@username = params[:username] | |
@password = params[:password] | |
@remote_path = '/ugmo/augusta/config/rc' | |
@configs = %w{clock-config sensor-config zone-config} | |
@tempdir = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** RYB code excerpt ***/ | |
abstract class Dot { | |
int c, t, x, y, w, h, d, r; | |
boolean v; | |
Dot(color c, int t, int x, int y, int w, int h, boolean v) { | |
this.c = c; | |
this.t = t; | |
this.x = x; | |
this.y = y; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# unvox.sh | |
# find iphone voicemails and save them locally | |
# | |
# Sean O'Donnell | |
# Mon Dec 23 14:36:42 EST 2013 | |
# | |
# requires ffmpeg, see http://www.ffmpeg.org/ | |
BASE_DIR=$(dirname $(dirname $0)) | |
INPUT_DIR="${HOME}/Library/Application Support/MobileSync/Backup" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Portfolio - Create PDF reports of user progress | |
Author: Sean O'Donnell <sodonnell@acponline.org> | |
Revised: April 7, 2010 | |
*/ | |
//TODO: Put CSS selectors in PortfolioOptions | |
var PortfolioOptions = { | |
debug_mode: false, | |
create_document_url: '/residents/portfolio', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class S3UrlController < AuthenticatedController | |
# Retreive a list of S3 objects | |
# For a given object, get a temporary, secret URL | |
skip_filter(*_process_action_callbacks.map(&:filter)) # Turn off any before filter that... | |
before_filter :basic_authenticate # ... is not your HTTP Basic authentication | |
rescue_from Exception do |error| | |
logger.error(error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Stamp class | |
# Utility class to convert datetime column values from | |
# one timezone to another (e.g., local to UTC). | |
class Stamp | |
attr_accessor :query, :status | |
attr_reader :records, :duplicates | |
def initialize(columns, old_time_zone, new_time_zone, time_format = "%F %T") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run `rake spec`, `rake spec:models`, `rake spec:controllers`, etc | |
# without running prerequisite, database tasks. Helpful for working | |
# with non-migration-aware, legacy databases. | |
if defined?(RSpec) | |
tasks = %w{ spec models controllers helpers lib mailers | |
rcov requests routing views } | |
skip_db_task = Proc.new do |task| | |
path = task.eql?('spec') ? 'spec/**' : "spec/#{task}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
def method_missing(method, *args, &block) | |
key = method.to_s | |
key =~ /(.+)=$/ ? store($1, args[0]) : fetch(key) | |
end | |
end | |
h = Hash.new | |
h.foo = 'bar' | |
p h.foo |
NewerOlder