Skip to content

Instantly share code, notes, and snippets.

@tpitale
tpitale / gist:2037000
Created March 14, 2012 14:51
Handy little script to run a glob directory of test/unit tests
#!/usr/bin/env ruby
$: << 'test' << 'lib'
Dir.glob(ARGV).each {|f| load f unless f =~ /^-/}
# Usage: ruby_test test/unit/**/*.rb
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@statico
statico / gist:3172711
Created July 24, 2012 21:15
How to use a PS3 controller on Mac OS X 10.7 (Lion)

How to use a PS3 controller on Mac OS X 10.7 (Lion)

  1. Open Apple menu -> System Preferences -> Bluetooth and disable Bluetooth on Mac as well as any other nearby Macs or devices which will try to pair with and confuse the controller.

  2. Reset PS3 controller by inserting paperclip into pinhole near L2 button.

  3. Connect PS3 controller to Mac with USB cable.

  4. Enable Bluetooth.

@brandonb927
brandonb927 / osx-for-hackers.sh
Last active March 27, 2024 06:33
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@tpitale
tpitale / reel_ws_pg_example.rb
Last active March 23, 2017 13:03
Reel Websocket Server using PG Listen/Notify for crude pubsub
require 'rubygems'
require 'bundler/setup'
require 'reel'
require 'celluloid/io'
require 'pg'
module PGNotifications
def self.included(actor)
actor.send(:include, Celluloid::IO)
end
dm-migrations
dm-do-adapter
dm-yaml-adapter
dm-mysql-adapter
dm-postgres-adapter
dm-sqlite-adapter
dm-sqlserver-adapter
dm-oracle-adapter
dm-rest-adapter
dm-ferret-adapter
@tpitale
tpitale / demo.rb
Created July 15, 2013 15:43
Test/demo script for Legato Issue #34
#!/usr/bin/env ruby -Ilib
require 'pp'
require 'oauth2'
require 'legato'
module OAuth2Helpers
def build_client(id, secret)
opts = {
:authorize_url => 'https://accounts.google.com/o/oauth2/auth',
@tpitale
tpitale / ruby-example-upstart.conf
Created January 3, 2014 04:09
Basic start/stop upstart init conf for a ruby script. May require modification to run in /bin/bash or if you need to source rbenv or chruby.
# /etc/init/ruby-example-upstart.conf
description "Ruby example upstart conf"
# change to the user you want to run this ruby script as
setuid deploy
setgid deploy
# This starts upon bootup and stops on shutdown
# check runlevel of running system with `runlevel` command
@tpitale
tpitale / group_and_count_to_date.sql
Last active August 29, 2015 13:56
Group count by creation date and sum of count-to-date.
SELECT created_on, note_count, sum(note_count) OVER (ORDER BY created_on ASC)
FROM (
SELECT date_trunc('day', created_at) AS created_on, count(1) AS note_count
FROM notes
GROUP BY created_on
ORDER BY created_on DESC
) AS note_counting;
-- WHERE created_on >= '2013-01-01'