This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
require 'poi-3.1-FINAL-20080629.jar' | |
java.io.FileOutputStream.new("test2.xls") do |io| | |
wb = org.apache.poi.hssf.usermodel.HSSFWorkbook.new | |
wb.createSheet("First") | |
wb.write(io) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
require 'poi-3.1-FINAL-20080629.jar' | |
class RubyOutputStream < java.io.OutputStream | |
def set_io(io) | |
@io = io | |
end | |
def write(b) | |
if b.is_a?(Fixnum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
def tree_ancestors | |
puts_tree_acestors(0, [self]) | |
end | |
protected | |
def puts_tree_acestors(indent, displayed_modules) | |
puts "%s[%s] %s" % [' ' * indent, (self.is_a?(Class) ? 'C' : 'M'), self.name] | |
nested_included_modules = included_modules.map{|mod| mod.included_modules}.uniq.flatten # - displayed_modules | |
my_included_modules = included_modules - nested_included_modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
def def_trace_method(method_name, suffix = :rubeus) | |
self.module_eval(<<-"EOS") | |
def #{method_name.to_s}_with_#{suffix.to_s}(*args, &block) | |
puts "\#{self.name}.#{method_name}(\#{args.map{|arg| arg.inspect}.join(', ')})" | |
puts caller.join("\n ") if block_given? | |
#{method_name.to_s}_without_#{suffix.to_s}(*args, &block) | |
end | |
EOS | |
self.module_eval do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 仕事用に作ってみたクラス | |
# 結局ボツにしました | |
class WhereBuilder | |
attr_accessor :joiner, 'AND' | |
attr_accessor :where_parts | |
attr_accessor :values | |
attr_accessor :filters | |
attr_accessor :wrapper | |
def initialize(*filters) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require 'yaml/encoding' | |
class String | |
alias :old_to_yaml :to_yaml | |
def to_yaml(ops = {}) | |
YAML.escape(self).old_to_yaml(ops) | |
end | |
end | |
require "yaml" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://kazmax.zpp.jp/lin/etc_passwd.html | |
alias users_list="cut -d: -f1 /etc/passwd | sort" | |
alias groups_list="cat /etc/group | sort" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) | |
require 'fileutils' | |
require 'optparse' | |
FileUtils.cd(RAILS_ROOT) | |
runtime_options = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
db_proj_name = 'your project name on db' | |
scm_proj_name = 'your project name on scm' | |
branch = `git status`.scan(/\# On branch ([^\s]+?)$/).flatten.first if File.exist?('./.git') | |
branch ||= `svn info`.scan(/\/#{scm_proj_name}\/(?:branches\/(.*?))\/|(trunk)/).flatten.compact.first if File.exist?('./.svn') | |
branch = branch ? '_' << branch.sub(/^local[\-_]/, '').sub('-', '_') : '' | |
%> | |
common: &common | |
adapter: mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# http://henrik.nyh.se/2008/10/cap-gems-install-and-a-gem-dependency-gotcha | |
namespace :gems do | |
desc "setup gemcutter" | |
task :gemcutter, :roles => :app do | |
run "#{sudo} gem install gemcutter" | |
run "#{sudo} gem tumble" | |
end | |
desc "Install gems" | |
task :install, :roles => :app do |
OlderNewer