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 / table.haml
Last active December 17, 2015 23:19
Tabla en Haml
%table#id_tabla
%thead
%th Columna 1
%th Columna 2
%tbody
%tr
%td
%label Hola
%td
%label World
@hyeomans
hyeomans / .gitconfig
Created May 10, 2013 17:48
Dot files
[color]
diff = auto
status = auto
branch = auto
[color "status"]
changed = yellow
added = green
untracked = red
@hyeomans
hyeomans / python_regex.rb
Created May 10, 2013 17:08
Using the block I can filter which operation I want to return with a simple string, otherwise it will return the 3 operations in an array.
require 'open3'
class PythonRegex
extend Open3
def self.calculate_intersection(first_regex, second_regex)
popen3('python', 'lib/services/greenery/main.py', first_regex, second_regex) do |stdin, stdout, stderr|
if block_given?
stdout.read.split("\n").select { |line| line.start_with? yield }
else
stdout.read.split("\n").each { |line| p line }
end
# simple ruby code example for running python script
path_to_script = File.dirname(__FILE__)
puts "It's a ruby script"
puts "Run python script with backticks"
puts "Result is available in caller.ru"
puts `python #{path_to_script}/processing.py UserName 37`
@hyeomans
hyeomans / vagrant_install.md
Last active December 17, 2015 02:19
Deploying Rails app to Vagrant on Ubuntu 12.04

Warming up

gem install vagrant

vagrant box add precise64 http://dl.dropbox.com/u/1537815/precise64.box
vagrant up && vagrant ssh

sudo apt-get -y update && sudo apt-get -y install curl git-core python-software-properties

Custom Apt-Get repo

@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;

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 / 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
# 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 / 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"