Skip to content

Instantly share code, notes, and snippets.

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

Shinichi Maeshima willnet

🏠
Working from home
View GitHub Profile
@willnet
willnet / emacs-install.sh
Last active December 11, 2015 11:08
how to install emacs on centos
./configure --without-toolkit-scroll-bars --without-xaw3d --without-compress-info --without-sound --without-pop --without-xpm --without-tiff --without-rsvg --without-gconf --without-gsettings --without-selinux --without-gpm --without-makeinfo --with-x
make
sudo make install
@willnet
willnet / stub_cookies.rb
Created February 6, 2013 01:41
stub cookies for unit test
class StubCookies < Hash
def [](name)
super(name.to_s)
end
def []=(key, options)
if options.is_a?(Hash)
options.symbolize_keys!
else
options = { :value => options }
@willnet
willnet / delete_logs_before_last_month.rb
Last active December 18, 2015 08:38
ruby script to delete old tomcat logs (e.g. 'catalina.2013-06-11.log') usage `./delete_logs_before_last_month.rb /path/to/catalina/logs_directory`
#!/usr/bin/env ruby
require 'pathname'
require 'date'
require 'fileutils'
path = ARGV.first
path_name = Pathname.new(path)
last_month = Date.today.prev_month
last_month_beginning_of_day = last_month.prev_day(last_month.day - 1)
@willnet
willnet / master.rb
Created June 11, 2013 08:27
god setting example
RAILS_ROOT = "/path/to/root"
God.watch do |w|
w.name = "solr"
w.interval = 30.seconds # default
w.dir = RAILS_ROOT
w.log = "#{RAILS_ROOT}/log/god.log"
w.env = { 'RAILS_ROOT' => RAILS_ROOT,
'RAILS_ENV' => "production",
'HOME' => '/root'}
@willnet
willnet / agg
Created June 17, 2013 11:40
ag wrapper script for make output like grep
#!/bin/sh
exec ag --silent --color --color-match '01;31' --nogroup "$@"
@willnet
willnet / postal_code.rb
Created July 6, 2013 06:24
tokyorubyistmeetupのペアプロ課題その1
# -*- coding: utf-8 -*-
require "csv"
module PostalCode
class << self
def sort
ary = CSV.read(File.join(File.dirname(__FILE__), "../data/ken_all.csv"))
sorted = ary.sort_by { |line| line[2] }
CSV.open("sorted.csv", "wb") do |csv|
@willnet
willnet / postal_code.rb
Created July 6, 2013 08:53
tokyorubyistmeetup のペアプロ課題その2(wip)
# -*- coding: utf-8 -*-
require "csv"
module PostalCode
def self.find(postal_code)
match = CSV.read(File.join(File.dirname(__FILE__), "../data/ken_all.csv")).find do |row|
row[2] == postal_code.tr("-", "")
end
match && match[6,3]
end
module ActionController
module Streaming
extend ActiveSupport::Concern
protected
# Set proper cache control and transfer encoding when streaming
def _process_options(options) #:nodoc:
super
if options[:stream]
@willnet
willnet / Gemfile
Created February 14, 2014 03:19
revenger.in の Gemfile
# -*- coding: utf-8 -*-
source 'http://rubygems.org'
gem 'rails', '3.2.15'
gem 'mysql2'
gem 'unicorn'
gem 'rabl'
gem 'i18n-js'
gem 'roadie'
gem 'kaminari'
@willnet
willnet / gem-info
Last active August 29, 2015 14:03
gem info
#!/bin/sh
echo "gem search -d ^${1}$"
gem search -d ^${1}$