Skip to content

Instantly share code, notes, and snippets.

Andrea D'Amico adamico

View GitHub Profile
@adamico
adamico / pack.c
Created Nov 28, 2015
C source of .pack in ruby
View pack.c
static VALUE
pack_pack(VALUE ary, VALUE fmt)
{
static const char nul10[] = "\0\0\0\0\0\0\0\0\0\0";
static const char spc10[] = " ";
const char *p, *pend;
VALUE res, from, associates = 0;
char type;
long items, len, idx, plen;
const char *ptr;
@adamico
adamico / Gemfile
Created Jul 30, 2015
Use CombinePDF in a Rails app to merge existing PDF files with Prawn generated PDF content
View Gemfile
gem 'combine_pdf'
gem 'prawn'
gem 'paperclip'
@adamico
adamico / en.yml
Last active Jun 21, 2017 — forked from johnjohndoe/uri_validator.rb
Rails 4 with I18n working interpolations
View en.yml
en:
errors: &errors
messages:
bad_uri: is an invalid url
bad_protocol: must start with %{protocols}
activemodel:
errors:
<<: *errors
activerecord:
errors:
View devise.fr.yml
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
fr:
devise:
confirmations:
confirmed: 'Votre compte a été validé, vous êtes maintenant connecté'
send_instructions: 'Vous allez recevoir les instructions nécessaires à la confirmation de votre compte dans quelques minutes'
send_paranoid_instructions: 'Si votre e-mail existe dans notre base de données, vous allez bientôt recevoir un e-mail contenant les instructions de confirmation de votre compte.'
failure:
already_authenticated: "Vous êtes déjà connecté !"
View gist:6592299
require 'open-uri'
require 'nokogiri'
doc = Nokogiri::HTML(open("http://www.threescompany.com/"))
titles = doc.css("#content_inner h2")
containers = doc.css("#content_inner .format_text")
articles = []
titles.each_with_index do |title, i|
images = containers[i].css("div > img, a > img")[0..-2]
images = images.map { |image| image.attributes["src"].value }
@adamico
adamico / collection_check_boxes_input.rb
Last active Apr 28, 2020 — forked from mattclar/simple_form.rb
This fork adds a custom horizontal form wrapper and merges append/prepend in a 'group' wrapper
View collection_check_boxes_input.rb
#app/inputs/collection_check_boxes_input.rb
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def item_wrapper_class
"checkbox-inline"
end
end
@adamico
adamico / collection_check_boxes_input.rb
Created Sep 6, 2013
SimpleForm inline collection radio_buttons/checkboxes for Twitter Bootstrap 3
View collection_check_boxes_input.rb
#app/inputs/collection_check_boxes_input.rb
class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
def item_wrapper_class
"checkbox-inline"
end
end
@adamico
adamico / simple_form_bootstrap.rb
Created Aug 30, 2013
Twitter Bootstrap 3 initializer for Simple Form
View simple_form_bootstrap.rb
# Use this setup block to configure all options available in SimpleForm.
SimpleForm.setup do |config|
# you need an updated simple_form gem for this to work, I'm referring to the git repo in my Gemfile
config.input_class = "form-control"
config.wrappers :bootstrap, tag: 'div', class: 'form-group', error_class: 'error' do |b|
b.use :html5
b.use :placeholder
b.use :label
b.use :input
@adamico
adamico / gist:1077608
Created Jul 12, 2011
multiple nested engine failing on refinerycms 1.0.3
View gist:1077608
refinerycms test-multiple-nested-engines
rails generate refinery_engine father name:string
bundle install
rails generate refinerycms_fathers && rake db:migrate
rails generate refinery_engine son name:string fathers:engine
bundle install
rails generate refinerycms_sons && rake db:migrate
rails generate refinery_engine daughter name:string fathers:engine
bundle install
rails generate refinerycms_daughters
@adamico
adamico / gist:1053980
Created Jun 29, 2011
no love for refinerycms, bundler 1.1.pre.5, rubygems 1.8.5
View gist:1053980
rvm gemset create refinery-bundler-pre --use
gem install bundler --pre
gem install refinerycms
refinerycms test_app
You can’t perform that action at this time.