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
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
/** | |
* 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
// 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
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
var Channels = require('./channels') | |
, Emitter = require('events').EventEmitter | |
var repeater = Channels.createRepeating(250, 'hello', 'world') | |
, emitter = new Emitter() | |
, emitterTestChannel = Channels.fromEmitter(emitter, 'test') | |
, mergedChannel = Channels.merge(repeater, emitterTestChannel) | |
, mappedChannel = Channels.map(function() { | |
return Array.prototype.join.call(arguments, ' ') | |
}, repeater) |
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 'https://rubygems.org' | |
gem 'activerecord', '~> 3.2' | |
gem 'activerecord-mysql2-adapter' | |
group :test do | |
gem 'rspec' | |
gem 'pry' | |
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
class Car | |
def initialize(model, engine = ::Engine.new) | |
@model = model | |
@engine = engine | |
end | |
def running | |
engine.running | |
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
function Foo(options) { | |
var privateInstanceVar = options.thing; | |
var publicInstanceVar = options.otherThing; | |
var publicInterface = { | |
publicFunction: publicFunction, | |
publicInstanceVar: publicInstanceVar | |
}; | |
return publicInterface; |
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
" copy all this into a vim buffer, save it, then... | |
" source the file by typing :so % | |
" Now the vim buffer acts like a specialized application for mastering vim | |
" There are two queues, Study and Known. Depending how confident you feel | |
" about the item you are currently learning, you can move it down several | |
" positions, all the way to the end of the Study queue, or to the Known | |
" queue. | |
" type ,, (that's comma comma) |