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 Enumerable | |
class MapEnumerator | |
instance_methods.each {|m| undef_method m unless m =~ /__/} | |
def initialize(enum) | |
@enum = enum | |
end | |
def method_missing(name, *args) | |
@enum.map {|e| e.send name, *args} |
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 Compose = require("compose") | |
var livingThing = Compose({ | |
alive: false, | |
isDead: function() { | |
return !this.alive | |
}, | |
isAlive: function() { | |
return this.alive | |
}, |
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
Generate ctags with `rake ctags` | |
Run snipper.rb | |
Move motion.snippets into ~/.vim/UltiSnips/ruby/ |
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
def triangle(*sides) | |
raise TriangleError if [ | |
sides.count != 3, | |
sides.any? {|side| side < 1}, | |
sides.max >= sides.reduce(:+) - sides.max | |
].any? | |
case sides.uniq.count | |
when 1 then :equilateral | |
when 2 then :isosceles | |
else :scalene |
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 | |
root=`git rev-parse --show-toplevel` | |
echo "Moving to root: $root" | |
cd $root | |
echo "Rebasing current directory" | |
git svn rebase | |
echo "Looking for externals" |
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
// ==================================== | |
// Example: Nesting callbacks to produce serial requests | |
server.on('request', function(req, res) { | |
//get session information from memcached | |
memcached.getSession(req, function(session) { | |
//get information from db | |
db.get(session.user, function(userData) { | |
//some other web service call | |
ws.get(req, function(wsData) { |
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
Browser.prototype.isGradeA = function() { | |
var browser = this | |
browser.on("response", function(res, target) { | |
var window = browser.window | |
var document = browser.document | |
var onMobileInitMakeGradeA = function() { | |
if (window.$) { | |
window.$(document).on("mobileinit", function() { | |
window.$.mobile.gradeA = function() { return true } | |
}) |
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
describe "wait after pressButton", -> | |
before (done)-> | |
brains.get "/two-timers-only-the-first-useful", (req,res)-> | |
res.send """ | |
<html> | |
<body> | |
<button id="pressMe">press me</button> | |
<script> | |
var button = document.getElementById("pressMe") | |
button.addEventListener("click", function(ev) { |
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 bash | |
if [ "$1" == "" ]; then | |
echo "Usage: deploy <command>" | |
echo "Execute <command> in the mirror of the dir you are in under /var/www" | |
echo "e.g. deploy php scripts/BusinessKnowledgeImport.php --force --only-external-rules" | |
exit 1 | |
fi | |
deploy_dir="/var/www" |
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 expect = require("chai").expect | |
var gameOrig = "../game" | |
var gameGood = "../game.good" | |
var capturingConsole = function(action) { | |
var log = console.log | |
var logs = [] | |
global.console.log = function(msg) { | |
logs.push(msg) |
OlderNewer