This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"decks": [] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
// parse markdown files to html | |
const fs = require('fs'); | |
const postTemplate = fs.readFileSync('templates/post.t', 'utf8'); | |
const postIndexTemplate = fs.readFileSync('templates/post_index.t', 'utf8'); | |
function parsePost(text) { | |
let post = {}; | |
let match = /([\w\W]+?) <([\W\w]*?)>\n\/\/ ([\W\w]*?)\n([\W\w]*)/g.exec(text); | |
post.title = match[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (c) 2018 Sid Mani | |
// https://sidmani.com | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy | |
// of this software and associated documentation files (the "Software"), to deal | |
// in the Software without restriction, including without limitation the rights | |
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
// copies of the Software, and to permit persons to whom the Software is | |
// furnished to do so, subject to the following conditions: | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* MIT License | |
* Copyright (c) 2018 Sid Mani | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: | |
* The above copyright notice and this permission notice shall be included in all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* MIT License | |
* Copyright (c) 2018 Sid Mani | |
* Permission is hereby granted, free of charge, to any person obtaining a copy | |
* of this software and associated documentation files (the "Software"), to deal | |
* in the Software without restriction, including without limitation the rights | |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
* copies of the Software, and to permit persons to whom the Software is | |
* furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator <: AdditionPrecedence | |
infix operator >: AdditionPrecedence | |
infix operator <=: AdditionPrecedence | |
infix operator >=: AdditionPrecedence | |
class AccumulatedComparison<T: Comparable> { | |
var result: Bool | |
var value: T | |
init(result: Bool, value: T) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Path { | |
private let path: UIBezierPath | |
init() { self.path = UIBezierPath() } | |
func move(to point: CGPoint) -> Path { | |
path.move(to: point) | |
return self | |
} | |
func addArc(withCenter center: CGPoint, radius: CGFloat, startAngle: CGFloat, endAngle: CGFloat, clockwise: Bool) -> Path { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple alternative to using swift 4's encodable protocol when you just need to quickly create a dictionary | |
// usage: | |
// struct SomeData: DictionaryEncodable { | |
// enum Key: String { | |
// case someValue | |
// } | |
// | |
// let someValue = 5 | |
// | |
// func encode(_ encoder: DictionaryEncoder) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// custom unique identifier | |
/// @see https://www.firebase.com/blog/2015-02-11-firebase-unique-identifiers.html | |
private let ASC_CHARS = Array("-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz") | |
private let DESC_CHARS = ASC_CHARS.reverse() | |
private var lastPushTime: UInt64 = 0 | |
private var lastRandChars = Array<Int>(count: 12, repeatedValue: 0) | |
func generatePushID(ascending: Bool = true) -> String { | |
let PUSH_CHARS = ascending ? ASC_CHARS: DESC_CHARS | |
var timeStampChars = Array<Character>(count: 8, repeatedValue: PUSH_CHARS.first!) |