Skip to content

Instantly share code, notes, and snippets.

View assaf's full-sized avatar

Assaf Arkin assaf

View GitHub Profile
@assaf
assaf / gist:9674758
Last active August 29, 2015 13:57
Mix use
// Liberally adapted from our test suites, which uses generators for complex steps (before/after/etc).
describe("With new customer", function() {
let business;
let customer1, customer2, customer3;
before(function*() {
// We have many tests, but you can only call listen() once
// on an HTTP server, so this is a case for resolve-once, and
// we use a promise.
yield Server.listen();
@assaf
assaf / gist:6bc56255459aa75f27b3
Created July 9, 2014 00:43
.git/hook/pre-commit
#!/bin/sh
#
# Run npm shrinkwrap on every commit, make sure we have the most recent
# dependencies checked into git.
DEPTH=10 # Set this to N to include more descendants in shrinkwrap
PATH=/usr/local/bin:$PATH
# Success or error, npm shrinkwrap will output to both stdout and stderr.
# We're only interested in what stderr has to say when it fails.

Keybase proof

I hereby claim:

  • I am assaf on github.
  • I am assaf (https://keybase.io/assaf) on keybase.
  • I have a public key whose fingerprint is E318 FD85 22D4 CBAE 142D F811 43A7 A5CA 24D1 FDF5

To claim this, I am signing this object:

var Immutable = require("immutable"),
t = require("transducers-js"),
comp = t.comp,
map = t.map,
filter = t.filter,
transduce = t.transduce;
var inc = function(n) { return n + 1; };
var isEven = function(n) { return n % 2 == 0; };
var sum = function(a,b) { return a+b; };
const Util = require('util');
const a = [];
console.log([].concat(a).length); // => 0
console.log([].slice.call(a).length); // => 0
const Arrayish = function() {
Array.call(this);
}
Util.inherits(Arrayish, Array);
@assaf
assaf / hostnames.txt
Created August 12, 2015 00:30
Time challenge
labnotes.org
example.com
mathforum.org
slack.com
github.com
facebook.com
twitter.com
@assaf
assaf / gist:205689
Created October 9, 2009 03:55
MySQL/EBS volume hourly snapshot
We couldn’t find that file to show.
# Rails 2.3 metal file to incorporate Resque Web UI inside Rails application.
# Uses HTTP Basic Authentication, until I can figure out how to get Authlogic
# working here. Accepts only users listed in ADMINS.
require "resque/server"
# since Authlogic is not keeping up, see http://github.com/binarylogic/authlogic/issuesearch?state=open&q=sinatra#issue/80
class Sinatra::Request
def self.before
end
end
# Allows something like:
# map.admin "/:action/:id", controller: :admin, conditions: { host: "admin.example.com" }
module ActionController
module Routing
class RouteSet
def extract_request_environment(request)
{ method: request.method, host: request.host }
end
end
class ActionMailer::Base
# Using this on staging server: never send emails to actual people.
# (Ocassionaly pulling live data into staging server)
def perform_delivery_safemail(mail)
addr = mail.to_addrs.first
mail.to = %{"#{addr.name || addr.address}" <test@... your email ...>}
perform_delivery_sendmail mail
end
end