Skip to content

Instantly share code, notes, and snippets.

View antico5's full-sized avatar

Armando Andini antico5

  • Santa Fe, Argentina
View GitHub Profile
@antico5
antico5 / guard_rspec.md
Created February 28, 2018 16:45
Guard RSpec
group :development do
  gem 'guard-rspec', require: false
end

bundle exec guard init rspec

guard

@antico5
antico5 / group_select_example.rb
Created February 27, 2018 14:58
Select count having
User.select('sales_person_id, COUNT(1) as us_count').group(:sales_person_id).having('COUNT(1) > 1')
class ApplicationRecord
def self.group_having(field, count)
select("#{field}, COUNT(1) as count").group(field).having("COUNT(1) > #{count}")
end
end
@antico5
antico5 / install_postgis.md
Last active May 22, 2018 13:51
Install postgis

gem 'activerecord-postgis-adapter'

bundle install

# database.yml
development:
  adapter: postgis
  encoding: unicode
 postgis_extension: postgis # default is postgis
@antico5
antico5 / Copy heroku database.md
Last active February 27, 2018 15:00
Copy heroku database between different apps

heroku pg:copy app_from::DATABASE_URL DATABASE_URL --app app_to

0x1D66E3e60aA606c6912abC93674fEdfB41CbfA42
@antico5
antico5 / rails gmail
Created May 29, 2017 14:13
rails gmail
http://www.google.com/accounts/DisplayUnlockCaptcha
https://www.google.com/settings/security/lesssecureapps
@antico5
antico5 / Capybara.md
Created April 7, 2017 15:53 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@antico5
antico5 / unicorn guide.md
Last active March 20, 2017 17:05
unicorn config

Install unicorn gem

  gem 'unicorn'

Make config/unicorn.rb

# set path to application
app_dir = File.expand_path("../..", __FILE__)
upstream project {
server 22.22.22.2:3000;
server 22.22.22.3:3000;
server 22.22.22.5:3000;
}
server {
listen 80;
location / {
@antico5
antico5 / time_travel.rb
Created January 3, 2017 14:24
time travel
require 'rails_helper'
include ActiveSupport::Testing::TimeHelpers
describe TimeTravel do
it 'allows person to answer after 1 day' do
expect(person_can_answer).to be_falsey
# About to go to the future
travel(1.day) do
# While in the future
expect(person_can_answer).to be_truthy