Skip to content

Instantly share code, notes, and snippets.

NoMethodError:
undefined method `content' for "foo=bar&hoge=piyo":String
# /home/hudson/.rvm/gems/ruby-1.9.2-p0@platform/gems/webmock-1.6.2/lib/webmock/http_lib_adapters/httpclient.rb:122:in `build_request_signature'
# /home/hudson/.rvm/gems/ruby-1.9.2-p0@platform/gems/webmock-1.6.2/lib/webmock/http_lib_adapters/httpclient.rb:14:in `do_get_with_webmock'
# /home/hudson/.rvm/gems/ruby-1.9.2-p0@platform/gems/webmock-1.6.2/lib/webmock/http_lib_adapters/httpclient.rb:6:in `do_get_block_with_webmock'
# /home/hudson/.rvm/gems/ruby-1.9.2-p0@platform/bundler/gems/httpclient-ff7c779fe301/lib/httpclient.rb:850:in `block in do_request'
# /home/hudson/.rvm/gems/ruby-1.9.2-p0@platform/bundler/gems/httpclient-ff7c779fe301/lib/httpclient.rb:937:in `protect_keep_alive_disconnected'
# /home/hudson/.rvm/gems/ruby-1.9.2-p0@platform/bundler/gems/httpclient-ff7c779fe301/lib/httpclient.rb:849:in `do_request'
# /home/hudson/.rvm/gems/ruby-1.9.2-p0@platform/bundler/gems/httpclient-ff7c77
@skuroki
skuroki / install_rvm.sh
Created July 26, 2011 12:29
rvm install script for ubuntu
sudo apt-get install -y \
build-essential \
openssl \
libreadline6 \
libreadline6-dev \
curl \
git-core \
zlib1g \
zlib1g-dev \
libssl-dev \
@skuroki
skuroki / watchr-runner.rb
Created November 2, 2011 09:19 — forked from rud/watchr-runner.rb
watchr for rspec
def run(cmd)
puts(cmd)
system(cmd)
puts 'Finished. ' + Time.now.to_s
end
def run_single_spec (*spec)
spec = spec.join(' ')
run "rspec -bX #{spec}"
end
@skuroki
skuroki / gist:2857051
Created June 2, 2012 06:59
Think about stable sort in ruby(1.9.3)
[10] pry(main)> [[10, 120], [20, 190], [10, 110], [20, 220], [10, 130], [20, 180]].sort_by(&:first)
=> [[10, 120], [10, 130], [10, 110], [20, 220], [20, 190], [20, 180]]
[12] pry(main)> [[10, 120], [20, 190], [10, 110], [20, 220], [10, 130], [20, 180]].each.with_index.sort_by { |a, i| [a.first, i] }
=> [[[10, 120], 0],
[[10, 110], 2],
[[10, 130], 4],
[[20, 190], 1],
[[20, 220], 3],
[[20, 180], 5]]
@skuroki
skuroki / crawler.rb
Created December 6, 2012 12:12
2ch crawler
# coding: utf-8
require 'nokogiri'
require 'mongo'
require 'open-uri'
require 'pp'
def extract_threads
l = open('http://hayabusa3.2ch.net/appli/subback.html').read.force_encoding('cp932').encode('utf-8')
n = Nokogiri::HTML.parse(l)
n.css('#trad a').select { |node| node.children[0].to_s =~ /.*スレ/ }.map { |node| node['href'].split('/')[0].to_i }
@skuroki
skuroki / .projection.json
Last active August 29, 2015 14:05
rails.vimからrailsへの依存をなくしたprojectionist.vimを(railsで)使ってみた ref: http://qiita.com/skuroki@github/items/c65b56c65a39f8e3ba22
{
"app/admin/*.rb": { "alternate": ["spec/features/admin/{}_spec.rb", "spec/features/admin/{plural}_spec.rb"], "type": "admin" },
"app/controllers/*_controller.rb": { "alternate": "spec/controllers/{}_controller_spec.rb", "type": "controller" },
"app/decorators/*_decorator.rb": { "alternate": "spec/decorators/{}_decorator_spec.rb", "type": "decorator" },
"app/helpers/*_helper.rb": { "alternate": "spec/helpers/{}_helper_spec.rb", "type": "helper" },
"app/mailers/*_mailer.rb": { "alternate": "spec/mailers/{}_mailer_spec.rb", "type": "mailer" },
"app/models/*.rb": { "alternate": "spec/models/{}_spec.rb", "type": "model" },
"app/workers/*.rb": { "alternate": "spec/workers/{}_spec.rb", "type": "worker" }
}
@skuroki
skuroki / file0.txt
Last active August 29, 2015 14:15
ActiveAdminのtable_forに渡したcollectionが勝手にdecorateされるようにする ref: http://qiita.com/skuroki@github/items/bcc99e456463901e44fa
module TableDecoration
def build(obj, *attrs)
ActiveDecorator::Decorator.instance.decorate(obj)
super(obj, *attrs)
end
end
module ActiveAdmin
module Views
class TableFor < Arbre::HTML::Table
@skuroki
skuroki / file0.txt
Last active August 29, 2015 14:17
ActiveDecoratorでdecorateしたオブジェクトのhas_one/belong_to先のオブジェクトが自動でdecorateされるようにする ref: http://qiita.com/skuroki@github/items/087e0953583d259738a5
module AssociationDecorator
def reader(*args)
result = super
if self.owner.is_a?(ActiveDecorator::Helpers)
ActiveDecorator::Decorator.instance.decorate(result)
end
result
end
end
@skuroki
skuroki / active_admin_menus.rb
Last active November 22, 2016 05:24
ActiveAdminでメニューの並び順を1箇所で管理する ref: http://qiita.com/skuroki@github/items/0a9db8a9e58f55202040
MENU_ITEMS = [
[:item, 'Dashboard', {label: proc{ I18n.t("active_admin.dashboard") }}],
[:item, 'Item', {}],
[:item, 'Skill', {label: '特技検索'}],
[:item, 'Evolution', {label: '進化検索'}],
[:category, 'master',
[
['Element', {}],
['BoxKind', {}],
]
@skuroki
skuroki / base.rb
Last active August 29, 2015 14:21
ActiveAdminで各ページ共通でレイアウトの構成要素をいじる ref: http://qiita.com/skuroki@github/items/c5fce4b45a2d1a4a4bca
module ActiveAdmin
module Views
module Pages
class Base
def build_main_content_wrapper
div id: "main_content_wrapper" do
div id: "main_content" do
para <<-'EOS'.html_safe
<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>