Skip to content

Instantly share code, notes, and snippets.

View nmenag's full-sized avatar

Nicolas Mena nmenag

View GitHub Profile
@nmenag
nmenag / erb_layout.rb
Created July 10, 2019 20:17
using template with ERB class
template = ERB.new(@template)
template.def_method(LayoutRenderer, 'render')
result = LayoutRenderer.new.render do
ERB.new(@content).result(binding)
end
File.open('tmp/payslip_filename.html', 'w+') do |f|
f.write result
end
@nmenag
nmenag / remove_braches.md
Created October 16, 2018 15:08
Remove all local branches
@nmenag
nmenag / install_crystal.md
Created October 11, 2018 22:17
Install Crystal lang
@nmenag
nmenag / gist:f5c268d833e7aeeacf3f6cb8b1a8f7d9
Created November 12, 2017 16:17 — forked from metaskills/gist:2836849
Basic Save & Open Page For Poltergeist
def save_and_open_page
dir = "#{Rails.root}/tmp/cache/capybara"
file = "#{dir}/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png"
FileUtils.mkdir_p dir
page.driver.render file
wait_until { File.exists?(file) }
system "open #{file}"
end
@nmenag
nmenag / restore-postgres-heroku.md
Last active October 25, 2017 22:28
Restore and backup BD postgres in Heroku

Restore database with Heroku

Some tips to improve test flow dealing with database on local and production environments.

I. Pull database from Heroku

It is really usefull if you want to fill your local database with real data from production environment.

1. Drop Local Database

@nmenag
nmenag / replace_word.md
Created October 12, 2017 05:22
Remplace words via console

grep -rl "ActiveRecord::Migration" db | xargs sed -i "" "s/ActiveRecord::Migration/ActiveRecord::Migration[5.1]/g"

@nmenag
nmenag / rollbar.md
Last active May 17, 2017 16:18
how to Install Rollbar on Heroku for a Rails project

Rails naming conventions

General Ruby conventions

Class names are CamelCase.

Methods and variables are snake_case.

Methods with a ? suffix will return a boolean.

@nmenag
nmenag / curl.txt
Created November 30, 2016 06:50
Curl example
curl -X POST -d '{title: "foo", body: "example in makeitreal wow", userId: 1 }' http://jsonplaceholder.typicode.com/posts