Skip to content

Instantly share code, notes, and snippets.

View katsuma's full-sized avatar
🏠
Working from home

ryo katsuma katsuma

🏠
Working from home
View GitHub Profile
var Keynote = Application("Keynote");
var theme = Keynote.themes.whose({name: "cookpad"}).first
var doc = Keynote.Document({documentTheme: theme});
Keynote.documents.push(doc); // Create a new document with specified theme
@katsuma
katsuma / .sample.zshenv
Created June 29, 2014 12:44
e や o の結果をhistoryに残しておく
pe() { peco | while read LINE; do $@ $LINE; print -s "$@ $LINE"; done }
alias o='git ls-files | pe open'
alias e='ghq list -p | pe cd'
zshaddhistory() {
local line=${1%%$'\n'}
local cmd=${line%% *}
[[ ${cmd} != (l|l[sal])
&& ${cmd} != (m|man)
location /blog/ {
if ($args = "p=845") {
set $args '';
rewrite ^ /blog/2014/02/23/%E3%81%93%E3%82%8C%E3%81%AF%E3%82%84%E3%81%B0%E3%81%84/ permanent;
}
}
# global prefix
set-option -g prefix C-t
bind-key C-t send-prefix
unbind-key C-b
# split window
bind-key s split-window -h
bind-key v split-window
# copy mode by vi bind
irb(main):009:0> tracks = Track.find_by(name: "ばらの花")
=> #[<Itunes::Track:0x007fda6b251398 @persistent_id="7614C19B856C4AB9", @name="ばらの花", @album="TEAM ROCK", @artist="くるり", @track_count="0", @track_number="9">]
irb(main):010:0> track = tracks.first
irb(main):011:0> track.artist
=> "くるり"
irb(main):012:0> track.play # 再生開始
=> #<Itunes::Track:0x007fda6b2713a0 @persistent_id="4B55CDCFEAE6E492", @name="ばらの花", @album="ベスト オブ くるり Tower Of Music Lover", @artist="くるり", @track_count="13", @track_number="2">
var max = 10000
var pi = Math.PI;
var a = new Array(max);
console.time('native');
for (var i = 0, len = a.length; i < len; i++) {
a[i] = pi;
};
console.timeEnd('native');
@katsuma
katsuma / add_file_to_itunes_lib.rb
Created June 20, 2012 17:12
Add a sound file to iTunes Library
file = MacTypes::FileURL.path(File.expand_path('/tmp/speech.aiff'))
command = "tell app \"iTunes\" to add \"#{file.hfs_path}\""
exec_command = "osascript -e '#{command}'"
`#{exec_command}`
@katsuma
katsuma / pop_zap.rb
Created June 11, 2012 17:09
Auto zapping
# -*- coding: utf-8 -*-
require 'rubygems'
require 'socket'
require 'open-uri'
require 'nokogiri'
require 'growl'
require 'ruby-debug'
module PopZap
LIVE_URL = 'http://tv2ch.nukos.net/tvres.html'
@katsuma
katsuma / start.cgi
Created February 26, 2012 04:38
cgi script to handle `git push` hook and to deploy project
#!/home/katsumatv/.rvm/rubies/ruby-1.9.3-p125/bin/ruby
ENV['GEM_HOME'] = '/home/katsumatv/.rvm/gems/ruby-1.9.3-p125'
ENV['PATH'] = "#{ENV['PATH']}:/home/katsumatv/.rvm/gems/ruby-1.9.3-p125/bin:/home/katsumatv/bin"
require 'rubygems'
require 'sinatra'
require 'json'
get '/' do
status 403
@katsuma
katsuma / taifu
Created December 23, 2011 18:56
taifu will add youtube sound to your iTunes library silently
#!/usr/bin/env ruby
# usage:
# taifu http://www.youtube.com/watch?v=KPWfBfFFrwsx
# taifu depends on VLC.app and rb-appscript gem
require 'rubygems'
require 'appscript'
require 'fileutils'