Skip to content

Instantly share code, notes, and snippets.

if let stream:InputStream = InputStream(fileAtPath: "/Users/pebble8888/hoge.txt") {
var buf:[UInt8] = [UInt8](repeating: 0, count: 16)
stream.open()
while true {
let len = stream.read(&buf, maxLength: buf.count)
print("len \(len)")
for i in 0..<len {
print(String(format:"%02x ", buf[i]), terminator: "")
}
if len < buf.count {
@mwermuth
mwermuth / UIBezier+Arrow.swift
Created September 11, 2014 14:01
Drawing an Arrow with Swift
extension UIBezierPath {
class func getAxisAlignedArrowPoints(inout points: Array<CGPoint>, forLength: CGFloat, tailWidth: CGFloat, headWidth: CGFloat, headLength: CGFloat ) {
let tailLength = forLength - headLength
points.append(CGPointMake(0, tailWidth/2))
points.append(CGPointMake(tailLength, tailWidth/2))
points.append(CGPointMake(tailLength, headWidth/2))
points.append(CGPointMake(forLength, 0))
points.append(CGPointMake(tailLength, -headWidth/2))