Skip to content

Instantly share code, notes, and snippets.

View rks's full-sized avatar

Randy Souza rks

View GitHub Profile
require 'json'
require 'octokit'
require 'time'
def log
file = './github_api_latest_release.json'
File.open(file, 'a+') { |f| f << yield }
end
@rks
rks / html.md
Last active April 27, 2021 17:01

All the HTML elements

An HTML element
class Thing
if ENV['DEFINE_NESTED_CLASS']
class SpecificThing
def identify
'nested'
end
end
end
end
@rks
rks / gist:2577339
Created May 2, 2012 15:12
Wrapping exceptions in Ruby
class CustomError < StandardError
def initialize(e = nil)
super e
set_backtrace e.backtrace if e
end
end
def run
r = Runner.new
r.fail
class ThingsController < ApplicationController
respond_to :html, :json
before_filter { @thing = {one: 1, two: 2} }
# /things/a -> renders template at things/a.html.erb
# /things/a.json -> renders @thing.to_json
def a
respond_with @thing
end
@rks
rks / gist:34437
Created December 10, 2008 18:51
RSpec routing trouble
# Using Rails 2.2.2 and RSpec + RSpec-Rails 1.1.11,
#
# The specs below all pass when I run:
# $ ./script/spec spec/controllers/admin/status_controller_spec.rb
#
# But when I run:
# $ rake spec
# all three fail with:
#
# 1)