This file contains 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
package main | |
import ( | |
"bytes" | |
"exec" | |
"log" | |
"os" | |
) | |
// Pipeline strings together the given exec.Cmd commands in a similar fashion |
This file contains 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 NoWww | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
request = Rack::Request.new(env) | |
if request.host.starts_with?("www.") | |
[301, {"Location" => request.url.sub(/www./, "")}, self] |
This file contains 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
heroku config --long | ruby -pe "\$_ = \$_.gsub(/(\w+)\s+=> (.+)/, 'export \1=\2')" > /tmp/$$ && source /tmp/$$; rm /tmp/$$ |
This file contains 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
function convertDateTimeSelectTo12Hour() { | |
var translate = {"00":"Midnight","01":"1am","02":"2am","03":"3am","04":"4am","05":"5am","06":"6am","07":"7am","08":"8am","09":"9am","10":"10am","11":"11am","12":"Noon","13":"1pm","14":"2pm","15":"3pm","16":"4pm","17":"5pm","18":"6pm","19":"7pm","20":"8pm","21":"9pm","22":"10pm","23":"11pm"}; | |
$("select[name$='(4i)]'] option").each(function() { | |
$(this).text(translate[$(this).text()]); | |
}); | |
} |
This file contains 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
#!/bin/sh -e | |
# Usage: license | |
# Prints an MIT license appropriate for totin' around. | |
# | |
# $ license > COPYING | |
#!/bin/sh | |
echo "Copyright (c) `date +%Y` Chris Wanstrath | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the |
This file contains 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
ZIP_FILE = "#{PROJECT}.zip" | |
desc "Zip of the folder for release" | |
task :zip => [:clean] do | |
require 'zip/zip' | |
require 'zip/zipfilesystem' | |
# check to see if the file exists already, and if it does, delete it. | |
if File.file?(ZIP_FILE) |
This file contains 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
/** | |
* Format any UTC timestamp on the page to the users local timezone. | |
*/ | |
var DateFormat = { | |
autoParse: function(){ | |
$$('span.timestamp').each(function(span) { | |
var utc = Date.parseUTC(span.getAttribute('utc')); | |
var rel = span.getAttribute('format'); | |
span.set('html', rel == 'words' ? utc.timeAgoInWords() : utc.strftime(rel)) | |
}); |
This file contains 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 FSM | |
def initialize | |
@states = {} | |
end | |
def state(name, &block) | |
s = State.new | |
s.instance_eval(&block) | |
@states[name] = s |
This file contains 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
module AttrLogger | |
def self.included(base) | |
base.extend(ClassLevelMethods) | |
end | |
module ClassLevelMethods | |
def attr_logger(*args) | |
args.each do |attribute| | |
define_method(attribute) do | |
value = instance_variable_get("@#{attribute}") |
This file contains 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 | |
require 'rubygems' | |
require 'logger' | |
require 'net/ssh' | |
require 'net/smtp' | |
require 'patron' | |
require 'timeout' | |
require 'parseconfig' | |
require 'yaml' |
NewerOlder