Skip to content

Instantly share code, notes, and snippets.

View nmenag's full-sized avatar
🏠
Working from home

Nicolas Mena nmenag

🏠
Working from home
  • Colombia
  • 13:43 (UTC -12:00)
View GitHub Profile
var holidays =[]
//holiday model ruby, table that save all the holidays federal
holidays = "<%= Holiday.all.map{ |h| h.date.strftime("%Y-%m-%d") } %>";
/*example "2015-10-12", "2015-11-02", "2015-11-16", "2015-12-08", "2015-12-25", "2016-01-01",
"2016-01-11", "2016-03-21", "2016-03-24", "2016-03-25", "2016-05-01", "2016-05-09", "2016-05-30",
"2016-06-06", "2016-07-04", "2016-07-20", "2016-08-07", "2016-08-15", "2016-10-17", "2016-11-07",
"2016-11-14", "2016-12-08", "2016-12-25"]*/
$('.date').datepicker({
@nmenag
nmenag / date_diff.rb
Created January 22, 2016 16:24
Method for calculate the years and the months between two dates
def date_diff(date1, date2)
month = (date2.year * 12 + date2.month) - (date1.year * 12 + date1.month)
month.divmod(12)
end
#for get the years
date_diff(date, Date.today)[0]
#for get the months
date_diff(date, Date.today)[1]
@nmenag
nmenag / tools.md
Last active June 9, 2016 16:44
Resources and services for project development
@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.
@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 / 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 / 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

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 / 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 / rollbar.md
Last active May 17, 2017 16:18
how to Install Rollbar on Heroku for a Rails project