start new:
tmux
start new with session name:
tmux new -s myname
require "open-uri" | |
require "net/http" | |
Error = Class.new(StandardError) | |
DOWNLOAD_ERRORS = [ | |
SocketError, | |
OpenURI::HTTPError, | |
RuntimeError, | |
URI::InvalidURIError, |
Thanks to this Gist: https://gist.github.com/avalonalex/8125197 | |
How to use: Make sure Homebrew is installed then run `curl https://gist.githubusercontent.com/zebMcCorkle/fa4508e27f457d7b796ffd474be35d62/raw/59942466b13fe92d09b4b537cc7fcfb309c05c4a/consolas.sh | bash -` |
#!/bin/env ruby | |
# lazy hack from Robert Klemme | |
module Memory | |
# sizes are guessed, I was too lazy to look | |
# them up and then they are also platform | |
# dependent | |
REF_SIZE = 4 # ? | |
OBJ_OVERHEAD = 4 # ? |
class TrieDict | |
attr_reader :dict | |
def initialize | |
@dict = {} | |
end | |
def put(str) | |
d = nil | |
str.chars.each do |c| |
require 'benchmark' | |
# | |
# Code example for my blogpost | |
# | |
# Hash lookup in Ruby, why is it so fast? | |
# | |
# | |
# Struct used to store Hash Entries |
test: | |
override: | |
- bundle exec rspec spec | |
deployment: | |
acceptance: | |
branch: master | |
commands: | |
- ./script/heroku_deploy.sh <ACCEPTANCE_HEROKU_APP>: | |
timeout: 300 |
#!/usr/bin/env ruby | |
# This is a basic deploy script for Heroku apps. | |
# It provides a structure you can use to expand on | |
# and add your own prereqs and deploy tasks. | |
# | |
# It basically ensures that: | |
# 1. There are no uncommited files | |
# 2. You can ssh to github | |
# 3. You can connect to heroku |
require 'spec_helper' | |
describe 'block example' do | |
let(:thing) { FactoryGirl.create :thing } | |
context 'without versioning' do | |
before do | |
thing.update_attributes name: 'a different name' |
require 'factory_girl_rails' | |
require 'rspec' | |
require 'rspec-rails' | |
require 'rspec/mocks/standalone' # => if factories need stubs (for remote services for example) | |
include FactoryGirl::Syntax::Methods # make FG methods available at top level, so you can do `> create :user` | |
def reload_factories! | |
FactoryGirl.instance_variable_set(:@factories, nil) # => clear loaded factories/sequences | |
# FactoryGirl.instance_variable_set(:@sequences, nil) |