Skip to content

Instantly share code, notes, and snippets.

def capture(stream)
begin
stream = stream.to_s
eval "$#{stream} = StringIO.new"
yield
result = eval("$#{stream}").string
ensure
eval("$#{stream} = #{stream.upcase}")
end
result
# http://qiita.com/ToQoz/items/848abdf90a0f40e70ce0
# http://stackoverflow.com/questions/3063507/list-goals-targets-in-gnu-make/9524878#9524878
_makefile_cache_updated_at() {
echo $(stat .make_targets -c%Y)
}
_makefile_updated_at() {
echo $(stat Makefile -c%Y)
}
_generate_makefile_cache() {
[ -f .make_targets ] && rm .make_targets
@calorie
calorie / update.rb
Last active December 29, 2015 06:18
boxen : update Puppetfile script
require 'open-uri'
require 'json'
READ_START_SYMBOL = '# ---auto update---'
READ_END_SYMBOL = '# ---/auto update---'
def notify(name, from, to)
puts "update #{name} from #{from} to #{to}"
end
local sprite = CCSprite:create("hoge.png")
sprite:setTouchEnabled(true)
sprite:addTouchEventListener(function(event, x, y)
if event == "began" then
return true
elseif event == "moved" then
elseif event == "ended" then
end
end)
set showmatch " 括弧の対応をハイライト
set number " 行番号表示
set list " 不可視文字表示
set listchars=tab:>.,trail:_,extends:>,precedes:< " 不可視文字の表示形式
set display=uhex " 印字不可能文字を16進数で表示
set previewheight=15 " プレビュー画面サイズ
set cmdheight=1 " コマンドラインに使われる画面上の行数
set lazyredraw " コマンド実行中は再描画しない
set ttyfast " 高速ターミナル接続を行う
set cursorline " カーソル行をハイライト
#------------------------------------
# options configuration
# ------------------------------------
# 指定したコマンド名がなく、ディレクトリ名と一致した場合 cd する
setopt auto_cd
# cd でTabを押すとdir list を表示
setopt auto_pushd
# ディレクトリスタックに同じディレクトリを追加しないようになる
setopt pushd_ignore_dups
# コマンドのスペルチェックをする
#MysqlでFKの一覧を調べるワンライナー
mysql -u resolver --password=resolver resolver < TableList.sql |sed 's/\\n/&\
/g'| grep 'CONSTRAINT .* FOREIGN KEY'|cut -d ' ' -f4 > FKList
# ファイル名を置換するワンライナー
ls *.png | cut -d ' ' -f14,15,16,17 |perl -nle '$o=$_;$_=~s/\s/_/i;$_=lc($_);$_=~s/^/icon_/i;rename($o, $_);'
ls *.png | cut -d ' ' -f14,15,16,17 |perl -nle '$o=$_;$_=~s/\s/_/i;$_=lc($_);$_=~s/^/button_/i;rename($o, $_);'
require 'fileutils'
GEMFILE_TMP = 'Gemfile_tmp'
FileUtils.cp('Gemfile', GEMFILE_TMP)
regex = /^\s*gem ['"]([-\w]+)['"](,.*)?/
gems = File.read(GEMFILE_TMP).scan(regex).map do |g|
g.first if g.last.nil?
end
// ==UserScript==
// @name Nico Nico Enhance
// @version 0.1
// @description Nico Nico Enhance
// @include *://www.nicovideo.jp/watch/*
// ==/UserScript==
(function(){
try{
// document.getElementById('PlayerContainer').focus();