Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View adamrothman's full-sized avatar

Adam Rothman adamrothman

View GitHub Profile
extension UIColor {
convenience init(hex: UInt32, alpha: CGFloat = 1.0) {
self.init(
red: CGFloat((hex & 0xff0000) >> 16) / 256.0,
green: CGFloat((hex & 0x00ff00) >> 8) / 256.0,
blue: CGFloat(hex & 0x0000ff) / 256.0,
alpha: alpha
)
}
"""Firebase-style 120-bit unique identifiers.
https://www.firebase.com/blog/2015-02-11-firebase-unique-identifiers.html
"""
from math import floor
from random import random
from string import ascii_lowercase
from string import ascii_uppercase
from string import digits
from time import time
@adamrothman
adamrothman / DataStructures.swift
Last active March 25, 2016 00:37
Useful data structures in Swift 2.2
/**
Hi
*/
@adamrothman
adamrothman / ddns.py
Last active March 4, 2016 22:44
Update a Route 53 record with your current external IP address
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import re
import sys
from argparse import ArgumentParser
from datetime import datetime
from subprocess import CalledProcessError
from subprocess import check_output
@adamrothman
adamrothman / S3Upload.swift
Last active July 14, 2017 08:33
Upload a UIImage to S3 and get its URL
/*
* Credit to JC https://github.com/kharmabum for most of this code.
*
* Frameworks used:
* - Alamofire https://github.com/Alamofire/Alamofire
* - Async https://github.com/duemunk/Async
* - AWS SDK http://aws.amazon.com/mobile/sdk/
*/
import Foundation
@adamrothman
adamrothman / keybase.md
Created January 25, 2015 20:16
Proof of identity for Keybase

Keybase proof

I hereby claim:

  • I am adamrothman on github.
  • I am adamrothman (https://keybase.io/adamrothman) on keybase.
  • I have a public key whose fingerprint is 6B1B 6368 2EB3 5A31 1F0F A7C3 F1F4 6D17 32DB 4649

To claim this, I am signing this object: