Skip to content

Instantly share code, notes, and snippets.

View fairchild's full-sized avatar

Michael Fairchild fairchild

  • Procore
  • California
View GitHub Profile
@poshaughnessy
poshaughnessy / app.js
Created January 31, 2012 09:28
Simple static site on Heroku with Node.js
var express = require('express');
var port = process.env.PORT || 3000;
var app = express.createServer();
app.get('/', function(request, response) {
response.sendfile(__dirname + '/index.html');
}).configure(function() {
app.use('/images', express.static(__dirname + '/images'));
}).listen(port);
@mourner
mourner / TileLayer.Common.js
Created February 11, 2012 23:11
Leaflet shortcuts for common tile providers
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core?
L.TileLayer.Common = L.TileLayer.extend({
initialize: function (options) {
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
(function () {
require 'fnordmetric'
require 'fnordmetric/logger'
# This is a quickie ruby script to set up some base data for the dashboard
income_billing_keys = [:weekly_billing_external, :weekly_income_quickbooks, :weekly_break_even]
bank_account_keys = [:bank_account_checking, :bank_account_money_market, :bank_account_bonus_employee, :bank_account_bonus_boardmembers, :quickbooks_receivables, :quickbooks_payables]
website_traffic_keys = [:visitors_daily]
jenkins_keys = [:jenkins_build_success_daily, :jenkins_build_failure_daily]
demo_data = {
@blomdell
blomdell / Readme.md
Created March 1, 2012 22:24
Opentransact demo

OpenTransact

Get started with AT&T's opentransact API, a sample app can be found at:

http://pure-sunset-8157.herokuapp.com/

In order to get started:


  1. Register your application with AT&T's Developer Portal
  2. Obtain a client_id and client_secret from AT&T's Developer Portal
  3. Set up settlement options with AT&T in order to enable payments
@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active March 23, 2025 21:22
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@ciscodesign
ciscodesign / Helper
Created March 18, 2012 22:51
Helper to use Font Awesome with Rails
def icon(name, size=1)
#icon("camera-retro")
#<i class="icon-camera-retro"></i>
html = "<i class='icon-#{name}' "
html += "style='font-size:#{size}em' "
html += "></i>"
html.html_safe
end
@cschneid
cschneid / hack.sh
Created April 1, 2012 03:43 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@njh
njh / mqtt-eventsource.rb
Created April 14, 2012 14:09
Subscribe to MQTT messages in browser using HTML5 Server-Sent Events
#!/usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
require 'em-mqtt'
require 'sinatra/base'
require 'thin'
class WebApp < Sinatra::Base
@davidwkeith
davidwkeith / index.html
Last active November 7, 2024 19:03
NOTE: This was a great hack in days gone by, but now both Apple and Google have improved their support for custom protocol handlers. Licensed under the WFTPL http://www.wtfpl.net/txt/copying/
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>App Redirection</title>
</head>
<body>
<!--
NOTE: This was a great hack in days gone by, but now both Apple and Google have improved their support for custom
protocol handlers.
@jboner
jboner / latency.txt
Last active April 16, 2025 10:37
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD