Skip to content

Instantly share code, notes, and snippets.

@kasima
kasima / double_closures.py
Created October 18, 2010 09:42
Favorite piece of code I wrote last week
# double closures - what does it mean!?
def if_braintree_disabled(default):
def generate_decorator(f):
def decorator(*args, **kwargs):
if not settings.LIVE_SITE and not settings.BRAINTREE_ENABLED:
return default
else:
return f(*args, **kwargs)
return decorator
return generate_decorator
@steipete
steipete / UIImage+PSPDFKitAdditions.m
Created August 13, 2011 20:52
Preload UIImage for super-smooth interaction. especially great if you use JPGs, which otherwise produce a noticeable lag on the main thread.
- (UIImage *)pspdf_preloadedImage {
CGImageRef image = self.CGImage;
// make a bitmap context of a suitable size to draw to, forcing decode
size_t width = CGImageGetWidth(image);
size_t height = CGImageGetHeight(image);
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace,
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little);
@mediabounds
mediabounds / floatsign.sh
Last active March 31, 2024 18:43
A small bash script to re-sign iOS applications.
# !/bin/bash
# Copyright (c) 2011 Float Mobile Learning
# http://www.floatlearning.com/
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
@DavidBarry
DavidBarry / SDViewWithNibLayout.h
Created January 22, 2012 12:40
This is a subclass of UIView to reduce boilerplate code when using Interface Builder to layout a custom UIView subclass.
#import <UIKit/UIKit.h>
@interface SDViewWithNibLayout : UIView
+ (id)viewFromNib;
+ (NSString *)nibName;
@end
@nfarina
nfarina / UIView+FrameAdditions.h
Created August 21, 2012 06:40
UIView Frame helper getter/setter category methods
#import <UIKit/UIKit.h>
@interface UIView (SMFrameAdditions)
@property (nonatomic, assign) CGPoint $origin;
@property (nonatomic, assign) CGSize $size;
@property (nonatomic, assign) CGFloat $x, $y, $width, $height; // normal rect properties
@property (nonatomic, assign) CGFloat $left, $top, $right, $bottom; // these will stretch the rect
@end
@girasquid
girasquid / setup.sh
Created September 17, 2012 04:35
How I deploy my side projects
curl -L http://path-to-setup.sh | bash
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add [email protected]:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

Pod::Spec.new do |s|
s.name = 'PSPDFKit'
s.version = '3.0.8'
s.license = 'Commercial'
s.summary = 'PSPDFKit - The definitive framework for displaying and annotating PDFs in your iOS apps.'
s.homepage = 'http://PSPDFKit.com'
s.author = { 'PSPDFKit GmbH' => '[email protected]' }
s.platform = :ios, '5.0'
s.source = { :git => 'https://github.com/PSPDFKit/PSPDFKit.git' }
@JaviSoto
JaviSoto / gist:5906004
Last active June 27, 2023 10:25
Mark designated initializer at compile time
#define MSDesignatedInitializer(__SEL__) __attribute__((unavailable("Invoke the designated initializer `" # __SEL__ "` instead.")))
// Sample usage:
- (instancetype)initWithObject:(id)object;
- (instancetype)init MSDesignatedInitializer(initWithObject:); // <- This even gets auto-complete.
// Now calling init on this class would throw a warning.
@raven
raven / Breakpoints_v2.xcbkptlist
Last active August 30, 2019 00:53
Symbolic breakpoint for dynamically linking libReveal against UIApplicationMain
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SymbolicBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"