Skip to content

Instantly share code, notes, and snippets.

View rodrei's full-sized avatar

Rodrigo Pavano rodrei

  • Mendoza, Argentina
View GitHub Profile
@rodrei
rodrei / gist:2777467
Created May 23, 2012 20:10
Calls are being deleted
# e is a Google::Event with valid phone_numbers
irb(main):011:0> e.create_call_from_attrs
RESQUE SCHEDULED: Call 4fbd42c46eee0c0007000002 at 2012-05-31 17:53:00 UTC
=> #<Call _id: 4fbd42c46eee0c0007000002, _type: nil, created_at: 2012-05-23 20:04:20 UTC, updated_at: 2012-05-23 20:04:20 UTC, deleted_at: nil, google_event_id: BSON::ObjectId('4fbd35802697550007000003'), bridge_number: "6193262700", pin: "4031741", starts_at: 2012-05-31 17:53:00 UTC, ends_at: 2012-05-31 18:53:00 UTC, state: "scheduled", user_id: BSON::ObjectId('4f8f0e44f67a78000a00000a'), provider_id: BSON::ObjectId('4f8ce23a011b4d0007000002')>
irb(main):012:0> e.call
=> #<Call _id: 4fbd42c46eee0c0007000002, _type: nil, created_at: 2012-05-23 20:04:20 UTC, updated_at: 2012-05-23 20:04:20 UTC, deleted_at: nil, google_event_id: BSON::ObjectId('4fbd35802697550007000003'), bridge_number: "6193262700", pin: "4031741", starts_at: 2012-05-31 17:53:00 UTC, ends_at: 2012-05-31 18:53:00 UTC, state: "scheduled", user_id: BSON::ObjectId('4f8f0e44f67a78000a00
num = Math.abs(num)
// Java code
num = -1234
positive = num.abs
# => 1234
@rodrei
rodrei / FlatteableHash
Created July 12, 2011 17:56
Hash class with flatten method added
class FlatteableHash
def flatten(ancestor_names = [])
flat_hash = {}
each do |key, value|
names = Array.new(ancestor_names)
names << key
if value.is_a?(Hash)
value = FlatteableHash.new(value)
@rodrei
rodrei / .janus.rake
Created June 17, 2011 23:10
Personal .janus.rake file
vim_plugin_task "unimpaired", "git://github.com/tpope/vim-unimpaired.git"
@rodrei
rodrei / .vimrc
Created June 17, 2011 23:09
Personal .vimrc
" UNIMPAIRED PLUGIN
" Bubble single lines
nmap <C-k> [e
nmap <C-j> ]e
" Bubble multiple lines
vmap <C-k> [egv
vmap <C-j> ]egv
RAML API design
Monads and Ruby http://codon.com/refactoring-ruby-with-monads
Book: understanding computation, Tom Stuart
Seccasts screencasts: https://www.seccasts.com/mror/
Elixir Sips: http://elixirsips.com/
Coursera, Programming Languages: https://www.coursera.org/course/proglang
Codetriage.com
Docdoctor
Rblibeprof
http://www.procode.org/stgit/ stack git
@rodrei
rodrei / rails_app.md
Last active August 29, 2015 14:07
Exercise

App to manage a blog.

The interface will be a JSON API. Please follow http://jsonapi.org/ standard.

There are users, blog posts and comments. A user can own many blog posts, and a blog post can have many comments.

  • Users should be able to sign up, and log in.

  • POST /sign_up will receive an email and password params and will create a new User. The email param must be a valid email address and the password must be at least 8 chars long.

<?php
// Model
class Province
{
public $name;
public $id;
public function __construct($name, $id) {
$this->name = $name;
$this->id = $id;

Uniform Access Principle

All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation

Bertrand Meyer

/*
* Creates a new object that uses the old object as its prototype
* From: Javascript: the Good Parts
*/
if (typeof Object.create !== 'function') {
Object.create = function (o) {
var F = function () {};
F.prototype = o;
return new F();
};