Skip to content

Instantly share code, notes, and snippets.

# aliases for git
alias g="git"
alias gad="git add"
alias gb="git branch -v"
alias gba="git branch -a"
alias gbl="git blame"
alias gbr="git branch -r"
alias gc="git commit -v"
alias gca="git commit -av"
alias gco="git checkout"
$KCODE = 'u'
require 'java'
include_class 'java.io.FileInputStream'
include_class 'org.apache.poi.hssf.usermodel.HSSFWorkbook'
def open_xls(filename)
input = FileInputStream.new filename
book = HSSFWorkbook.new input
input.close()
module DoubleCtrlCTrapper
TOLERANCE = 3
def self.tolerance?(sec)
sec < TOLERANCE
end
def self.freq?(current)
b = @last_trapped && tolerance?(current - @last_trapped)
@last_trapped = current
b
#!/usr/bin/env ruby
# ruby timer.rb 3m ramen_ok &
require 'time'
require 'date'
NOHUP_FLAG = '___nohup___'
def main(delay, message)
wait(parse_time(delay))
notify(message)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML5 Canvas</title>
<script src="3d.js" type="text/javascript"></script>
<style type="text/css">
html, body, canvas { overflow: hidden; width: 100%; height: 100%; margin: 0; padding: 0; border: 0 }
textarea { display: none }
</style>
" generate method skeleton from word under the cursor
nnoremap <silent> <C-k> mayiw`a}odef <C-[>poend<C-m><C-[><C-o>
# will_paginateのリンク描画のみ行う
module WillPaginate
module ViewHelpers
def prepare_renderer(collection)
renderer = WillPaginate::LinkRenderer.new
options = {}.symbolize_keys.reverse_merge WillPaginate::ViewHelpers.pagination_options
renderer.prepare collection, options, self
renderer
end
class Struct
unless self.respond_to? :org_new_for_access_instance_variable
class << self
alias_method :org_new_for_access_instance_variable, :new
def new(*ary, &block)
st = org_new_for_access_instance_variable(*ary, &block)
st.module_eval {
alias_method :org_init, :initialize
def initialize(*ary)
org_init(*ary)
#!/usr/bin/env ruby
require 'tempfile'
def main
user = ARGV[0]
remote = ARGV[1]
if user_existed?(user)
STDERR.puts "already exist user #{user}. do nothing."
exit 1
end
(function () {
function setTitle(elements) {
for (var i=0; i < elements.length; i++) {
elements[i].title = elements[i].name;
}
}
var elements = document.getElementsByTagName('input');
setTitle(elements);
elements = document.getElementsByTagName('select');