Skip to content

Instantly share code, notes, and snippets.

View hotchpotch's full-sized avatar
🏠
Working from home

Yuichi Tateno (secon) hotchpotch

🏠
Working from home
View GitHub Profile
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 / gist:1446423
Created December 8, 2011 08:01
Vim 抜けるときに screen のウィンドウ名を変える
autocmd VimLeave * silent! exe '!echo -n "^[kvim leave^[\\"'
From 8f33021b62c3716d153d8f1dbb7b403a300e8164 Mon Sep 17 00:00:00 2001
From: Yuichi Tateno <hotchpotch@gmail.com>
Date: Mon, 3 Oct 2011 16:51:19 +0900
Subject: [PATCH] OobGC: force GC.start
---
lib/unicorn/oob_gc.rb | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/lib/unicorn/oob_gc.rb b/lib/unicorn/oob_gc.rb
@hotchpotch
hotchpotch / gist:1113542
Created July 29, 2011 09:57
ChromeKeyConfig My Settings
{
"name": "Chrome Keyconfig",
"version": "1.11.0",
"normal_actions": {
"j": {
"name": "scroll down",
"args": []
},
"k": {
"name": "scroll up",