Skip to content

Instantly share code, notes, and snippets.

View hyeomans's full-sized avatar
🏠
Working from home

Hector Yeomans hyeomans

🏠
Working from home
View GitHub Profile
@hyeomans
hyeomans / strategy.cs
Created March 21, 2012 18:23
Strategy Pattern with BitRate Conversions
using System;
using System.Collections.Generic;
namespace StrategyPattern
{
public enum UnitOfBitRate
{
Gbps,
Mbps,
Kbps,
@hyeomans
hyeomans / gist:2494406
Created April 25, 2012 23:23
Installing Riak in Mint
Installing Erlang
sudo apt-get install curl build-essential libncurses5-dev openssl libssl-dev fop xsltproc
curl -O https://raw.github.com/spawngrid/kerl/master/kerl
chmod a+x kerl
./kerl build R14B03 r14b03
sudo ./kerl install r14b03 /opt/erlang/r14b03
. /opt/erlang/r14b03/activate
Installing Riak
sudo apt-get install build-essential libc6-dev-i386
@hyeomans
hyeomans / gist:4270322
Created December 12, 2012 18:32
Testing environment for Rails
1.- Start Spork in a terminal window.
2.- Write a single test or small group of tests.
3.- Run Command-Shift-R to verify that the test or test group is red.
4.- Write the corresponding application code.
5.- Run Command-Shift-E to run the same test/group again, verifying that it’s green.
6.- Repeat steps 2–5 as necessary.
7.- When reaching a natural stopping point (such as before a commit), run rspec spec/ at the command line to confirm that the entire test suite is still green.

Install Rails

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@hyeomans
hyeomans / gist:5327710
Last active December 15, 2015 21:39 — forked from alexbihary/gist:5078409
Setting up an environment in Debian based

Ubuntu 12.04 Ruby on Rails Development Environment

I haven't set up an install guide for the latest ubuntu release, largely because the last set of instructions worked pretty closely with the latest and greatest Ubuntu, 12.04 Precise Pangolin, however when installing today, I found that there were enough differences in the way that I configure my setup to justify an update, so here it goes. Yes, I'm late to the party, but a quick google search didn't find anything that I felt was as complete for my requirements as my previous install guides, so here I go.

As always with my install guides, I have included here is just about everything you'll need (and then some) to get started with ruby on rails development with Ubuntu 12.04 as a platform. These are my settings and preferences, and this is certainly not the only way of doing things, so keep that in mind.

Step 1: Get the repos ready and run updates.

sudo apt-get update && sudo apt-get upgrade

@hyeomans
hyeomans / fun_bash.sh
Last active December 15, 2015 22:09
My bash aliases
##Install elinks
##brew install elinks
alias fact="elinks -dump randomfunfacts.com | sed -n '/^| /p' | tr -d \|"
##Jobs that take too long
alias funspork="fact && spork"
# check the comments for @billmann's awesome solution to the same problem
def make_hash_one_dimensional(input = {}, output = {}, options = {})
input.each do |key, value|
key = options[:prefix].nil? ? "#{key}" : "#{options[:prefix]}#{options[:delimiter]||"_"}#{key}"
if value.is_a? Hash
make_hash_one_dimensional(value, output, :prefix => key, :delimiter => "_")
else
output[key] = value
end
@hyeomans
hyeomans / benchmark.rb
Last active December 16, 2015 22:48
Benchmarking regex against kernel string comparison
Setup the Benchmark
[1] pry(main)> require 'benchmark'
=> true
[2] pry(main)> test_string = "/foo/bar/bah/bing"
=> "/foo/bar/bah/bing"
String#starts_with?
[3] pry(main)> Benchmark.realtime { (1..10000).to_a.each { %r{^/foo}.match(test_string) } }
=> 0.009987447

Setup new Mac with OSX Lion from scratch

These commands are good as of 2011-07-27.

Install Xcode 4

The download/install takes a while so start it first. When it finishes downloading you will still need to run it to complete installation.

Really the nicest choice for a terminal on OSX right now, especially with Lion style full screen support.

@hyeomans
hyeomans / postgres.sql
Last active December 17, 2015 00:29
Postgres shortcuts
//Access root
sudo su - postgres
psql postgres
//Create user
create user el_usuario with password '';
//Giving user permission to create databases
ALLTER USER el_usuario CREATEDB;