Skip to content

Instantly share code, notes, and snippets.

View harlanhaskins's full-sized avatar
🦅
Swifting

Harlan Haskins harlanhaskins

🦅
Swifting
View GitHub Profile
@harlanhaskins
harlanhaskins / keybase.md
Created November 23, 2017 15:47
Keybase Proof

Keybase proof

I hereby claim:

  • I am harlanhaskins on github.
  • I am harlanhaskins (https://keybase.io/harlanhaskins) on keybase.
  • I have a public key ASAaLSbIdUmM-i3WHBBB-TdELlHJc_NXNetHa6sBSxxqzAo

To claim this, I am signing this object:

@harlanhaskins
harlanhaskins / swift-format.swift
Created October 26, 2017 19:48
Simple Swift Formatter using SwiftSyntax
import Foundation
import SwiftSyntax
func main() throws {
guard CommandLine.arguments.count > 1 else {
print("usage: swift-format [file]")
exit(-1)
}
let url = URL(fileURLWithPath: CommandLine.arguments[1])
Require Import String Arith List Bool Ascii.
Scheme Equality for string.
(*
* The Simply-Typed Lambda Calculus
*)
(*
* Two base types:
* - Integers (natural numbers)
Definition bind_option (A: Type) (B: Type) (opt: option A) (f: A -> option B): option B :=
match opt with
| Some v => f v
| None => None
end.
Definition return_option (A: Type) (a: A) := Some a.
(* return a >>= f = f a *)
Theorem left_identity_option A B a f:
@harlanhaskins
harlanhaskins / fix-calendar.swift
Created August 28, 2017 03:00
Fixes TigerCenter Calendars on the macOS calendar app
#!/usr/bin/env swift
import EventKit
let eventStore = EKEventStore()
extension String: Error {}
func deleteBadEvents(calendarName: String) throws {
// Make dates for Fall Semester 2017 before exams
use std::env;
fn print_spongebob(vals: &[String]) {
let statement = vals.join(" ");
let mut lower = true;
for c in statement.chars() {
let new_c = if lower { c.to_lowercase().next() }
else { c.to_uppercase().next() };
if let Some(c) = new_c {
print!("{}", c);
@harlanhaskins
harlanhaskins / ARC.md
Last active March 12, 2017 04:07
Trill ARC

Automatic Reference Counting

Previously, Trill used the TinyGC garbage collector to manage memory allocated by indirect types. This garbage collector, though able to clean up these heap structures, does not afford the ability to introspect a data structure for its references, which is necessary to implement Copy on Write. As such, we have elected to move to an Automatic Reference Counting model for automatically managing the allocation of indirect types in the Trill language.

What is ARC?

@harlanhaskins
harlanhaskins / interface.swift
Last active March 2, 2017 20:33
A "Generated Interface" of everything Trill imports from C.
// <none>:2:18
let __llvm__: Int
// <none>:3:19
let __clang__: Int
// <none>:4:25
let __clang_major__: Int
// <none>:5:25
(var_assign_decl <none>:2:18 kind="global" modifiers="implicit" mutable=false name="__llvm__" type="Int"
(num_expr <none>:2:18 raw="1" type="Int" value=1))
(var_assign_decl <none>:3:19 kind="global" modifiers="implicit" mutable=false name="__clang__" type="Int"
(num_expr <none>:3:19 raw="1" type="Int" value=1))
(var_assign_decl <none>:4:25 kind="global" modifiers="implicit" mutable=false name="__clang_major__" type="Int"
(num_expr <none>:4:25 raw="3" type="Int" value=3))
(var_assign_decl <none>:5:25 kind="global" modifiers="implicit" mutable=false name="__clang_minor__" type="Int"
(num_expr <none>:5:25 raw="9" type="Int" value=9))
(var_assign_decl <none>:6:30 kind="global" modifiers="implicit" mutable=false name="__clang_patchlevel__" type="Int"
(num_expr <none>:6:30 raw="1" type="Int" value=1))
Name: cllvm
Description: The llvm library
Version: 3.9.1
Libs: -L/usr/local/Cellar/llvm/3.9.1/lib -lLLVMLTO -lLLVMObjCARCOpts -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMDebugInfoDWARF -lLLVMGlobalISel -lLLVMCoverage -lLLVMTableGen -lLLVMOrcJIT -lLLVMMIRParser -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUAsmPrinter -lLLVMAMDGPUUtils -lLLVMObjectYAML -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMDebugInfoCodeView -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lLLVMMCJIT -lLLVMLibDriver -lLLVMOption -lLLVMLineEditor -lLLVMPasses -lLLVMipo -lLLVMVectorize -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMObject -lLLVMMCParser