Skip to content

Instantly share code, notes, and snippets.

View benashman's full-sized avatar

Ben Ashman benashman

View GitHub Profile
@benashman
benashman / Prototype.swift
Last active March 14, 2017 17:00
Swift prototype helpers (WIP)
// Generate a random color
func randomColor() -> UIColor {
let hue : CGFloat = CGFloat(arc4random() % 256) / 256 // use 256 to get full range from 0.0 to 1.0
let saturation : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from white
let brightness : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from black
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1)
}
// Execute block after delay

Keybase proof

I hereby claim:

  • I am benashman on github.
  • I am benashman (https://keybase.io/benashman) on keybase.
  • I have a public key whose fingerprint is EE3E 9592 B9D3 D75F 5142 142D AD57 DD3C A5E3 E2E1

To claim this, I am signing this object:

@benashman
benashman / ughOS
Last active December 17, 2015 21:10
Adventures in border-radius…
@rounded_top_mask = CAShapeLayer.layer
@rounded_top_mask.path = UIBezierPath.bezierPathWithRoundedRect(@insight_header.bounds, byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight, cornerRadii: CGSizeMake(4, 4)).CGPath
@insight_header.layer.mask = @rounded_top_mask
.vs.
.insight-header {
border-radius: 4px 4px 0 0;
}
@benashman
benashman / legitDate
Last active December 17, 2015 12:28
Legit dates, yo.
var legitDate = function(y, m, d) {
var date = new Date(
y + "-" + ("0" + m).slice(-2) + "-" + ("0" + d).slice(-2)
);
return date;
};