This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def bar | |
baz = 'something' | |
baz + what_with_context(:something) | |
end | |
end | |
module Wat | |
def what_with_context(id) | |
instance_exec(&Huh.some_method) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Hash | |
# Accessing deep hash values. For example, given this hash: | |
# h = {:a => {:b => :c}} | |
# h.dig(:a, :b) | |
# => :c | |
# h.dig(:x, :y, :z) | |
# => nil | |
def dig(*path) | |
first, tail = path[0], path[1..-1] | |
node = self[first] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources :objects do | |
put :publish, :on => :member | |
end | |
before_filter :load_object | |
def update | |
@object.update_attributes!(params[:object]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require_relative '../test_helper' | |
class ${1:Model}sControllerTest < ActionController::TestCase | |
def setup | |
@${1/./\l$0/} = ${1/./\l$0/}s(:default) | |
end | |
def test_get_index | |
get :index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ${1:Model}sController < ApplicationController | |
before_action :build_${1/./\l$0/}, only: [:new, :create] | |
before_action :load_${1/./\l$0/}, only: [:show, :edit, :update, :destroy] | |
def index | |
@${1/./\l$0/}s = ${1:Model}.page(params[:page]) | |
end | |
def show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'oauth' | |
require 'oauth/signature/plaintext' | |
c = OAuth::Consumer.new( | |
'account_name', 'oath_secret', { | |
:http_method => :post, | |
:scheme => :query_string, | |
:signature_method => 'PLAINTEXT', | |
:oauth_callback => 'oob', | |
:site => 'https://testingtesting0123.freshbooks.com', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
require 'pp' | |
doc = Nokogiri::HTML(open('http://www.ibao.org/html/find_a_broker/mapfind.asp?tcode=13')) | |
out = [] |
NewerOlder