Skip to content

Instantly share code, notes, and snippets.

@edelpero
edelpero / method_performance_comparison.rb
Created April 15, 2015 16:16
Compares method execution performance
View method_performance_comparison.rb
require 'benchmark/ips'
class A
def sum
1 + 1
end
end
class B
def sum
@edelpero
edelpero / cleaning_hash.md
Last active August 29, 2015 14:19
How to Remove Empty Elements and Empty Strings from a Hash and it's Child Elements
View cleaning_hash.md
@edelpero
edelpero / heroku_rails_phantomjs.md
Last active May 10, 2021 08:31
Heroku, Ruby on Rails and PhantomJS
View heroku_rails_phantomjs.md

#Heroku, Ruby on Rails and PhantomJS

In this post, I’m going to show you how to modify an existing Ruby on Rails app running on Heroku’s Cedar stack to use PhantomJS for screen scraping. If you’ve never heard of PhantomJS, it’s a command-line WebKit-based browser (that supports JavaScript, cookies, etc.).

Let’s get started. This is a high-level overview of the required steps:

  • Modify your app to use multiple Heroku buildpacks.
  • Extend your app to use both the Ruby as well as the PhantomJS buildpacks.
  • Confirm that everything worked.
@edelpero
edelpero / erb_to_haml.md
Last active August 29, 2015 13:56
Convert all ERB templates to HAML
View erb_to_haml.md

###1. Prerequisites:

You must have the following gems installed:

  • haml (or haml-rails)
  • hpricot
  • ruby_parser

###2. Create new HAML files

Test the changes: (no files created)

@edelpero
edelpero / gist:4240670
Created December 8, 2012 15:07 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts
View gist:4240670