Skip to content

Instantly share code, notes, and snippets.

View satococoa's full-sized avatar

Satoshi Ebisawa satococoa

View GitHub Profile
@satococoa
satococoa / gist:2347993
Created April 10, 2012 02:33
tmuxで画面を4分割しつつコマンド実行
#!/bin/zsh
tmux new-window -n name # 新しいwindowを開きたくない場合は以下
# tmux rename-window name
tmux split-window -h
tmux split-window -v -t name.0
tmux split-window -v -t name.1
tmux send-keys -t name.0 'echo 0' C-m
tmux send-keys -t name.1 'echo 1' C-m
tmux send-keys -t name.2 'echo 2' C-m
@satococoa
satococoa / multi-user-homebrew.md
Created April 16, 2012 03:08
マルチユーザーでHomebrewを使う

マルチユーザーでHomebrewを使う

staffグループのユーザーに/usr/local以下の書き込み権限を与えればいい

umask 0022 を umask 0002 に変更し、新しく作成したファイルにgroup writeパーミッションがつくようにする

/etc/bashrc OR /etc/profileの最終行に以下を追加

umask 0002
@satococoa
satococoa / homebrew.mxcl.jenkins.plist
Created April 17, 2012 01:27
Homebrewでインストールしたjenkinsでコミットログが文字化けするので対応
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-Dfile.encoding=UTF-8</string> <!-- 文字化け対策追加 -->
# usage: $ bundle exec ruby get_all_pdfs.rb | xargs -n 1 curl -O
require 'bundler/setup'
require 'nokogiri'
require 'open-uri'
require 'pp'
page_url = URI.parse('https://developer.apple.com/jp/devcenter/ios/library/japanese.html')
doc = Nokogiri::HTML(open(page_url))
@satococoa
satococoa / amida.md
Created May 19, 2012 09:19
あみだくじ

あみだくじを作ってください。

仕様

  • 当たりの数は一つ
  • 当たりの位置はランダム
  • 人リストからランダムに配置すること
  • 横線がランダムに配置されること
  • 横線が複数繋がってはいけない
  • 横線が一本も繋ってない縦線が存在してはいけない
@satococoa
satococoa / english_numerals.md
Created May 19, 2012 09:33
English Numerals

English Numerals

引数で与えられた数字を英語で表示してください。

$ ruby numerals.rb 7
  #=> seven

@satococoa
satococoa / config.rb
Created May 26, 2012 19:23
RubyMotion 1.6でdeployment_targetを4.3にしたときにcrashするのを修正
# ./lib/motion/project/config.rb
# RakefileからrequireすればOK
# そのうち直るとは思うけれどもとりあえず。。。
class Motion::Project::Config
def target(platform)
File.join(platform_dir(platform), 'Developer/SDKs',
platform + deployment_target + '.sdk')
end
def frameworks_dependencies
@satococoa
satococoa / gist:2978822
Created June 23, 2012 16:07
Preferences.sublime-settings
{
"font_face": "Ricty-Regular",
"font_size": 16.0,
"highlight_line": true,
"tab_size": 2,
"translate_tabs_to_spaces": true,
"word_wrap": true
}
@satococoa
satococoa / app_delegate.rb
Created July 23, 2012 13:16
UIAlertView, UIActionSheet
class MyViewController < UIViewController
def viewDidLoad
super
view.backgroundColor = UIColor.whiteColor
button = UIButton.buttonWithType(UIButtonTypeRoundedRect).tap do |b|
b.frame = [[30.0, 30.0], [200.0, 30.0]]
b.setTitle("Click", forState:UIControlStateNormal)
b.addTarget(self, action: 'open_action_sheet:', forControlEvents: UIControlEventTouchUpInside)
end
@satococoa
satococoa / resize.rb
Created July 25, 2012 02:51
ImageMagickで50%に画像を縮小(元ファイルはファイル名に@2xつけてコピー)
require 'pp'
require 'pathname'
input_dir = 'orig'
output_dir = 'out'
Pathname.glob("#{input_dir}/**/*.png").sort.each do |path|
dist = Pathname(path.to_s.gsub(input_dir, output_dir))
dist.dirname.mkpath unless dist.dirname.exist?
system('cp %s %s' % [path.to_s, dist.to_s.gsub('.png', '@2x.png')])