Skip to content

Instantly share code, notes, and snippets.

View hmsk's full-sized avatar
🍺
Now Brewing

Kengo Hamasaki hmsk

🍺
Now Brewing
View GitHub Profile
@rud
rud / watchr-runner.rb
Created February 8, 2010 14:17
watchr for rspec
if __FILE__ == $0
puts "Run with: watchr #{__FILE__}. \n\nRequired gems: watchr rev"
exit 1
end
# --------------------------------------------------
# Convenience Methods
# --------------------------------------------------
def run(cmd)
puts(cmd)
# Monkeypatch to disable connection pooling in ActiveRecord
module ActiveRecord
module ConnectionAdapters
class ConnectionPool
def checkout
c = ActiveRecord::Base.send(spec.adapter_method, spec.config.dup)
c.verify!
c
end
@deplorableword
deplorableword / varnish.rb
Created October 20, 2010 08:53
Install varnish 2.0.6 via Brew on Snow Leopard
require 'formula'
class Varnish <Formula
url 'http://downloads.sourceforge.net/project/varnish/varnish/2.0.6/varnish-2.0.6.tar.gz'
homepage 'http://varnish.projects.linpro.no/'
md5 'd91dc21c636db61c69b5e8f061c5bb95'
depends_on 'pkg-config' => :build
depends_on 'pcre'
#!/usr/bin/env perl
use strict;
use warnings;
use Pod::Usage;
use Text::Markdown 'markdown';
use HTML::TreeBuilder;
use List::Util 'max';
@riywo
riywo / gist:836630
Created February 21, 2011 03:41
指定秒間だけtcpdumpしてmk-query-digestするshell
#!/bin/sh
SEC=$1
tcpdump -s 65535 -nn -q -tttt -x port 3306 -l > /tmp/tcpdump.3306 2> /dev/null &
PID_3306=$!
tcpdump -s 65535 -nn -q -tttt -x port 11211 -l > /tmp/tcpdump.11211 2> /dev/null &
PID_11211=$!
@tricknotes
tricknotes / compile-haml.watchr.rb
Created October 16, 2011 13:32
Hamlをコンパイルするwatchr
require "open3"
watch('(.*)\.haml') do |md|
stdin, stdout, stderr = Open3.popen3("haml #{md[0]}")
error_message = ''
unless stderr.eof?
error_message << stderr.to_a.join
end
@sowawa
sowawa / .recipe
Created April 28, 2012 03:45
Installing rails 4.0.0 beta
thumbnail: http://pds.exblog.jp/pds/1/201101/16/02/d0055302_13383029.jpg
video: http://www.youtube.com/watch?v=UE27t_LJpx0
@melborne
melborne / Plugins.textile
Created May 9, 2012 11:54
Translation of Jekyll Plugins

https://github.com/mojombo/jekyll/wiki/Plugins

Jekyllプラグインシステムのフックは、あなたのサイト向けに特化したコンテンツの生成を可能にします。Jekyllのソースを修正することなく、あなたのサイト用のコードを実行できます。

The Jekyll plugin system hooks allow you to create custom generated content specific to your site. You can run custom code for your site without having to modify the Jekyll source itself.

プラグインのインストール

h2. Installing a plugin

@chuckbjones
chuckbjones / deploy.rb
Created August 22, 2012 07:51
Generate static html files at deploy time in Rails 3.x
# define a method to run rake tasks
def run_rake(task, options={}, &block)
rake = fetch(:rake, 'rake')
rails_env = fetch(:rails_env, 'production')
command = "cd #{current_path} && #{rake} #{task} RAILS_ENV=#{rails_env}"
run(command, options, &block)
end
@sorah
sorah / spec_helper.rb
Created December 17, 2012 01:34
Show warnings for examples that has no expectations
RSpec.configure do |config|
config.after(:each) do
result = self.example.metadata[:execution_result]
has_mock_expectations = RSpec::Mocks.space.instance_eval{receivers}.empty?
if !result[:exception] && !result[:pending_message] && !RSpec::Matchers.last_should && hasnt_mock_expectations
$stderr.puts "[WARN] No expectations found in example at #{self.example.location}: Maybe you forgot to write `should` in the example?"
end
end
end