Skip to content

Instantly share code, notes, and snippets.

View luisguzman02's full-sized avatar
🎯
Focusing

Luis luisguzman02

🎯
Focusing
View GitHub Profile

Capybara

save_and_open_page

Matchers

have_button(locator)

Game of Life

An implementation of Conway's Game of Life in 140 characters of Ruby.

Author

Created by Simon Ernst (@sier).

@luisguzman02
luisguzman02 / cors-nginx.conf
Last active August 26, 2015 23:35 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@luisguzman02
luisguzman02 / how_to_concerns.md
Created November 3, 2015 01:05 — forked from jhjguxin/how_to_concerns.md
how to concerns with rails 3
@luisguzman02
luisguzman02 / states_matcher.rb
Created January 6, 2016 21:58 — forked from ka8725/states_matcher.rb
Custom matcher for Rspec to test state_machine status flow
# This custom matcher can be used to test state machine
#
# Examples
#
# it { should have_event(:status, :event_name, [:state1, :state2] => [:state3, :state4]) }
# it { should have_event(:status, :event_name, {
# :state1 => :state3,
# :state1 => :state4,
# :state3 => :state3,
# :state2 => :state4
@luisguzman02
luisguzman02 / db.rake
Created May 4, 2016 23:30 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
@luisguzman02
luisguzman02 / user.rb
Created August 2, 2016 07:44 — forked from harlow/user.rb
Extract a validator in Rails. Zip code validation.
# app/models/user.rb
class User < ActiveRecord::Base
validates :zip_code, presence: true, zip_code: true
end
@luisguzman02
luisguzman02 / gist:a1bc2b7e602e1c408bbe6a0a561b7bbf
Created November 18, 2016 22:06 — forked from chrissimpkins/gist:5bf5686bae86b8129bee
Atom Editor Cheat Sheet (Sweetmeat)

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on Mac OSX.

Key to the Keys

  • ⌘ : Command key
  • βŒƒ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • β†’ : Right arrow key
  • ↑ : Up arrow key
@luisguzman02
luisguzman02 / gist:db8e94520195b3dc9f4ff499d2fd615a
Created January 25, 2017 17:33 — forked from mudge/gist:428455
Namespaces with Nokogiri::Builder
# Dealing with namespaces in Nokogiri.
#
# First thing you must do is abandon what you're used to with Builder,
# namespaces aren't just attributes on an element, they uniquely identify
# what sort of element you are building and, as such, you are better off
# specifying them manually.
#
# The key here is accessing the Nokogiri::XML::Element being built with
# b.parent, then you can set the namespace (distinguished by an element
# with a prefix such as "soap12:Envelope") or add a default namespace