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
var assert = require('assert') | |
function _if(predicate) { | |
return { | |
then: function(thenFn) { | |
return { | |
else: function(elseFn) { | |
predicate.map(function(val) { | |
if (val) thenFn() | |
else elseFn() |
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
// result of `curl https://lydian.indabamusic.com/opportunities` | |
{ | |
"status": "success", | |
"message": null, | |
"data": [ | |
{ | |
"id": "1237fa00-c24c-11e2-94e4-12313b0b1241", | |
"slug": "device-you-think-you-know-remix-contest", | |
"name": "Device - \"You Think You Know\" Remix Contest", | |
"tempo": "179", |
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
/** | |
* Removes all unread threads matching the query | |
* older_than:<interval> label:purge-after-<interval> | |
*/ | |
var intervals = ["1d", "7d", "1m"]; | |
function purgeAll() { | |
intervals.forEach(function(interval) { | |
var query = constructQuery(interval); | |
var threads = GmailApp.search(query); | |
Logger.log("Found " + threads.length + " matching query: " + query); |
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
ENV['TZ'] = 'UTC' | |
if RUBY_PLATFORM =~ /java/ | |
org.joda.time.DateTimeZone.setDefault(org.joda.time.DateTimeZone::UTC) | |
java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone('UTC')) | |
end |
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
var data | |
function possiblyAsync(callback) { | |
if (alreadyLoaded) { | |
callback(data) | |
} else { | |
asyncLoad(function(loadedData) { | |
data = loadedData | |
callback(data) | |
}) | |
} |
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
var express = require('express') | |
, cors = require('connect-xcors')({ | |
headers: ['X-Requested-With', 'X-HTTP-Method-Override', 'Content-Type', 'Accept', 'Authorization'] | |
}) | |
var app = express() | |
// OPTIONS requests don't get handled because | |
// cors is hidden behind the routing middleware | |
// and '/' is only accessible via GET |
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
IOError: | |
closed stream | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/openssl/buffering.rb:174:in `sysread_nonblock' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/openssl/buffering.rb:174:in `read_nonblock' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/protocol.rb:132:in `readline' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2770:in `read_chunked' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2750:in `read_body_0' | |
/Users/pdswan/.rbenv/versions/1.9.3-p286/lib/ruby/1.9.1/net/http.rb:2710:in `read_body' |
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
source "http://rubygems.org" | |
gem 'thin' | |
gem 'cramp' | |
gem 'rack' |
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
require 'ostruct' | |
class VagrantSSHConfig < OpenStruct | |
def initialize | |
super parse_options(`vagrant ssh-config`) | |
end | |
private | |
def parse_options(option_string) |
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
require 'test/unit' | |
require 'mocha' | |
# assumes MailingListUpdater is defined / exposed at the top level. this is not the case | |
# for the code in this gist. | |
class MailingListUpdaterTest < Test::Unit::TestCase | |
test "#update_mailing_list calls enqueue_for_mailing_list_update when a user is present" do | |
user = mock('User', :enqueue_for_mailing_list_update => true) | |
record = stub('Record') |