Skip to content

Instantly share code, notes, and snippets.

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

Toshihiro Suzuki toshi0383

🏠
Working from home
  • Tokyo
View GitHub Profile
@toshi0383
toshi0383 / wifilog.sh
Last active August 29, 2015 14:11
GL-06P の累計受信データ量を取得するシェル
#!/bin/bash
URL="http://pocketwifi.home/api/monitoring/traffic-statistics"
response=`curl -s $URL`
PATTERN=TotalDownload
downloadByte=`echo "$response" \
| grep $PATTERN \
| sed -e "s/<TotalDownload>//g" -e "s~</TotalDownload>~~g"`
if [ ! $downloadByte ];then
exit 1;
fi
#!/bin/bash
git config --global alias.p 'pull'
git config --global alias.s 'status'
git config --global alias.o 'checkout'
git config --global alias.b 'checkout -b'
git config --global alias.pu 'push'
git config --global alias.puu 'push -u'
git config --global alias.c 'commit -v'

GUIツールやコマンドラインのdiffに比べて、 上記のGitHubを利用した運用が優れている点をまとめてみました。

  • レビューコメントとソースコードが独立し、安全かつ効率的な開発ができる
  • 下記により、レビューをする人の負荷が少ない
    • レビューの時点では必ず競合が解消されている
    • レビューをする人はWebページを開けば差分が見れる(積極的にレビューする気になる)
    • ブランチ全体のdiffを見る方法をツールで覚える必要がない(誰でもレビューする人になれる)
  • featureブランチもPull Requestのマージのときに一緒にワンクリック(1度のクリック)で消せる
  • 手元にソースコードがないときでもレビューしてマージまでできる
@toshi0383
toshi0383 / file0.txt
Last active August 29, 2015 14:21
for文内で宣言するクロージャにインクリメントする引数を渡してはいけない ref: http://qiita.com/toshi0383/items/595ee6c47d43ef043f2c
func getF(num:Int) -> Void -> Void {
return {
println(num)
}
}
var list1: [(Void -> Void)] = Array()
var list2: [(Void -> Void)] = Array()
var list3: [(Void -> Void)] = Array()
for (var i = 0; i < 3; i++) {
@toshi0383
toshi0383 / file0.txt
Created May 25, 2015 06:32
filter-branchで指定した範囲のコミットログを修正する ref: http://qiita.com/toshi0383/items/f760f09ae4b921af0e9b
git filter-branch --msg-filter '
sed -e "s/^feature.*$/ref\ #146/"
' tmp2..tmp
@toshi0383
toshi0383 / AppDelegate.swift
Created May 29, 2015 11:56
MacアプリでiOSアプリみたいにURL Scheme起動すんのってどうやんの?を調べてみた ref: http://qiita.com/toshi0383/items/94abad5667f84b773ba9
func applicationDidFinishLaunching(aNotification: NSNotification) {
// Insert code here to initialize your application
var appleEventManager:NSAppleEventManager = NSAppleEventManager.sharedAppleEventManager()
appleEventManager.setEventHandler(self, andSelector: "handleGetURLEvent:replyEvent:", forEventClass: AEEventClass(kInternetEventClass), andEventID: AEEventID(kAEGetURL))
var appUrl = NSBundle.mainBundle().bundleURL.URLByAppendingPathComponent("", isDirectory: true)
var a:Boolean = 0 // true
var status = LSRegisterURL(appUrl as CFURL!, a)
}
func handleGetURLEvent(event: NSAppleEventDescriptor?, replyEvent: NSAppleEventDescriptor?) {
@toshi0383
toshi0383 / CodePiece.swift
Created July 25, 2015 06:21
throwsとrethrows。うーんここまでやるかなあ。 #cswift #CodePiece
func executeRethrows(f:() throws ->()) rethrows {
do{try f()}catch{print(error)}
}
func execute(f:() throws ->()) {
do{try f()}catch{print(error)}
}
enum MyError:ErrorType {
case A, B
}
execute{
@toshi0383
toshi0383 / CodePiece.swift
Created July 25, 2015 06:34
Boolを返すメソッドならwhereに書けるってことみたい。 #cswift #CodePiece
let op:[Int?] = [1,2,3,nil,5]
func a() { print("brown") }
func a(value:Int) -> Bool { print("yellow"); return true }
func a() -> Bool {print("green");return true}
for case let v? in op where a(v) { print(v) }
for case let v? in op where a() { print(v) }
// yellow
// 1
// yellow
@toshi0383
toshi0383 / CodePiece.swift
Last active August 29, 2015 14:25
で、できた。。 #cswift #CodePiece
import UIKit
protocol CustomViewControllerType {
func hello()
}
extension CustomViewControllerType {
func hello() {
print("hello")
}
}
@toshi0383
toshi0383 / CodePiece.swift
Created July 25, 2015 07:07
さっきのprotocol extensionをsuperclass的に扱うやつBAD ACCESSになった。 #cswift #CodePiece
import UIKit
protocol CustomViewControllerType {
func hello()
}
extension CustomViewControllerType {
func hello() {
print("hello")
}