Skip to content

Instantly share code, notes, and snippets.

View hotchpotch's full-sized avatar

Yuichi Tateno (secon) hotchpotch

View GitHub Profile
@hotchpotch
hotchpotch / elasticsearch.rb
Last active December 14, 2015 18:59
elasticsearch homebrew formula 0.90.0.Beta1
require 'formula'
class Elasticsearch < Formula
homepage 'http://www.elasticsearch.org'
url 'https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.0.Beta1.tar.gz'
sha1 'b2c7381368f8df57d10ce5fa18f55876d5d8969d'
head 'https://github.com/elasticsearch/elasticsearch.git'
depends_on 'maven' if build.head?
#!/usr/bin/env ruby
require 'msgpack'
require 'pp'
while gets
line = $_.strip
begin
pp MessagePack.unpack(line)
rescue EOFError => e
#!/usr/bin/env ruby
require 'capybara-webkit' # '~> 0.14.0'
require 'optparse'
require 'cgi'
options = {}
OptionParser.new do |opt_parser|
opt_parser.on('-O filename') {|value| options[:filename] = value }
def destroy_all(conditions = nil)
if conditions
where(conditions).destroy_all
else
to_a.each {|object| object.destroy }.tap { reset }
end
end
source :forward
source(:http) {
port '8889'
}
foo_path = '/tmp/foo.log'
match(:file, 'heartbeat.**') {
path foo_path
require 'timecop'
module ActiveRecordDetectTimeInScopes
extend ActiveSupport::Concern
module ClassMethods
def scope(*args)
scope_caller = caller
Timecop.travel(Time.now) do
Timecop.top_stack_item.define_singleton_method :time do
@hotchpotch
hotchpotch / hatenaone.css
Created March 13, 2012 22:34
Hatena One !!!!!!!!!
li.entry:not(.haiku2_default_text) {
display:none;
}
li.entry.one_comment {
display:block;
}
body {
min-height: 2000px;
@hotchpotch
hotchpotch / gist:1996817
Created March 7, 2012 22:42
bundler benchmark
$ time ruby -S bundle _1.0.22_ exec ruby -e ''
ruby -S bundle _1.0.22_ exec ruby -e '' 1.50s user 0.25s system 95% cpu 1.829 total
$ time ruby -S bundle _1.1.0_ exec ruby -e ''
ruby -S bundle _1.1.0_ exec ruby -e '' 1.09s user 0.21s system 94% cpu 1.388 total
@hotchpotch
hotchpotch / photozou_scraper.rb
Created March 5, 2012 22:12
Photozou Scraper
#!/usr/bin/env ruby
require 'digest/sha1'
require 'pathname'
require 'open-uri'
require 'uri'
require 'nokogiri'
module PhotozouScraper
PHOTOZOU_URL = 'http://photozou.jp'
@hotchpotch
hotchpotch / .pryrc
Created March 5, 2012 13:26
pry clipboard copy utility
def pbcopy(str)
IO.popen('pbcopy', 'r+') {|io| io.puts str }
output.puts "-- Copy to clipboard --\n#{str}"
end
Pry.config.commands.command "hiscopy", "History copy to clipboard" do |n|
pbcopy _pry_.input_array[n ? n.to_i : -1]
end
Pry.config.commands.command "copy", "Copy to clipboard" do |str|