Skip to content

Instantly share code, notes, and snippets.

Lucas Húngaro lucashungaro

Block or report user

Report or block lucashungaro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lucashungaro
lucashungaro / gist:02c40b4d618b93f3e44971889e7c33f3
Created Apr 8, 2016
Fix Homebrew issues after upgrading to El Capitan (errors such as /usr/local is not writable or cannot load such file --mach)
View gist:02c40b4d618b93f3e44971889e7c33f3
sudo chown -R $(whoami):admin /usr/local
cd /usr/local
git reset --hard
git clean -df
brew update
Profit!
@lucashungaro
lucashungaro / gist:06d1add1f39a57e05837
Created Apr 21, 2015
Microservices, RabbitMQ etc
View gist:06d1add1f39a57e05837
https://speakerdeck.com/joshsz/rack-amqp-ditch-http-inside-soa
http://blog.carbonfive.com/2014/04/28/micromessaging-connecting-heroku-microservices-wredis-and-rabbitmq/
https://www.rabbitmq.com/tutorials/tutorial-six-ruby.html
http://highscalability.com/blog/2014/4/8/microservices-not-a-free-lunch.html
https://www.youtube.com/watch?v=vfs4sr1_o6s (Global Scaling at The New York Times Using RabbitMQ (from OSCON 2014))
View keybase.md

Keybase proof

I hereby claim:

  • I am lucashungaro on github.
  • I am lucashungaro (https://keybase.io/lucashungaro) on keybase.
  • I have a public key whose fingerprint is DBDB D15C 2767 6225 056B 63AC 956A BAD9 2CFE 2097

To claim this, I am signing this object:

@lucashungaro
lucashungaro / config.ru
Created Oct 31, 2013
Unicorn + Heroku + worker_killer + GC vars tweak
View config.ru
# This file is used by Rack-based servers to start the application.
# GC_FREQUENCY = 8
# require "unicorn/oob_gc"
# GC.disable # Don't run GC during requests
# use Unicorn::OobGC, GC_FREQUENCY # Only GC once every GC_FREQUENCY requests
# # Unicorn self-process killer
require "unicorn/worker_killer"
@lucashungaro
lucashungaro / form_helper.rb
Last active Jan 27, 2017
Triggering an autocomplete select box with Capybara and Turnip
View form_helper.rb
# on spec/helpers
module FormHelper
def fill_in_autocomplete(selector, value)
page.execute_script %Q{$('#{selector}').focus().val('#{value}').keydown()}
end
def choose_autocomplete(text)
find('ul.ui-autocomplete').should have_content(text)
page.execute_script("$('.ui-menu-item:contains(\"#{text}\")').find('a').trigger('mouseenter').click()")
end
View card_data.rb
class CardData
def initialize(node)
@card_data = node
end
def name
@card_data.search("name").text
end
def image
@lucashungaro
lucashungaro / gist:3784008
Created Sep 25, 2012
removing conditional and working with provided callbacks
View gist:3784008
class UserController < ApplicationController
def create
@user_creation = UserCreation.new(self)
@user_creation.on_success { redirect_to users_path }
@user_creation.on_failure { render :new }
@user_creation.please_create_an_user_as_admin(params[:user])
end
end
View gist:3001641
# WARNING: pseudo code
class Authenticator
def initialize(user_repository = User)
@user_repository = user_repository
end
def authenticate(identifier, hashed_password)
@user_repository.find(:username => identifier, :password => hashed_password).present?
end
View gist:3001511
class Game < ActiveRecord::Base
belongs_to :category
validates_presence_of :title, :category_id, :description,
:price, :platform, :year
end
 
class GamePriceService
attr_accessor :game
 
# we could use a config file
View gist:3001505
class Game < ActiveRecord::Base
belongs_to :category
validates_presence_of :title, :category_id, :description,
:price, :platform, :year
end
 
class GamePriceService
attr_accessor :game, :json_parser
 
# we could use a config file
You can’t perform that action at this time.