Skip to content

Instantly share code, notes, and snippets.

View novohispano's full-sized avatar

Jorge Téllez novohispano

View GitHub Profile
module ObjectCreationMethods
def new_ci_source(overrides = {})
defaults = {name: "testrepo", owner: "blairtest", active:false}
CiSource.new(defaults.merge(overrides))
end
def create_ci_source(overrides = {})
ci_source = new_ci_source(overrides)
require 'minitest/autorun'
require 'minitest/pride'
require_relative 'beer_song'
class BeerSongTest < MiniTest::Unit::TestCase
def beer_song
@beer_song = ::BeerSong.new
end
class BeerSong
def verses(beginning, ending = 0)
song = ""
beginning.downto(ending).each do |n|
song << verse(n) + "\n"
end
song
end
def verse(n)
class Centaur
attr_reader :name, :breed
def initialize(name, breed)
@name = name
@breed = breed
@standing = true
@actions = 0
end
class Phoenix
attr_reader :name, :age, :lives
def initialize(name)
@name = name
@age = 0
@alive = true
@lives = 1
end
exports.makeMeal = function (meal) {
return "Preparing " + meal
}
var serveDrink = function (drink) {
return "Serving " + drink
}
@novohispano
novohispano / routes.rb
Last active August 29, 2015 14:11
Multitenant Blogger Advanced.
# Original Router
Rails.application.routes.draw do
resources :articles
resources :comments
resource :account, only: [:show] do
get :work
end
get '/login' => 'sessions#new'
@novohispano
novohispano / deploy.rake
Created January 26, 2015 17:01
Rake task for Heroku deployment.
namespace :deploy do
desc "Deploys app to Github & production."
task all: :environment do
if system("rake test:all") == false
puts "The tests fail."
break
end
puts "The tests passed."
@novohispano
novohispano / application_helper.rb
Created February 18, 2015 11:45
Caching in Rails
module ApplicationHelper
def cache_key_for(model)
prefix = model.to_s.downcase.pluralize
count = model.count
max_updated_at = model.maximum(:updated_at).try(:utc).try(:to_s, :number)
"#{prefix}/all-#{count}-#{max_updated_at}"
end
end
@novohispano
novohispano / application.yml
Last active August 29, 2015 14:16
Getting Started with OAuth
development:
github_key: 710899dd3710a6a9814e
github_secret: 102dc5253ae360eaae533e7dc5ceb46929dcbe4b