Skip to content

Instantly share code, notes, and snippets.

@haranicle
haranicle / CodePiece.swift
Created February 16, 2016 10:07
これもダメと #CodePiece
protocol P1 {
}
protocol P2 {
typealias A = P1 // Selfでも同様
}
let arr1: Array<P1> = []
let arr2: Array<P2> = [] // Protocol 'P2' can only be used as a generic constraint because it has Self or associated type requirements
@haranicle
haranicle / CodePiece.swift
Created May 21, 2016 07:58
ですよねー #CodePiece
let t: AnyClass = NSObject.self
typealias T = t // Use of undeclared type 't'
@haranicle
haranicle / CodePiece.swift
Created June 11, 2016 07:14
この書き方は便利そう #CodePiece #cswift
@available(iOS 10.0, *)
extension MyClass {}
@haranicle
haranicle / CodePiece.swift
Created June 11, 2016 08:13
メモ #CodePiece #cswift
@available(*, unavailable, message="Hello!")
@available(*, unavailable, renamed="newFunc")
@haranicle
haranicle / CodePiece.swift
Created June 11, 2016 08:18
いいえ逃 #CodePiece #cswift
let param
let a: String = { @noescape () -> String in
param // self.がいらない!
}()
import Foundation
class Thunder { }
class Fire { }
protocol Pokemon {
associatedtype PokemonType
func attack(move:PokemonType)
}
mkdir tmp && \
ffmpeg -i img.mov -an -r 5 tmp/%04d.png && \
convert tmp/*.png -resize 40% tmp/output_%04d.png && \
convert -delay 12 tmp/output_*.png img.gif && \
convert -layers Optimize img.gif img.gif && \
rm -rf tmp
#!/bin/sh
# settings
DEVICE_TOKEN="XXXXXX"
TOPIC="com.your.app.bundle.id"
# process
DATE="`date \"+%Y/%m/%d %H:%M:%S\"`"
@haranicle
haranicle / split NSString
Last active July 2, 2017 08:35
split NSString
var str: NSString = "abcdef"
for i in 0..<str.length {
print(str.substring(with: NSRange(location: i, length: 1)))
}