Skip to content

Instantly share code, notes, and snippets.

View bbonamin's full-sized avatar
🕶️

Bruno Bonamin bbonamin

🕶️
View GitHub Profile
@bbonamin
bbonamin / Vagrantfile
Created May 9, 2014 19:30
Vagrant VM with access to host VPN
Vagrant::Config.run do |config|
config.vm.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
config.vm.network :hostonly, "192.168.56.101"
config.vm.box = "base-hadoop"
config.vm.customize ["modifyvm", :id, "--memory", 1024, "--cpus", "1"]
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "manifests"
puppet.manifest_file = "base-hadoop.pp"
puppet.module_path = "modules"
end
@bbonamin
bbonamin / Vagrantfile
Created December 24, 2014 13:07
Vagrant + Ansible as provisioned dev box
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 3000, host: 3001
config.vm.provision :ansible do |ansible|
ansible.playbook = "playbook.yml"
ansible.verbose = 'v'
end
end
@bbonamin
bbonamin / anagram.exs
Created September 17, 2015 19:55
Beginner's Elixir version of Avdi's anagram for Hello Crystal http://devblog.avdi.org/2015/08/20/hello-crystal/
defmodule Anagram do
def table(file, table) do
case IO.read(file, :line) do
line when line != :eof ->
word = String.replace(line, ~r/\n/, "")
key = to_key(word)
row = table[key] || []
row = row ++ [String.downcase(word)]
@bbonamin
bbonamin / I18n devise es
Created May 18, 2011 15:32 — forked from miclovich/I18n devise es
devise I18n file in spanish
es:
errors:
messages:
not_found: 'no encontrado'
already_confirmed: 'ya ha sido confirmada'
not_locked: 'no está bloqueada'
devise:
failure:
unauthenticated: 'Necesitas acceder a tu cuenta o registrarte antes de continuar.'
@bbonamin
bbonamin / order.rb
Created August 1, 2011 09:08 — forked from pcreux/order.rb
active_admin custom collection action with filtering and sorting
ActiveAdmin.register Order do
# Export the current collection of items with filtering and sorting
# List the current collection ids
collection_action :export_txt do
render :text => collection.map { |order| order.id }.join(', ')
end
# Add a button to index page to export current collection as txt
@bbonamin
bbonamin / Gemfile
Created August 10, 2011 22:19 — forked from emzeq/orders.rb
rails3-jquery-autocomplete in ActiveAdmin
gem 'rails3-jquery-autocomplete', '0.9.0'
@bbonamin
bbonamin / flight.rb
Created August 16, 2011 12:01 — forked from geektoo/flight.rb
flights models
class Flight < ActiveRecord::Base
has_many :people
end
@bbonamin
bbonamin / schema.rb
Created September 3, 2011 00:21
Rails multiple association between two models - schema
create_table "flights", :force => true do |t|
t.date "date"
t.integer "pilot_id"
t.integer "instructor_id"
t.integer "glider_id"
t.string "type_of_flight"
t.integer "towplane_pilot_id"
t.integer "towplane_id"
t.integer "departure_airfield_id"
t.integer "arrival_airfield_id"
@bbonamin
bbonamin / ability.rb
Created October 5, 2011 15:02 — forked from watson/ability.rb
Active Admin CanCan integration with shared front/backend User model and multi-level autherization
# app/models/ability.rb
# All front end users are authorized using this class
class Ability
include CanCan::Ability
def initialize(user)
user ||= User.new
can :read, :all
@bbonamin
bbonamin / rails_admin_and_globalize3.md
Created November 19, 2011 19:16 — forked from Overbryd/rails_admin_and_globalize3.md
RailsAdmin and Globalize3

RailsAdmin and Globalize3

I have a project where I need translated content. Therefore I use globalize3, wich stores its translated attributes in a seperate table that belongs to the original model. And I use RailsAdmin for painless record management.

It took me some time to figure out how to get those working together, but eventually I found a solution that is non invasive and still ok to work with.

The translated model

In my case there is a Snippet class. It holds content for static pages or text passages on the website. There is a good README for globalize3 for installation instructions and documentation.