Skip to content

Instantly share code, notes, and snippets.

View sozorogami's full-sized avatar

Tyler Tape sozorogami

  • Duolingo
  • New York
View GitHub Profile
@sozorogami
sozorogami / main.go
Created October 6, 2015 14:09
Convert `Podfile.lock` dependency list into a `.dot` file than can be opened in OmniGraffle
package main
import "os"
import "bufio"
import "io/ioutil"
import "regexp"
import "strings"
// Copy Podfile.lock contents into input.txt in same dir as script
@sozorogami
sozorogami / bug.swift
Last active August 29, 2015 14:23
When mutating methods from a protocol are called on a variable conforming to that protocol, the compiler misses the mutation and emits a warning. Casting the variable to a type that implements the protocol will silence the warning.
protocol Increaser {
var value: Int { get set }
mutating func increase()
}
func doIncrease(var myIncreaser: Increaser) { // Parameter 'myIncreaser' was never mutated; consider
myIncreaser.increase() // changing to 'let' constant
myIncreaser.value
}
@sozorogami
sozorogami / worktime.go
Created May 22, 2014 07:26
問題は、一日、一週間、一ヶ月という期間で、働いた時間を保存して算出することです。「俺、頭いい!」と思いつつこんな実装にしたのですが、残念ながらWorkDayはcountableの内でも、[]WorkDayは[]countableとして通用しないよ?ってコンパイラに怒られるのです。sumHoursWorked内のコードを重複させないで実装する方法はありませんか。
type countable interface {
HoursWorked() time.Duration
}
type WorkDay struct {
StartTime time.Time
EndTime time.Time
}
type WorkWeek struct {