Skip to content

Instantly share code, notes, and snippets.

View Koronen's full-sized avatar

Victor Koronen Koronen

View GitHub Profile
@emachnic
emachnic / nginx_virtual_host
Created November 27, 2011 05:37 — forked from mrsweaters/nginx_virtual_host
Ruby on Rails server setup on Ubuntu 11.04 with Nginx, Unicorn, Rbenv
upstream example-workers {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a single worker for timing out).
server unix:/tmp/example.co.uk.socket fail_timeout=0;
}
server {
listen 80; # default;
server_name example.co.uk;
root /home/example.co.uk/website/public;
@sontek
sontek / snowjob.py
Created December 22, 2011 04:24
Make your terminal snow with python
#!/usr/bin/env python
import os
import random
import time
import platform
snowflakes = {}
try:
# Windows Support
@RISCfuture
RISCfuture / rails_template.rb
Last active September 30, 2015 20:27
Tim's Awesome Rails Template
# encoding: utf-8
require 'open3'
def rvm_env(cmd)
Open3.popen3 "bash -c 'source ~/.rvm/scripts/rvm && #{cmd}'" do |stdin, stdout, stderr, thread|
thread.join
end
end
@peterhellberg
peterhellberg / Gemfile
Created April 10, 2012 11:51
Sinatra acceptance testing, using minitest/spec and capybara-webkit
source :rubygems
gem "sinatra", "~> 1.3.2"
group :test do
gem "minitest", "~> 2.10"
gem "rack-test", "~> 0.6.1"
gem "capybara", "~> 1.1"
gem "capybara-webkit", "~> 0.11"
gem "capybara_minitest_spec", "~> 0.2"
@Koronen
Koronen / bootstrap_debian.sh
Created April 29, 2012 10:38
System bootstrap scripts
#!/bin/sh
set -e
# System update & upgrade
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y dist-upgrade
# Editor
@Nycander
Nycander / latency.txt
Created May 31, 2012 13:41 — forked from jboner/latency.txt
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
Send 2K bytes over 1 Gbps network 20,000 ns
Read 1 MB sequentially from memory 250,000 ns
Round trip within same datacenter 500,000 ns
Disk seek 10,000,000 ns
@Frost
Frost / hash_wat.rb
Created July 19, 2012 18:35
Ruby Hash wat.
# So, let's create a Hash with an empty Array as the default value...
0|frost tiamat >> irb
irb(main):001:0> h = Hash.new []
=> {}
irb(main):002:0> h[42] << "foo"
=> ["foo"]
irb(main):003:0> h
=> {}
irb(main):004:0> h[42] += ["bar"]
=> ["foo", "bar"]
@Frost
Frost / jump_to_relative_line
Created July 31, 2012 16:02
macro for jumping to a relative line in vim
" prompt user for a line to jump to.
" accepts N, +N or -N as input.
" -N will be equivalent of just typing N-
" +N equals typing N+ or running :N
function! JumpToRelativeLine()
let linenumber = line('.')
call inputsave()
let line = input('go to line: ')
call inputrestore()
call setpos('.', [0,eval(linenumber + line),0,0])
@ryanb
ryanb / expectations.md
Created December 6, 2012 01:04
Alternative expectation interface for MiniTest and RSpec

Expectations

I took the ideas presented here and built a gem called Mustard. Check it out!

There are several expectation/assertion interfaces available for writing tests/specs. Here are some issues I have with them.

Test::Unit/MiniTest

  • The order of assert_equals feels backwards
  • Oh wait, that should be assert_equal (that too)
@ivanvanderbyl
ivanvanderbyl / gist:4222308
Created December 6, 2012 06:55
Postgres 9.1 to 9.2 upgrade guide for Ubuntu 12.04
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"