Skip to content

Instantly share code, notes, and snippets.


Tonatiuh Núñez tonatiuh

View GitHub Profile

Therubyracer + libv8 in Mavericks with ruby-1.9.3-p448 issue


If therubyracer gives you a problem like this one when installing it:

ERROR:  Error installing therubyracer:
  ERROR: Failed to build gem native extension.

    /Users/tonatiuh/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
View todo.mkd


  • improve file copying
  • commit the files, created repo
  • install nginx

to do

  • install the gems


  • install the gems for auth and main
tonatiuh /
Last active Aug 29, 2015
Bash functions that make automate some day to day tasks

Function that automates the creation of a new gitflow branch:


function git_start_feature() {
  story_title=${story_title,,} # downcase string
  story_title=${story_title// /-} # replace spaces by dashes
  story_title=${story_title//\//-} # replace slashes by dashes
tonatiuh / gist:3670657
Created Sep 7, 2012
Error when sending all the vertical form
View gist:3670657
class Vertical < ActiveRecord::Base
has_one :parent_relation, foreign_key: "child_id", class_name: "VerticalRelation"
has_many :child_relations, foreign_key: "parent_id", class_name: "VerticalRelation"
has_one :head_relation, foreign_key: "tail_id", class_name: "VerticalRelation"
has_one :tail_relation, foreign_key: "head_id", class_name: "VerticalRelation"
has_one :parent, through: :parent_relation
has_many :children, through: :child_relations, source: :child
has_one :head, through: :head_relation
View gist:3710358
## The vertical
#Be sure of that vertical with id 1 exists
## The campaign (form)
#Put to the campaign the state of washignton
#Set to the campaign the vertical: 1
## The contacts (on the rails console)
Contact.create(:name => 'Jodee Clore', :vertical_id => 1, :geo_id => '15121') #this geo_id's are citys of washington
Contact.create(:name => 'Trish Roudebush', :vertical_id => 1, :geo_id => '14974')
tonatiuh / gist:3717573
Created Sep 13, 2012
method for finding matching geo campaigns
View gist:3717573
def self.find_matching_campaigns_by_geo(contact)
matching_campaigns = []
Campaign.all.each do |campaign|
campaign.geos.each do |geo|
match = Geo.where(id:"LEFT JOIN geo_polygons as container ON container.geo_id = #{}").where('ST_Within(geo_polygons.poly, container.poly)')
matching_campaigns << campaign unless match.empty?
View contact.rb
def new_contact_obligations
# self.vertical = conversions.first.placement.vertical
self.attributes = load_loc_attrs!
tonatiuh / campaign.rb
Created Sep 22, 2012
Update another record on after_save on model
View campaign.rb
after_save :bid_adjusts
def bid_adjusts
unless @old_exclusive_campaign.nil?
campaign = Campaign.find(
campaign.update_attributes(exclusivity: false)
tonatiuh / cucumber_error.log
Created Sep 29, 2012
Error when running cucumber
View cucumber_error.log
Scenario: Returning to a form placement # features/collection.feature:12
When a contact returns to a form placement completed previously # features/step_definitions/engine_steps.rb:132
Unable to load URL: (Capybara::Driver::Webkit::WebkitInvalidResponseError)
./features/step_definitions/engine_steps.rb:29:in `/^a contact visits a page with an? (\w+) placement$/'
features/collection.feature:13:in `When a contact returns to a form placement completed previously'