Skip to content

Instantly share code, notes, and snippets.

alemar11 / zen.swift
Created Aug 20, 2015
Zen Swift script
View zen.swift
#!/usr/bin/env xcrun swift
import Foundation
func Zen() -> String? {
if let url = NSURL(string: ""), data = NSData(contentsOfURL: url), zen = NSString(data: data, encoding: NSUTF8StringEncoding){
return zen as String
return nil
alemar11 /
Last active Sep 12, 2015 — forked from brandonb927/
OSX for Hackers: Yosemite Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned. Also, please don't email me about this script, my poor inbox...
# Alot of these configs have been taken from the various places
# on the web, most from here
# Set the colours you can use
alemar11 / color.m
Last active Sep 12, 2015 — forked from kylefox/color.m
Generate a random color (UIColor) in Objective-C
View color.m
Distributed under The MIT License:
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
alemar11 / StringSize.swift
Last active Sep 18, 2015 — forked from plumhead/StringSize.swift
String extension to find the layout size of a String with specified attributes.
View StringSize.swift
extension String {
func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect {
let storage = NSTextStorage(string: self)
let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height))
let layout = NSLayoutManager()
storage.addAttributes(attrs, range: NSMakeRange(0, storage.length))
container.lineFragmentPadding = 0.0
let _ = layout.glyphRangeForTextContainer(container)
alemar11 / .lldbinit
Created Sep 28, 2015
Xcode lldbinit
View .lldbinit
# Swift
command alias uikit expr import UIKit
command alias foundation expr import Foundation
command alias vh expr -l objc++ -O -- [[[UIWindow keyWindow] rootViewController] _printHierarchy]
# Objective-C
command alias uikitc expr @import UIKit
command alias foundationc expr @import Foundation
command alias vhc po [[[UIWindow keyWindow] rootViewController] _printHierarchy]
View context errors.swift
public struct Error: ErrorType {
let source: String; let reason: String
public init(_ source: String = __FILE__, _ reason: String) {
self.reason = reason; self.source = source
protocol Contextualizable {}
extension Contextualizable {
func functionContext(function : String = __FUNCTION__) -> String {
alemar11 / Trees.swift
Created Oct 27, 2015 — forked from CodaFi/Trees.swift
A small propositional logic proof tree generator and prover.
View Trees.swift
//: Playground - noun: a place where people can play
//: Prop 'til you Drop
indirect enum Formula : CustomStringConvertible {
case Var(String)
case Or(Formula, Formula)
case And(Formula, Formula)
case Imply(Formula, Formula)
case BiImply(Formula, Formula)
case Negate(Formula)
alemar11 / HttpStatusCode.swift
Created Oct 27, 2015 — forked from zacharyclaysmith/HttpStatusCode.swift
Http Status Code enum for Swift.
View HttpStatusCode.swift
// HttpStatusCode.swift
// Created by Zachary Smith on 5/1/15.
// Copyright (c) 2015 Zachary Smith. All rights reserved.
import Foundation
alemar11 / Emoji.swift
Created Oct 29, 2015 — forked from DJBen/Emoji.swift
View Emoji.swift
enum Emoji: String {
case Copyright = "\u{00A9}"
case Registered = "\u{00AE}"
case Bangbang = "\u{203C}"
case Interrobang = "\u{2049}"
case Tm = "\u{2122}"
case InformationSource = "\u{2139}"
case LeftRightArrow = "\u{2194}"
case ArrowUpDown = "\u{2195}"
case ArrowUpperLeft = "\u{2196}"
View where-where.swift
import Cocoa
// for-in
func checkForIn(array: [Int], dict: [Int: String]) {
for num in array where dict[num] != nil {
checkForIn([1,2,3,4], dict: [1:"one", 2:"two"])