Skip to content

Instantly share code, notes, and snippets.

@henrik
henrik / hash_deep_diff.rb
Created July 14, 2009 08:38
Recursively diff two Ruby hashes.
# Recursively diff two hashes, showing only the differing values.
# By Henrik Nyh <http://henrik.nyh.se> 2009-07-14 under the MIT license.
#
# Example:
#
# a = {
# "same" => "same",
# "diff" => "a",
# "only a" => "a",
# "nest" => {
;; need Revision 1.178 2009/04/20 16:18:58 or higher
(setq anything-display-function
(lambda (b)
(delete-other-windows)
(split-window-horizontally)
(pop-to-buffer b)))
@uasi
uasi / gist:214109
Last active September 11, 2015 03:06
Show branch name in Zsh's right prompt
#
# Show branch name in Zsh's right prompt
#
autoload -Uz VCS_INFO_get_data_git; VCS_INFO_get_data_git 2> /dev/null
setopt prompt_subst
function rprompt-git-current-branch {
local name st color gitdir action
# Drop this file in config/initializers to run your Rails project on Ruby 1.9.
# This is three separate monkey patches -- see comments in code below for the source of each.
# None of them are original to me, I just put them in one file for easily dropping into my Rails projects.
# Also see original sources for pros and cons of each patch. Most notably, the MySQL patch just assumes
# that everything in your database is stored as UTF-8. This was true for me, and there's a good chance it's
# true for you too, in which case this is a quick, practical solution to get you up and running on Ruby 1.9.
#
# Andre Lewis 1/2010
# encoding: utf-8
@miyagawa
miyagawa / gitweb.psgi
Created March 27, 2010 13:54
Running gitweb.cgi on Plack
# 1. Download git and make gitweb/gitweb.cgi (See gitweb/INSTALL how to set gitweb root etc.)
# 2. Copy this file as gitweb/app.psgi
# 3. cd gitweb; plackup
# 4. Access http://localhost:3000/gitweb.cgi
use Plack::Builder;
use Plack::App::WrapCGI;
use Plack::App::File;
builder {
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
落書きの報告書 Twitterばかりしてる俺
超高速でビルドするけど 動かないVirtual Machine
やさしくないJavaの本ページ破りたい
Chromeの裏 2ちゃんを覗いて見つかれば逃げ場もない
座って固まり 目を伏せながら
心のひとつも解りあえないプログラムをにらむ
そして仲間たちは今夜辞職の計画をたてる
とにかくもう 会社や家には帰りたくない
自分の業務が何なのかさえ 解らず震えている
25の夜
あたし大卒やのにね 仕事をもらわれへんのやと書いた
マスターの手紙の文字は とがりながらふるえている
ヲタのくせにと足を切られ 学生たちの眼が年をとる
虚しさを握りしめ過ぎた 日々の中夢が崩れ去る
私 本当は目撃したんです 昨日大手企業の 面接で
五秒で落ちたヲタクと 学歴だけで受かった奴らの薄笑い
私 驚いてしまって 助けもせず叫びもしなかった
ただ恐くて逃げました 私の敵は すべてです
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
if Rails.version == '2.3.8' && Gem.available?('mongrel', Gem::Requirement.new('~>1.1.5')) && self.class.const_defined?(:Mongrel)
# Pulled right from latest rack. Old looked like this in 1.1.0 version.
#
# def [](k)
# super(@names[k] ||= @names[k.downcase])
# end
#
module Rack