Skip to content

Instantly share code, notes, and snippets.

View kazuph's full-sized avatar

Kazuhiro Homma kazuph

View GitHub Profile
@kazuph
kazuph / mv_here_nested_files.rb
Created April 6, 2014 06:51
写真整理用。
#!/usr/bin/env ruby
# coding : utf-8
require 'awesome_print'
require 'pry'
# このスクリプト以下のファイルを見つけたら、このディレクトリに配置する
# 重複を避けるためディレクトリの階層分の名前に変更してmvする
Dir.glob("./**/*").each do |fp|
next if FileTest.directory?(fp)
@kazuph
kazuph / .gitignore
Last active November 24, 2015 03:06
Backlog記法で書かれたWikiをMarkdownのプロジェクトのWikiに全面自動移行するスクリプト ref: http://qiita.com/kazuph/items/57103dde7f4e4a0c4ff1
# Created by https://www.gitignore.io/api/vim,ruby
### Vim ###
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist
*~
@kazuph
kazuph / analytics.rb
Last active August 29, 2015 13:56
Google Analytics から情報を引っ張ってくるスクリプト。初回はブラウザで認証して、以降はファイルに保存した認証情報を使用する。
#!/usr/bin/env ruby
# coding : utf-8
# 参考
# https://github.com/google/google-api-ruby-client
# https://github.com/google/google-api-ruby-client-samples/tree/master/adsense
# https://developers.google.com/api-client-library/ruby/guide/aaa_oauth
# http://blog.naberon.jp/post/2013/08/25/google-analytics-api/
# こっちのモジュールも良さそう
@kazuph
kazuph / file0.html
Created February 4, 2014 01:56
子のng-repeatで親のng-repeatのindexを参照したい ref: http://qiita.com/kazuph/items/e625be063feb6b462af0
<div ng-repeat="(fIndex, f) in foos">
<div>
<div ng-repeat="b in foos.bars">
<a ng-click="addSomething(fIndex)">Add Something</a>
</div>
</div>
</div>
@kazuph
kazuph / file0.html
Created February 2, 2014 16:05
AngularJSでng-repeatした要素ごとに独立した処理を実行させる ref: http://qiita.com/kazuph/items/c098cd75b1208fcc2a85
<div ng-controller="myController">
<div ng-repeat="f in forms">
{{f}}
<input ng-model="data[f]" ng-keyup="doChange(f)">
{{dataTimes[f]}}
</div>
</div>
@kazuph
kazuph / api.rb
Created January 28, 2014 13:44
grape-swaggerでgrapeでつくったAPIのドキュメントを自動生成する ref: http://qiita.com/kazuph/items/7a63d1cf22f2c6ab509d
desc "Reserve a virgin in heaven", {
:notes => <<-NOTE
Virgins in heaven
-----------------
> A virgin doesn't come for free
If you want to reserve a virgin in heaven, you have to do
some crazy stuff on earth.
@kazuph
kazuph / winzip.sh
Created January 23, 2014 08:21
macでwindows用に文字コードを変換したパスワード付きのzipを生成する(かも
#!/usr/bin/env bash -eu
DIR=$1
echo "${DIR}を圧縮します。"
cp -rp ${DIR} ${DIR}_org
convmv -f utf8 --nfd -t utf8 --nfc -r --notest ${DIR}/*
convmv -f utf8 -t cp932 -r --notest ${DIR}/*
zip -9 -r ${DIR}.zip ${DIR}
zipcloak ${DIR}
@kazuph
kazuph / config
Last active January 4, 2016 00:09
Vagrantでvagrantのデフォの秘密鍵じゃなくて自分のいつもの秘密鍵を使えるようにするシェルスクリプト ref: http://qiita.com/kazuph/items/0d9d723b36720b9bd6ed
Host vagrant
HostName 127.0.0.1
User vagrant
Port 2222 # ← これは変わる可能性がある
@kazuph
kazuph / memo.md
Last active January 3, 2016 13:49
CROSS2014の自分メモ
@kazuph
kazuph / file0.txt
Created January 9, 2014 05:47
NSMutableStringを使った箇所でが何故かiOS7でだけコケる ref: http://qiita.com/kazuph/items/3324aa635738fcc35c84
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Attempt to mutate immutable object with insertString:atIndex:'