Skip to content

Instantly share code, notes, and snippets.

@interface UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path;
@end
@implementation UIImage(ImmediateLoad)
+ (UIImage*)imageImmediateLoadWithContentsOfFile:(NSString*)path {
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path];
@bignerdranch
bignerdranch / BNRTimeBlock.h
Created March 9, 2012 13:51
Timing Utility Post 20120308
CGFloat BNRTimeBlock (void (^block)(void));
@brandonb927
brandonb927 / image-2x.less
Last active December 1, 2019 15:38
@2x LESS CSS Mixin
/**
* I converted the SCSS mixin to LESS for the awesome coders like myself in response to a blog post on 37Signals - http://37signals.com/svn/posts/3271-easy-retina-ready-images-using-scss
*
* Update: 2014-08-04 - Updated a long-standing bug where retina images were shown no matter what in the first background-image property.
* - Updated retina media query to be more reliable ()
* Update: 2013-11-13 - Picked up another technique thanks to reading this post from Tyler Tate, auto-fill in the second filename for the retina image, http://tylertate.com/blog/2013/06/11/retina-images-using-media-queries-and-LESS-CSS.html
* Update: 2013-04-16 - Have recently found a few use cases when using a retina pattern from Subtle Patterns on the <body>, this has come in handy
* Update: 2013-04-05 - Some research in the Wordpress Core(http://core.trac.wordpress.org/ticket/22238#comment:5) was pointed out that some tests may be redundant (Thanks @kbav) so I've cleaned these up
* Update: 2012-12-29 - U
@ryanmaxwell
ryanmaxwell / ryan-objc.cfg
Last active June 26, 2019 16:41
Objective-C Uncrustify Config
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.2 (140)
#
# Alignment
# ---------
## Alignment
@Gi-lo
Gi-lo / gist:4279932
Created December 13, 2012 21:11
Easily create GET NSURLs in Objective-C. (Used in https://github.com/Gi-lo/GCXHTTPOperation )
- (NSURL *)URLWithString:(NSString *)string andQueryValuesForKeys:(NSString *)value, ... {
if (!value) {
return [NSURL URLWithString:string];
}
NSMutableString *queryString = [NSMutableString string];
NSString *argument = nil;
NSUInteger argumentCount = 0;
va_list argumentList;
@gavrix
gavrix / gist:5054182
Created February 28, 2013 04:28
Script integrating OCLint into XCode. Put it in "Run script" build phase.
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
@lqi
lqi / gist:5358513
Last active July 29, 2017 14:33 — forked from gavrix/gist:5054182
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
cd ${TARGET_TEMP_DIR}
@nickfishman
nickfishman / gzipRequestTest.js
Last active July 21, 2021 22:16
Second attempt at conditional gzip decoding based on the Content-Encoding response header with the mikeal/request library for Node.js. This DOES work.
var request = require('request'),
zlib = require('zlib');
var headers = {
"accept-charset" : "ISO-8859-1,utf-8;q=0.7,*;q=0.3",
"accept-language" : "en-US,en;q=0.8",
"accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
"accept-encoding" : "gzip,deflate",
};
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active March 10, 2024 19:23
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@markd2
markd2 / NSObject+setValuesForKeysWithJSONDictionary.h
Created July 18, 2013 13:44
Support files for Inside the Bracket Part 6, showing an actual use of the objective-C runtime API.
//
// NSObject+setValuesForKeysWithJSONDictionary.h
//
// Created by Tom Harrington on 12/29/11.
// Tweaked by Mark Dalrymple
//
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>