Skip to content

Instantly share code, notes, and snippets.

View drobune's full-sized avatar

Yuichi Sano drobune

View GitHub Profile
@drobune
drobune / .zshrc
Created August 28, 2015 08:25
zsh notify
#copy from https://www.reddit.com/r/linux/comments/1pooe6/zsh_tip_notify_after_long_processes/
preexec () {
# Note the date when the command started, in unix time.
CMD_START_DATE=$(date +%s)
# Store the command that we're running.
CMD_NAME=$1
}
precmd () {
# Proceed only if we've ran a command in the current shell.
if ! [[ -z $CMD_START_DATE ]]; then
@drobune
drobune / gist:4157e94d5a45c410d68f
Created September 24, 2014 03:49
forever を自動起動
/usr/local/bin/node /usr/local/bin/forever start \
-p /var/run/forever \
--pidfile /var/run/node-app.pid \
-l /var/log/node-app.log -a \
-d /home/node/ \
/home/node/app.js
@drobune
drobune / jump-to-github.el
Created September 5, 2015 21:01
emacsでカーソル行のgithubページに飛ぶ
(defun jump-to-github ()
"Go to github code position at most recent commitl;"
(interactive)
(let (full_path)
(setq
full_path buffer-file-name
dir_name (shell-command-to-string (concat "echo " full_path "| xargs dirname"))
cd_dir (shell-command-to-string (concat "cd " dir_name))
prefix (shell-command-to-string "git rev-parse --show-prefix | tr -d '\n'")
current_commit (shell-command-to-string "git show -s --format=%H | tr -d '\n'")
@drobune
drobune / gist:6153012
Last active December 20, 2015 15:19
how to parse xml and guess encording in ruby
#perse xml
require 'rexml/document'
doc = REXML::Document.new(response[:body])
doc.elements['response/result'].text
#guess encording
require 'nkf'
NKF.guess(response[:body])
app.configure(function() {
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.cookieParser());
//↓sessionの前に書かないと、最初のアクセスでundefinedが返ってきました。
app.use(express.csrf());
app.use(express.session({ secret: 'secret goes here' }));
app.use(express.bodyParser());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
#!/bin/bash
base=`basename $0 | sed -e 's/\.sh$//g'`
cmd=`echo $base | awk -F '_' '{print $1}'`
keystroke=`echo $base | sed -e 's/^[^_]\+_//g'`
id=`xdotool getwindowfocus`
case $cmd in
key)
xdotool key --window $id "$keystroke" > /dev/null 2>&1
(xbindkey '("m:0x4" "c:58") "/usr/local/bin/key_Return.sh")
(xbindkey '("m:0x4" "c:57") "/usr/local/bin/key_Down.sh")
(xbindkey '("m:0x4" "c:43") "/usr/local/bin/key_BackSpace.sh")
(xbindkey '("m:0x4" "c:33") "/usr/local/bin/key_Up.sh")
(xbindkey '("m:0x5" "c:41") "/usr/local/bin/key_Right.sh")
(xbindkey '("m:0x5" "c:56") "/usr/local/bin/key_Left.sh")
#!/bin/bash -xe
base=`basename $0 | sed -e 's/\.sh$//g'`
cmd=`echo $base | awk -F '_' '{print $1}'`
keystroke=`echo $base | sed -e 's/^[^_]\+_//g'`
id=`xdotool getwindowfocus`
# Avoid chikachika-terminal
#app_name=`xprop -id ${id} | grep M_CLASS | cut -f3 -d ' ' | tr '[:upper:]' '[:lower:]' | tr -d ',','"',' ',"\'"`
#if [ "$app_name" == "terminator" ]; then
@drobune
drobune / gabagaba.rb
Created April 5, 2016 06:22
hashを受け取ってアクセス可能なインスタンス変数を生成するクラス
class Gabagaba
def initialize(opts = {})
opts.each do |key, value|
self.class.class_eval { attr_accessor "#{key}" }
self.instance_variable_set "@#{key}" value
end
end
end
@drobune
drobune / Home.sh
Created May 11, 2016 03:39
Homeボタンをシミュレートする(xbindkeysでCtrl-aを割り当てる)
#!/bin/bash -xe
id=`xdotool getwindowfocus`
xdotool key --window $id Home > /dev/null 2>&1