Skip to content

Instantly share code, notes, and snippets.

View larsacus's full-sized avatar

Lars Anderson larsacus

View GitHub Profile

Keybase proof

I hereby claim:

  • I am larsacus on github.
  • I am larsacus ( on keybase.
  • I have a public key whose fingerprint is 4F0E 87B0 42E0 8CDE 01DE C310 AB95 DD3F 493A C413

To claim this, I am signing this object: do |s| = 'CSPlaceKitten'
s.version = '0.0.1'
s.summary = 'Automatically place adorable kittens as place holder images on your image views.'
s.description = 'A place kitten category on top of the awesome UIImageView+AFNetworking category that will automatically place adorable kittens as place holder images on your image views.'
s.homepage = ''
s.license = {:type => 'MIT'} = {'Conrad Stoll' => ''}
s.requires_arc = true
s.platform = :ios, '5.0'
larsacus /
Last active December 11, 2015 17:39
HWWand *wand = [[HWWand alloc] init];
HWMagic *magic = [HWSpell genericSpell];
[wand setMagic:(__bridge HWSpell *)magic];
larsacus / PauseCAAnimation.m
Created January 10, 2012 15:46
Pauses and resumes all CA Animations on a CALayer - from
CFTimeInterval pausedTime = [layer convertTime:CACurrentMediaTime() fromLayer:nil];
layer.speed = 0.0;
layer.timeOffset = pausedTime;
CFTimeInterval pausedTime = [layer timeOffset];
larsacus / round.m
Created December 16, 2011 18:02
Round corner without clipsToBounds
// Clips the bottom left corner to a radius
CGSize cornerSize = CGSizeMake(10,10);
UIBezierPath *roundRectMaskPath = [UIBezierPath bezierPathWithRoundedRect:view.bounds
CAShapeLayer *roundRectMaskLayer = [CAShapeLayer layer];
roundRectMaskLayer.frame = self.view.bounds;
roundRectMaskLayer.path = roundRectMaskPath.CGPath;
larsacus / EagerPNG.m
Created November 14, 2011 21:52
"Eager" image deserialization - not mine - not sure where I found it - or how useful it may be...
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *deserializedImage = UIGraphicsGetImageFromCurrentImageContext()];
larsacus / PDF2UIImage.m
Created November 14, 2011 20:49
Render PDF document to UIImage
NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"pdf_name" ofType:@"pdf"];//this is assuming the pdf is in the main bundle
NSInteger pageNumber = 1;//for a one-page PDF
CGSize containerSize = self.imageView.bounds.size;
CGContextRef context = UIGraphicsGetCurrentContext();
const char *pdfFileName = [pdfPath cStringUsingEncoding:NSASCIIStringEncoding];
CGDataProviderRef pdfDataProvider = CGDataProviderCreateWithFilename(pdfFileName);
CGPDFDocumentRef myDocument = CGPDFDocumentCreateWithProvider(pdfDataProvider);
larsacus /
Created November 14, 2011 20:43
High-Resolution Timer Using Mach Time
#include "mach/mach_time.h" //NOT #import
mach_timebase_info_data_t mach_info;
uint64_t start = mach_absolute_time();
//do stuff to time
uint64_t finish = mach_absolute_time() - start;
larsacus / NIL_Termination.h
Created October 25, 2011 17:30
Enumerate a list of object specified in a prototype with NS_REQUIRES_NIL_TERMINATION. From
- (id)initWithTitle:(NSString *)title
animationImages:(UIImage *)firstImage, ...NS_REQUIRES_NIL_TERMINATION;
larsacus / ViewControllerWithAd.m
Created September 13, 2011 20:14
LARSAdController - Create Ad in View with View Controller
- (void)viewWillAppear:(BOOL)animated{
[[LARSAdController sharedManager] addAdContainerToView:[self view] withViewController:self];
[[LARSAdController sharedManager] setGoogleAdPublisherId:myPublisherId]; //change publisher id unless you want me to have your monies
[[LARSAdController sharedManager] layoutBannerViewsForCurrentOrientation:self.interfaceOrientation];
-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
[[LARSAdController sharedManager] layoutBannerViewsForCurrentOrientation:toInterfaceOrientation];