This file contains 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 = [] |
This file contains 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 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 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 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 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 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 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 | |
def deep_slice(*allowed_keys) | |
sliced = { } | |
allowed_keys.each do |allowed_key| | |
if allowed_key.is_a?(Hash) | |
key = allowed_key.keys.first | |
sliced[key] = self[key].deep_slice(*[allowed_key.values].flatten) if self[key] | |
else | |
sliced[allowed_key] = self[allowed_key] if self[allowed_key] |
This file contains 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
module Foo | |
def hello | |
puts 'foo' | |
end | |
end | |
module Bar | |
def hello | |
puts 'bar' | |
end |
This file contains 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
vagrant@jun-group:~/player$ rails s torquebox | |
=> Booting TorqueBox | |
=> Rails 3.2.18 application starting in development on http://0.0.0.0:3000 | |
=> Call with -d to detach | |
=> Ctrl-C to shutdown server | |
Exiting | |
NameError: missing class or uppercase package name (`com.jungroup.player.geocoding.ZipcodeTranslator') | |
get_proxy_or_package_under_package at org/jruby/javasupport/JavaUtilities.java:54 | |
method_missing at file:/home/vagrant/.rvm/rubies/jruby-1.7.8/lib/jruby.jar!/jruby/java/java_package_module_template.rb:14 | |
(root) at /home/vagrant/player/lib/geo_code.rb:7 |
OlderNewer