Skip to content

Instantly share code, notes, and snippets.

@wtnabe
wtnabe / gist:1451127
Created December 9, 2011 11:08
A typo of ruby-enterprise's spec file
--- ruby-enterprise.spec.orig 2011-08-12 01:07:59.000000000 +0900
+++ ruby-enterprise.spec 2011-12-09 19:38:47.000000000 +0900
@@ -87,7 +87,7 @@
%defattr(-,root,root)
%{_bindir}/*
%{_prefix}/lib/*
-%{_prefix}/share/man/man1/ruby.1
+%{_prefix}/share/man/man1/ruby.1.gz
%doc source/ChangeLog
%doc source/COPYING
@wtnabe
wtnabe / gist:1568178
Created January 6, 2012 00:25
kramdown list examples
$ echo '*abc' | kramdown
<p>*abc</p>
$ echo '* abc' | kramdown
<ul>
<li>abc</li>
</ul>
$ echo ' *abc' | kramdown
<p>*abc</p>
$ echo ' * abc' | kramdown
<ul>
@wtnabe
wtnabe / gist:1569788
Created January 6, 2012 08:59
this month's weekday array
(Date.parse('2012-01-01')..Date.parse('2012-01-31')).to_a.find_all { |d|
not d.sunday? and not d.saturday?
}.map { |d|
d.day
}
@wtnabe
wtnabe / interlaced.rake
Created January 31, 2012 03:51
rake task listing interlace images ( with identify command included in ImageMagick suite )
if system( 'which identify' )
desc 'list interlace images under current directory'
task :interlaced do
`find . -name '*.gif' -o -name '*.png' -o -name '*.jpg' -o -name '*.jpeg' |\
xargs identify -verbose | awk '/^Image:/ || /Interlace/'`.lines.each_slice(2) \
{ |e|
puts e unless e[1].include?( 'None' )
}
end
end
@wtnabe
wtnabe / Gemfile
Created February 5, 2012 02:06
rake tasks for creating and reviewing slides of showoff
# -*- mode: ruby -*-
source :rubygems
gem 'rake'
if RUBY_PLATFORM.include?( 'darwin' ) and
RUBY_PLATFORM.match(/[0-9.]+\z/).to_s.split('.').first.to_i < 10
gem 'guard', '< 0.9'
else
gem 'guard'
@wtnabe
wtnabe / git-commit-spreader.rb
Created February 29, 2012 14:09
spread each git commits to branches
#! /usr/bin/env ruby
i = 1
`git log --reverse --oneline`.lines.map { |commit|
commit.chomp.split(/\s+/).first
}.each { |ref|
system(sprintf("git branch %02d_%s %s", i, ref, ref))
i += 1
}
@wtnabe
wtnabe / jasmine-jquery.patch
Created April 19, 2012 08:16
jasmine-jquery.js's patch for jasmine gem
@@ -29,7 +29,7 @@
jasmine.Fixtures = function() {
this.containerId = 'jasmine-fixtures';
this.fixturesCache_ = {};
- this.fixturesPath = 'spec/javascripts/fixtures';
+ this.fixturesPath = '__spec__/fixtures';
};
jasmine.Fixtures.prototype.set = function(html) {
@wtnabe
wtnabe / Gemfile
Created April 20, 2012 07:57
minimal rspec-capybara-mechanize env
# -*- mode: ruby -*-
source :rubygems
gem 'rake'
gem 'rspec'
gem 'capybara', '< 2'
gem 'capybara-mechanize'
@wtnabe
wtnabe / mongo.rake
Created April 30, 2012 13:13
mongo task for rails ( put this task file as lib/tasks/mongo.rake )
# -*- mode: ruby -*-
include FileUtils::Verbose
@root = File.expand_path( File.dirname(__FILE__) + '/../../' )
namespace :mongo do
desc 'prepare'
task :prepare do
dbpath = "#{@root}/db/mongodb"
@wtnabe
wtnabe / cap_guard.rb
Created May 23, 2012 02:12
guard of wrong time deployment
require "open-uri"
NTP_SERVER = xxxx
ntp_time = Time.parse(URI("http://#{NTP_SERVER}").read.meta['date'])
local_time = Time.now
if ( (local_time.to_i - ntp_time.to_i).abs > 5 )
abort "Your machine is wrong !\nIs it #{local_time} now ?\n"
end