Skip to content

Instantly share code, notes, and snippets.

View nmenag's full-sized avatar

Nicolas Mena nmenag

View GitHub Profile
@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 / 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
@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

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
@nmenag
nmenag / wickedpdf_heroku.rb
Created July 30, 2016 20:11
wickedpdf on Heroku
gem 'wicked', '~> 1.3'
gem 'wicked_pdf', '~> 1.0', '>= 1.0.6'
gem 'wkhtmltopdf-binary', '~> 0.12.3'
group :production, :staging do
gem 'wkhtmltopdf-heroku', '~> 2.12', '>= 2.12.3.0'
end
@nmenag
nmenag / last_commit.md
Last active February 23, 2020 21:22
Rollback to last git commit

Git commands

  • To UNDO local file changes but NOT REMOVE your last commit, then use

git reset --hard

  • To UNDO local file changes AND REMOVE your last commit, then use

git reset --hard HEAD^

@nmenag
nmenag / arithmetic_progression.rb
Created March 14, 2016 02:17
verify arithmetic progression in ruby
class Array
<<-DOC
8, 3, -2, -7, -12, ...
3 - 8 = -5
-2 - 3 = -5
-7 - (-2) = -5
-12 - (-7) = -5
d = −5.