Skip to content

Instantly share code, notes, and snippets.

💭
Tired

Yung-Luen Lan yllan

💭
Tired
Block or report user

Report or block yllan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yllan
yllan / line2data.swift
Created Jun 19, 2019
Encode MKPolyline to Data
View line2data.swift
func encode(line: MKPolyline) -> Data {
return Data(buffer: UnsafeBufferPointer(start: line.points(), count: line.pointCount))
}
func decode(data: Data) -> MKPolyline {
let buf = UnsafeMutableBufferPointer<MKMapPoint>.allocate(capacity: data.count / MemoryLayout<MKMapPoint>.size)
data.copyBytes(to: buf)
return MKPolyline(points: buf.baseAddress!, count: buf.count)
}
@yllan
yllan / encodable_polyline.swift
Created Jun 18, 2019
How to encode MKPolyline
View encodable_polyline.swift
import MapKit
extension MKPolyline: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer()
for idx in 0..<self.pointCount {
let p = self.points()[idx]
try container.encode(p.x)
try container.encode(p.y)
}
}
@yllan
yllan / encodable_polyline.swift
Created Jun 18, 2019
How to encode MKPolyline
View encodable_polyline.swift
import MapKit
extension MKPolyline: Encodable {
public func encode(to encoder: Encoder) throws {
var container = encoder.unkeyedContainer()
for idx in 0..<self.pointCount {
let p = self.points()[idx]
try container.encode(p.x)
try container.encode(p.y)
}
}
@yllan
yllan / template.html
Last active May 2, 2019
Email Template
View template.html
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>眠豆腐 Sleepy Tofu :: 手工床墊專門製造所</title>
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="padding: 0;">
<div id="wrapper" dir="ltr" style="background-color: #f7f7f7; margin: 0; padding: 70px 0 70px 0; width: 100%; -webkit-text-size-adjust: none;">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"><tr>
<td align="center" valign="top">
View gist:8dd07114c16dbf3c59c1bcb49c16d4c4
1, 4, 12, 2, 3, 6, 8, 9, 5, 7, 10, 11,
1, 4, 12, 2, 3, 8, 6, 9, 7, 5, 10, 11,
1, 4, 12, 2, 3, 8, 6, 9, 7, 10, 5, 11,
1, 4, 12, 2, 3, 8, 6, 11, 5, 10, 7, 9,
1, 4, 12, 2, 3, 8, 11, 6, 5, 10, 7, 9,
1, 4, 12, 2, 3, 11, 8, 5, 9, 7, 6, 10,
1, 4, 12, 2, 3, 11, 8, 9, 5, 7, 10, 6,
1, 4, 12, 2, 8, 3, 6, 9, 7, 5, 10, 11,
1, 4, 12, 2, 8, 3, 6, 9, 7, 10, 5, 11,
1, 4, 12, 2, 8, 3, 6, 11, 5, 10, 7, 9,
@yllan
yllan / crash.log
Created Sep 27, 2018
Xcode 10 crash log
View crash.log
Process: Xcode [4673]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: Xcode
Version: 10.0 (14320.25)
App Item ID: 497799835
App External ID: 828536089
Code Type: X86-64 (Native)
Parent Process: ??? [1]
Responsible: Xcode [4673]
User ID: 501
@yllan
yllan / yllan.md
Created Aug 23, 2018
yllan intro
View yllan.md

現任職於博智雲端科技用python寫web app,下班後的身份是台灣城市單車聯盟理事、Cocoaheads Taipei發起人、業餘macOS/iOS開發者。 上一個生涯目標是推廣熱愛的蘋果,已達成。接下來的生涯目標是推廣熱愛的單車多元文化,用單車來改變城市。 曾主辦「沈默的騎行」呼籲重視交通安全,以及「台北裸騎」。

View sign.swift
//
// Signer.swift
// Sign
//
// Created by Yung-Luen Lan on 2018/8/17.
// Copyright © 2018 yllan. All rights reserved.
//
import Foundation
View AppDelegate.swift
import Cocoa
import MapKit
class MultilineCluster: NSObject, MKOverlay {
var coordinate: CLLocationCoordinate2D
var boundingMapRect: MKMapRect
var lines: [[MKMapPoint]] = []
var strokeColor: NSColor = .black
init(coords: [[CLLocationCoordinate2D]]) {
@yllan
yllan / twd97.swift
Created Jul 15, 2018
Convert TWD97 to latitude, longitude
View twd97.swift
// from https://gist.github.com/pingyen/1346895
import Foundation
extension Double {
var ²: Double {
get {
return self * self
}
}
You can’t perform that action at this time.