Skip to content

Instantly share code, notes, and snippets.

View gurgeous's full-sized avatar

Adam Doppelt gurgeous

  • Seattle, WA
View GitHub Profile
@gurgeous
gurgeous / gist:5580856
Created May 15, 2013 00:36
convert blue favorite stars to orange favorite stars with imagemagick
FILES = %w(
drawable-hdpi/btn_star_off_disabled_focused_holo_dark.png
drawable-hdpi/btn_star_off_disabled_holo_dark.png
drawable-hdpi/btn_star_off_focused_holo_dark.png
drawable-hdpi/btn_star_off_normal_holo_dark.png
drawable-hdpi/btn_star_off_pressed_holo_dark.png
drawable-hdpi/btn_star_on_disabled_focused_holo_dark.png
drawable-hdpi/btn_star_on_disabled_holo_dark.png
drawable-hdpi/btn_star_on_focused_holo_dark.png
drawable-hdpi/btn_star_on_normal_holo_dark.png
List of banned twitter usernames:
@account
@activity
@badges
@blocks
@bouncers
@contacts
@devices
@discuss
### Keybase proof
I hereby claim:
* I am gurgeous on github.
* I am amd (https://keybase.io/amd) on keybase.
* I have a public key whose fingerprint is 4648 089F 413E BA29 4EB9 1128 4450 6F43 3F8E B428
To claim this, I am signing this object:
@gurgeous
gurgeous / objc_to_swift.rb
Last active February 5, 2016 18:11
Convert simple objc to swift
#!/usr/bin/env ruby
#
# This is a braindead objc => swift converter. It only handles a few things,
# but it saved me many hours of mechanical translation. The output still
# requires editing.
#
# Many thinsg aren't handled. Most things, in fact. Have fun!
#
# Usage: objc_to_swift.rb Somefile.m
@gurgeous
gurgeous / CGMath.swift
Last active April 13, 2021 15:52
missing operators for CGPoint, CGSize and CGRect
//
// MARK: CGPoint op point/size/float
//
func -(l: CGPoint, r: CGPoint) -> CGPoint { return CGPoint(x: l.x - r.x, y: l.y - r.y) }
func +(l: CGPoint, r: CGPoint) -> CGPoint { return CGPoint(x: l.x + r.x, y: l.y + r.y) }
func *(l: CGPoint, r: CGPoint) -> CGPoint { return CGPoint(x: l.x * r.x, y: l.y * r.y) }
func /(l: CGPoint, r: CGPoint) -> CGPoint { return CGPoint(x: l.x / r.x, y: l.y / r.y) }
func -(l: CGPoint, r: CGSize) -> CGPoint { return CGPoint(x: l.x - r.width, y: l.y - r.height) }
@gurgeous
gurgeous / SwiftWishlist.md
Last active August 29, 2015 14:09
Swift syntactic sugar wishlist

Regex literals and operators

let re = /regex/
if "xyz" =~ /regex/ {  }

Optionals as conditionals

@gurgeous
gurgeous / MKMath
Created November 15, 2014 00:11
missing operators for MKMapPoint, MKMapSize and MKMapRect
//
// MARK: MKMapPoint op point/size/float
//
func -(l: MKMapPoint, r: MKMapPoint) -> MKMapPoint { return MKMapPoint(x: l.x - r.x, y: l.y - r.y) }
func +(l: MKMapPoint, r: MKMapPoint) -> MKMapPoint { return MKMapPoint(x: l.x + r.x, y: l.y + r.y) }
func *(l: MKMapPoint, r: MKMapPoint) -> MKMapPoint { return MKMapPoint(x: l.x * r.x, y: l.y * r.y) }
func /(l: MKMapPoint, r: MKMapPoint) -> MKMapPoint { return MKMapPoint(x: l.x / r.x, y: l.y / r.y) }
func -(l: MKMapPoint, r: MKMapSize) -> MKMapPoint { return MKMapPoint(x: l.x - r.width, y: l.y - r.height) }
@gurgeous
gurgeous / UIColor.swift
Created November 15, 2014 00:13
UIColor enhancements
extension UIColor {
//
// MARK: create with hex string
//
convenience init(string: String) {
// strip leading pound
let s = string.stringByReplacingOccurrencesOfString("#", withString: "")
var r = UInt32(0)
@gurgeous
gurgeous / NSDate.swift
Created November 16, 2014 21:32
NSDate extensions
private var NSDateFormatters = [ String: NSDateFormatter ]()
extension NSDate {
//
// MARK: today
//
// like NSDate(), but doesn't set any time components so it's always 8am. When
// we get dates off the wire they are always set to 8am. Having all our "dates"
// with identical times makes comparisons easier.
@gurgeous
gurgeous / annotate_box.rb
Created July 9, 2015 21:21
RMagick - autoscale text within a box, like iOS UILabel
class Magick::Draw
# Autoscale text within a box. The text will be scaled to fit if the
# specified pointsize is too big. If minscale is set and the text still
# won't fit at minscale * pointsize, it gets ellipsized. halign/valign can
# be used to set horizontal and vertical alignment. This is similar to the
# behavior of iOS UILabel.
def annotate_box(image:, text:, x:, y:, w:, h:, pointsize:, minscale: nil, halign: 0, valign: 0)
draw = self.clone
draw.pointsize = pointsize
draw.gravity = Magick::NorthWestGravity