Skip to content

Instantly share code, notes, and snippets.

View ivanacostarubio's full-sized avatar
💭
⚡️accelerating

Ivan ivanacostarubio

💭
⚡️accelerating
View GitHub Profile
class Lead
@@filter_options = ["followup","skype", "documents", "estimate"]
@@all_options = ["followup","skype", "documents", "won", "lost", "estimate"]
validates :status, :inclusion => { :in => @@all_options}
validates_presence_of :status, :name_project, :name_client, :url_project
@ivanacostarubio
ivanacostarubio / gist:3764890
Created September 22, 2012 02:23
Newton's Square Root Approximation
def abs(x)
(x < 0) ? -x : x
end
def sqrtIter(guess, x)
isGoodEnough(guess,x) ? guess : sqrtIter( improve(guess,x) ,x)
end
def isGoodEnough(guess,x)
@ivanacostarubio
ivanacostarubio / Gemfile
Created September 24, 2012 23:14
ICANHAZTYPOS
source :rubygems
gem 'levenshtein-ffi', :require => 'levenshtein'
gem "rspec"
@ivanacostarubio
ivanacostarubio / play.rb
Created October 2, 2012 15:08
Higher Order Function in Ruby
#
# Intro to Higher Order Functions
#
# translated to Ruby from Martin Scala Coursera.org class
#
def cube(n)
n ** n
end
require 'rr'
class CrazyMath
def self.fib(n)
if n < 3
1
else
CrazyMath.fib(n - 1) + CrazyMath.fib(n - 2)
end
end
module MotionModel
module Model
def save(*)
puts "called MM#save"
end
end
end
module MotionModel
module Paranoid
####################
# Multi App Dynos
####################
Recently @hirodusk tweeted - http://cl.ly/image/2s1X0E351v29 - about a prototype they've been working on to bring visibility to their dynos idling behavior. He got me thinking.
What about if we can have a different Dyno that can be share between apps? So far, I've been able to acomplish something similar to this by having a bunch of different sinatra apps and mapping them to different URLS. All this under the same Git repo and Heroku app. This approach is all good if all the sinatra apps are related somehow, but it brakes if they apps are unrelated because you don't want them all in the same repository.
I would love to pay Heroku for 5 Dynos and have them serve 10 different apps.
# BEFORE
orange_button({:action => :buton_action, :text => "GET MY IDEAL BODY WEIGHT", :size => CGRectMake(10, 240, 300, 46), :font => {:size => 33, :color => uicolor_white, :family => "BebasNeue"}})
# AFTER
orange_button do |b|
b.action = :button_action
b.text = "GET MY IDEAL BODY WEIGHT"
@ivanacostarubio
ivanacostarubio / when_to_use_ exceptions.text
Created February 26, 2013 19:35
When to use exceptions
-----------------------------------------------------------------------------------------------------------------------
Michael Feathers wrote on Ruby Parley:
I still like Bertrand Meyer's advice on exceptions: use them when you
can't tell before a call whether it will succeed or not.
That said, there are alternatives. You can pass two actions to a
method, one of which is called when it succeeds and the other when it
########################
me:
########################
Hi! This is Ivan. One of the founders of MealsApp.com I noticed you have recorded a lot of meals and I am wondering: - What don't you like and what do you like about the app? - What would you like to see in the app so that it is awesome? Thank you very very very very much for replying to this email. It'll help us create the best app for nutrition. Bon Appetit
########################