Skip to content

Instantly share code, notes, and snippets.

View harlanhaskins's full-sized avatar
🦅
Swifting

Harlan Haskins harlanhaskins

🦅
Swifting
View GitHub Profile
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
(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))
@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
extension UIView {
func constraintsEqualToSuperview(_ edgeInsets: UIEdgeInsets = UIEdgeInsets.zero, priority: UILayoutPriority = 1000) -> [NSLayoutConstraint] {
self.translatesAutoresizingMaskIntoConstraints = false
var constraints = [NSLayoutConstraint]()
if let superview = self.superview {
constraints.append(self.constraining(.leading, .equal, to: superview, constant: edgeInsets.left, priority: priority))
constraints.append(self.constraining(.trailing, .equal, to: superview, constant: -edgeInsets.right, priority: priority))
constraints.append(self.constraining(.top, .equal, to: superview, constant: edgeInsets.top, priority: priority))
constraints.append(self.constraining(.bottom, .equal, to: superview, constant: -edgeInsets.bottom, priority: priority))
}
@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?

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 / 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
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 / 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: