Skip to content

Instantly share code, notes, and snippets.

View jawj's full-sized avatar

George MacKerron jawj

View GitHub Profile
@jawj
jawj / CAMediaTimingFunction+GMTimingBlock.h
Last active January 22, 2017 03:42
An easing category on CAMediaTimingFunction, with thanks to Mozilla
//
// CAMediaTimingFunction+GMTimingBlock.h
//
// Created by George MacKerron on 2015/06/11.
// Copyright (c) 2015 George MacKerron. All rights reserved.
//
#import <QuartzCore/QuartzCore.h>
@jawj
jawj / crc.coffee
Last active August 29, 2015 14:13
String CRC in CoffeeScript
# tested against OS X cksum: `echo -n 'hello' | cksum -o 3` == "hello".crc32()
String.CRC32Table = # ref: http://www.w3.org/TR/PNG/#D-CRCAppendix
for c in [0..255] # (can clobber c with impunity below thanks to CoffeeScript)
for k in [0..7]
c = if c & 1 then 0xedb88320 ^ (c >>> 1) else (c >>> 1)
c >>> 0
String::crc32 = (crc = 0xffffffff) ->
for i in [0...@length] by 1
@jawj
jawj / AlignmentRectRespectingSlider.h
Last active August 29, 2015 14:06
A UISlider subclass for iOS7 that respects alignmentRectInsets on custom thumb images
@interface AlignmentRectRespectingSlider : UISlider
@end