Skip to content

Instantly share code, notes, and snippets.

(create-fontset-from-ascii-font "Menlo-14:weight=normal:slant=normal" nil "menlomarugo")
(set-fontset-font "fontset-menlomarugo"
'unicode
(font-spec :family "Hiragino Maru Gothic ProN" :size 16)
nil
'append)
(add-to-list 'default-frame-alist '(font . "fontset-menlomaruugo"))
@igaiga
igaiga / command.rb
Created January 13, 2011 08:18
shell command runner
# -*- coding: utf-8 -*-
class Command
attr_accessor :command, :status, :out
def initialize(command)
@command = command
self
end
def run
@out = `#{@command} 2>&1`
begin
#raise Exception
String.send(:bar)
rescue Exception => e
puts "rescue Exception"
puts "[Exception class: #{e.class}] [message: #{e.message}] [backtrace: #{e.backtrace}]"
# puts e.class
# puts e.message
# puts e.backtrace
# puts e.methods
class MyException < StandardError
attr_accessor :log_level
def initialize(log_level, message)
@log_level = log_level
super message
end
def log
"[Exception class: #{self.class}] [message: #{message}] [backtrace: #{backtrace}]"
end
@igaiga
igaiga / iphone .gitignore
Created January 30, 2011 05:38
iPhoneアプリ向け .gitignore
/build/
/*.xcodeproj/[USERNAME].*
# [USERNAME] は 自分の名前に置き換え
@igaiga
igaiga / search_ja.rb
Created February 24, 2011 04:24
ファイル中の日本語をだいたい検索
# -*- coding: utf-8 -*-
# 鬼車リファレンス
# http://www.geocities.jp/kosako3/oniguruma/doc/RE.ja.txt
require 'kconv'
Dir.glob('**/*.*'){ |f|
puts "■file: #{f}"
File.open(f, "r"){ |file_hundle|
contents = file_hundle.read
encoding = Kconv.guess(contents)
contents.force_encoding(encoding)
@igaiga
igaiga / p.js
Created March 23, 2011 06:48
javascript で p メソッド
var p = function { print; };
var i18n = {};
i18n['hoge'] = "Hello";
var _ = function(key) { return i18n[key]; };
p(_('hoge'));
@igaiga
igaiga / require_file_once.js
Created March 25, 2011 01:48
javascriptタグを1回だけ読み込み
requireFileOnce = function( checkType, js_name ){
if(typeof(checkType) == 'undefined'){
if( typeof(js_name) == 'string'){
document.write('<script type="text/javascript" src="/javascripts/' + js_name + '.js"></script>');
}else{
for( var i=0; i<js_name.length; i++ ){
document.write('<script type="text/javascript" src="/javascripts/' + js_name[i] + '.js"></script>');
}
}
}
require 'rubygems'
require 'zipruby'
buffer = Zip::Archive.open_buffer(Zip::CREATE) do |ar|
ar.add_buffer('zoo.txt', 'Hello, world!')
end
File.open('out.zip',"wb"){ |f|
f.write buffer
}
@igaiga
igaiga / wkhtmltoimage_converter.rb
Created June 19, 2011 03:42
wkhtmltoimage を使って変換するスクリプト
# -*- coding: utf-8 -*-
# 使い方:wkhtmltoimage と 対象のHTMLフォルダを置いて実行してください。
@option = "--width 480"
@out_ext = "png"
@out_path = "output"
def out_file_path(in_filename)
File.join(@out_path, File.dirname(in_filename), File.basename(in_filename, '.*') + '.' + @out_ext)
end