Skip to content

Instantly share code, notes, and snippets.

View mattyoho's full-sized avatar

Matt Yoho mattyoho

  • Portland, OR, USA
View GitHub Profile
@swannodette
swannodette / gist:3217582
Created July 31, 2012 14:52
sudoku_compact.clj
;; based on core.logic 0.8-alpha2 or core.logic master branch
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
@redsquirrel
redsquirrel / bowling_score.rb
Created July 15, 2012 00:43
In which I realize that the scoring logic for strikes and spares are the same. (3 consecutive balls)
require 'test/unit'
def score(*frames)
score = roll_count = 0
rolls = frames.flatten
frames.each do |frame|
if sum(frame) == 10
score += sum(next_three(rolls, roll_count))
else
score += sum(frame)
@jimweirich
jimweirich / base_spec-fragment.rb
Created June 20, 2012 18:18
Isolating Class Changes
context "with an isolated decorator class" do
let(:decorator_class) { Class.new(Decorator) }
subject{ decorator_class.new(source) }
context "when #hello_world is called again" do
it "proxies method directly after first hit" do
subject.methods.should_not include(:hello_world)
subject.hello_world
subject.methods.should include(:hello_world)
end
@conanr
conanr / 01_setup_vagrant.sh
Created June 6, 2012 20:00
Vagrant set up using Nginx, Mysql, & God
vagrant box add precise32 http://files.vagrantup.com/precise32.box
vagrant init precise32
# update Vagrantfile to port forward: ln 32 => "config.vm.forward_port 80, 8080"
vagrant up
vagrant ssh

Install

brew install logrotate

add to .bash_profile

export PATH=${PATH}:/usr/local/sbin

restart terminal just to check the logrotate command returns something

logrotate -?

make logrotate.d directory inside of /etc/ and add new config file

Install

brew install logrotate

add to .bash_profile

export PATH=${PATH}:/usr/local/sbin

restart terminal just to check the logrotate command returns something

logrotate -?

make logrotate.d directory inside of /etc/ and add new config file

@jboner
jboner / latency.txt
Last active April 19, 2025 21:29
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
@majek
majek / README.md
Created April 26, 2012 15:15
Passing TCP socket descriptors around

Passing TCP socket descriptors around

In linux, normally, it is impossible to "bind()" to the same TCP port twice. If you try to bind to the same port from second proces unix processes you'll see:

socket.error: [Errno 98] Address already in use

@cstrahan
cstrahan / quality.rake
Created April 18, 2012 23:22
A hackish rake task for checking code quality with reek and cane.
# Colors
escape = -> n { STDOUT.tty? ? "\033[#{n}m" : "" }
red = escape[31]
green = escape[32]
yellow = escape[33]
blue = escape[34]
magenta = escape[35]
cyan = escape[36]
reset = escape[ 0]
@austenito
austenito / integration_spec.rb
Created April 11, 2012 12:50
Integration Testing w/ Sorcery
describe "Shopping Cart Requests" do
let!(:user) { Fabricate(:user) }
before(:each) do
login_user_post("admin", "admin")
end
context "when I visit the shopping cart" do
it " show the logged in users' cart items " do
#Test stuff