Skip to content

Instantly share code, notes, and snippets.

View ecavazos's full-sized avatar

Emilio Cavazos ecavazos

  • Google
  • Mountain View, CA
View GitHub Profile
@ecavazos
ecavazos / api.go
Last active December 14, 2015 12:39
Get json data from Github's API (in Go)
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func gist(id string) {
@ecavazos
ecavazos / mysql.go
Last active December 14, 2015 11:38
package main
import (
"database/sql"
"fmt"
_ "github.com/Go-SQL-Driver/MySQL"
"strings"
)
const DbName = "go_test_db"
@ecavazos
ecavazos / Gemfile
Created July 27, 2012 21:07
This is for Blaine
source 'http://rubygems.org'
gem 'nokogiri'
gem 'shotgun'
gem 'sinatra'
gem 'yajl-ruby'
@ecavazos
ecavazos / basic_celluloid.rb
Created June 6, 2012 06:32
A very basic celluloid example
require 'celluloid'
class Cat
include Celluloid
def initialize(name)
@name = name
end
def speak
@ecavazos
ecavazos / completions.rb
Created June 5, 2012 05:22
Some defer for that "A"
require 'eventmachine'
class HardWorker
def initialize(name)
@name = name
@completion = EM::Completion.new
end
def work
@ecavazos
ecavazos / jim.rb
Created March 23, 2012 21:06
tiny sinatra for inside joke
require 'sinatra'
get '/' do
haml :index
end
post '/' do
name = params[:name].downcase
if name == "jim" || name == "jim clenney" || name == "bubba"
@greeting = "Yam pie for you."
@ecavazos
ecavazos / gist:2166956
Created March 23, 2012 04:56
fix my macvim fonts (os x)
defaults -currentHost write -globalDomain AppleFontSmoothing -int 3
@ecavazos
ecavazos / fake_friends.rb
Created February 21, 2012 03:40
People you follow on Twitter who don't follow you.
require 'twitter_oauth'
require 'pp'
consumer_key = '<key>'
consumer_secret = '<secret>'
remote_id = '<id>'
access_token = '<token>'
user = '<screen_name>'
# Add the users_lookup method
@ecavazos
ecavazos / clean_local_branches.rb
Created February 19, 2012 04:02
Delete local branches that have been merged into master.
#!/usr/bin/env ruby
branches = %x(git fetch origin && git branch --merged master)
exclude = /master|test|production|staging/
deletable = branches.split("\n").select { |branch| branch.strip !~ exclude }
if deletable.empty?
puts 'nothing to delete :('
else
@ecavazos
ecavazos / rank_and_score.rb
Created February 19, 2012 03:40
Sorted set rank and score.
require 'sorted_set_adapter'
set = SortedSetAdapter.new
set.flush
set.add 1, 'foo'
set.add 2, 'bar'
p set.all # -> ["foo", "bar"]