Skip to content

Instantly share code, notes, and snippets.

View iberianpig's full-sized avatar

Kohei Yamada iberianpig

View GitHub Profile
@iberianpig
iberianpig / PackageControl_st3_behind_proxy.txt
Last active August 29, 2015 13:55
sublime-text 3でのPackageControlのプロキシ越しのインストール
import urllib.request,ospf = 'Package Control.sublime-package'ipp = sublime.installed_packages_path()urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler( {"http": "http://[user]:[password]@[proxy_IP]:[proxy_port]"} ) ))open(os.path.join(ipp, pf), 'wb').write( urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20') ).read())
@iberianpig
iberianpig / power_save.sh
Last active August 29, 2015 13:57
Ubuntu 12.04 省電力Script
#!/bin/sh
date>/home/iberianpig/powersaved.txt
sleep 10
# Reduce power for SATA link power management
for i in 0 1 2 3 4 5 ; do
echo min_power>/sys/class/scsi_host/host${i}/link_power_management_policy
done
# Disable the NMI watchdog
echo 0 > /proc/sys/kernel/watchdog
alias be='bundle exec'
alias r='bundle exec spring rails'
alias ra='bundle exec spring rake'
"http://vimblog.hatenablog.com/entry/vimrc_introduction
set number " 行番号を表示する
set cursorline " カーソル行の背景色を変える
set cursorcolumn " カーソル位置のカラムの背景色を変える
set laststatus=2 " ステータス行を常に表示
set cmdheight=1 " メッセージ表示欄を2行確保
set showmatch " 対応する括弧を強調表示
set helpheight=998 " ヘルプを画面いっぱいに開く
set list " 不可視文字を表示
set listchars=tab:▸\ ,eol:↲,extends:❯,precedes:❮ " 不可視文字の表示記号指定
Fcitxの設定 > 全体の設定 > ホットキー > 拡張オプション表示 > 入力メソッドをオフに
@iberianpig
iberianpig / imagict.js
Created October 13, 2014 08:43
imagictのブックマークレット。ダイアログorタブで開く。
javascript:(function(){var w=(document.all)?document.selection.createRange().text:(window.getSelection()+'');if(!w)w=prompt('Imagictで検索したいワードを入力してください。','');if(w!=null)window.open('http://imagict.com/words/search?dictionary=en_ja&word='+encodeURIComponent(w));})();
@iberianpig
iberianpig / character_set_and_collation.rb
Last active August 29, 2015 14:15
db/schemaを読み取って、default charset/collation, 既存DBのcharset/collationを変換するとき用。migrationファイルのchangeメソッドに使う。
class ChangeCollationOption < ActiveRecord::Migration
def up
execute "ALTER TABLE access_counters DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
execute "ALTER TABLE access_counters CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"
execute "ALTER TABLE access_tokens DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
execute "ALTER TABLE access_tokens CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"
execute "ALTER TABLE activities DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
execute "ALTER TABLE activities CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"
execute "ALTER TABLE admin_featured_users DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;"
execute "ALTER TABLE admin_featured_users CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;"
@iberianpig
iberianpig / id_hash.rb
Last active August 29, 2015 14:23
3桁"/"区切りのurlを生成する。paperclipで生成されるurlをidから作る。
#NOTE: create id_hash for paperclip's url
# e.g) photo_id = 14721; format("%09d", photo_id).split("").each_slice(3).map{ |array| array.join("") }.join("/")
# # => "000/014/721"
id_hash = format("%09d", photo_id).split("").each_slice(3).map{ |array| array.join("") }.join("/")
@iberianpig
iberianpig / prepare-commit-msg
Last active August 29, 2015 14:23
ブランチ名がNUMBER_TITLEの時に、自動でコミットメッセージに[#NUMBER]を付与するフックスクリプト
#!/bin/sh
# set to repository/.git/hooks/prepare-commit-msg
# chmod +x prepare-commit-msg
COMMIT_EDITMSG=$1
mv $COMMIT_EDITMSG $COMMIT_EDITMSG.tmp
number=`git branch | grep "*" | awk '{print $2}' | sed -e "s/^\([0-9]*\).*/\1/g"`
msg=""
@iberianpig
iberianpig / ec2_ssh.sh
Last active December 10, 2015 01:23
Connect to EC2 with adding/removing IP from Security Group
#!/bin/sh
if [ $# -lt 2 ]; then
echo "give HOST(~/.ssh/config), GROUP_ID(sg-xxxx) [, PROFILE(~/.aws/config)] as arguments" 1>&2
echo "$ ssh_ec2 Hostname sg-groupid default" 1>&2
exit 1
fi
HOST=$1
GROUP_ID=$2