Skip to content

Instantly share code, notes, and snippets.

View haydenholligan's full-sized avatar

Hayden Holligan haydenholligan

View GitHub Profile
@haydenholligan
haydenholligan / svimrc
Last active January 24, 2019 14:54
sVimrc
let blacklists = ["*://jupyter.student.cs.uwaterloo.ca/*", "http://localhost:8888/notebooks/Documents/*"]
@haydenholligan
haydenholligan / Clock.swift
Last active October 14, 2017 16:03
A Swift struct for a Clock.
//You can get the time components, but can only increment 1 second at a time.
struct Clock {
var seconds: Int = 0 {
didSet {
if seconds == 60 {
minutes += 1
seconds = 0
}
@haydenholligan
haydenholligan / UIColor+Hex
Created December 20, 2016 19:04
Hex (AARRGGBB) -> UIColor init
convenience init(hex: String) {
var rgbValue:UInt32 = 0
Scanner(string: hex).scanHexInt32(&rgbValue)
self.init(red: CGFloat((rgbValue & 0x00FF0000) >> 16) / 255.0,
green: CGFloat((rgbValue & 0x0000FF00) >> 8) / 255.0,
blue: CGFloat(rgbValue & 0x000000FF) / 255.0,
alpha: CGFloat((rgbValue & 0xFF000000) >> 24) / 255.0)
}
@haydenholligan
haydenholligan / Create iOS Icons.jsx
Last active August 13, 2016 04:09 — forked from twonjosh/Create iOS Icons.jsx
Photoshop Script to Create iOS Icons from a source image
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com
//Because swift thinks remainder is cooler than modulus
func modulus(number: Double, modulo: Double) -> Double {
var result = number % modulo
if result < 0 {
result += modulo
}
return result
}
func pointPairToDegrees(from: CGPoint, to: CGPoint) -> Double {
let origin = CGPointMake(to.x - from.x, to.y - from.y)
let bearingRadians = Double(atan2f(Float(origin.y), Float(origin.x)))
let bearingDegrees = bearingRadians * (180 / M_PI)
return modulus(bearingDegrees, modulo: 360)
}
func modulus(number: Double, modulo: Double) -> Double {
var result = number % modulo
if result < 0 {