Skip to content

Instantly share code, notes, and snippets.

View amedrz's full-sized avatar

Amed Rodriguez amedrz

  • British Columbia, Canada
View GitHub Profile
# models/organization.rb
Class Organization < ActiveRecord::Base
has_many :sharegroups, :foreign_key => "host_organization_id"
has_many :inverse_sharegroups, :class_name => "Sharegroup", :foreign_key => "guest_organization_id"
has_many :direct_organizations, :through => :sharegroups, :source => :guest_organization
has_many :inverse_organizations, :through => :inverse_sharegroups, :source => :host_organization
def organizations
direct_organizations | inverse_organizations
@amedrz
amedrz / key_events_with_jquery.js
Created April 5, 2011 16:47
key events with jQuery.
$(document).ready(function(){
$(document).keydown(function(event){
switch(event.which){
case 13:
alert("enter");
break;
case 39:
alert("right-arrow");
break;
case 37:
@amedrz
amedrz / rbenv.md
Created May 9, 2012 19:44
Installing rbenv on Mac OS X

Basic GitHub Checkout

This will get you going with the latest version of rbenv and make it easy to fork and contribute any changes back upstream.

  1. Check out rbenv into ~/.rbenv.

     $ cd
     $ git clone git://github.com/sstephenson/rbenv.git .rbenv
    
@amedrz
amedrz / gist:3933285
Last active October 11, 2015 22:58
README template

Project dependencies

Specify app's low-level dependencies and its versions, e.g. Ruby, Rails, Spree, RefineryCMS, Node.js...

Setup Development Environment

Specify all the necessary steps to successful setup the app in a development machine.

Such steps would include how to:

@amedrz
amedrz / gist:4151646
Last active October 13, 2015 06:08
Web App Exercise

Restaurants Management Platform

Description

You will create a Ruby on Rails app with an admin interface from where logged in users would be able to list, create, edit and delete restaurants.

Please use your own judgment to build the appropiate database structure and models relationships. In the same way, feel free to use any gem that would help you to DRY.

We are interested in evaluating the approach/process you take to build this app in all the involved aspects (management, concept, development, deployment) as well as the best practices applied using technologies such as Ruby, Rails, Git etc.

MongoMapper::Railtie.class_eval do
config.action_dispatch.rescue_responses.merge!(
'MongoMapper::DocumentNotFound' => :not_found
)
end
@amedrz
amedrz / hbd.rb
Created April 23, 2013 15:35
Happy Birthday Tellez
class Tellez
def self.birthday?
Time.now.day == 23 && Time.now.month == 4
end
end
puts "Happy B-day Téllez!" if Tellez.birthday?
@amedrz
amedrz / page-object-before.js
Last active October 9, 2015 16:42
page-object-before
// Before page object
test('sign up', function() {
expect(1);
visit('/sign-up');
fillIn('#signup-form #name', 'John Doe');
fillIn('#signup-form #email', 'john@doe.com');
fillIn('#signup-form #password', '1234567890');
click('#signup-form #submit');
@amedrz
amedrz / page-object-after.js
Created October 6, 2015 15:59
page-object-after
// After page object
const pageObject = PO.build({
visit: PO.visitable('/sign-up'),
name: PO.fillable('#signup-form #name'),
email: PO.fillable('#signup-form #email'),
password: PO.fillable('#signup-form #password'),
submit: PO.clickable('#signup-form #submit')
});
test('sign up', function() {
@amedrz
amedrz / using-data-attrs.js
Last active October 7, 2015 20:53
using-data-attrs
/**
Markup example:
<label for="name">Name</label>
<input id="name" type="text" data-tests="signup-name"/>
...
**/
const pageObject = PO.build({
visit: PO.visitable('/sign-up'),
name: PO.fillable('[data-tests="signup-name"]'),