Skip to content

Instantly share code, notes, and snippets.

@nicklockwood
nicklockwood / gist:9605636
Last active December 11, 2019 15:17
Singleton Category implementation
Singleton.h
-------------
@protocol Singleton
@optional
+ (instancetype)sharedInstance;
@end
@knownasilya
knownasilya / ajax.js
Last active June 22, 2016 14:37
RSVP jquery ajax wrapper
function ajax(url, options) {
return new Ember.RSVP.Promise(function (resolve, reject) {
options = options || {};
options.url = url;
options.success = function (data) {
Ember.run(null, resolve, data);
};
options.error = function () {
@orta
orta / Makefile
Created February 21, 2014 23:35
Artsy iOS makefile
WORKSPACE = Artsy.xcworkspace
SCHEME = Artsy
CONFIGURATION = Beta
APP_PLIST = Artsy/App/Art.sy-Info.plist
BUNDLE_ID = net.artsy.artsy.beta
PLIST_BUDDY = /usr/libexec/PlistBuddy
BUNDLE_VERSION = $(shell $(PLIST_BUDDY) -c "Print CFBundleVersion" $(APP_PLIST))
GIT_COMMIT = $(shell git log -n1 --format='%h')
ALPHA_VERSION = $(BUNDLE_VERSION)-$(BUILD_NUMBER)-$(GIT_COMMIT)
@implementation SomeVC
- (void)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)path
{
... cell = ....;
[self configureCell:cell forIndexPath:path];
return cell;
}
- (void)configureCell:(MyRatingCell*)cell forIndexPath:(NSIndexPath*)path
@pburleson
pburleson / gist:2784669
Created May 24, 2012 22:44
UIImagePNGRepresentation Crash
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x3602632c __pthread_kill + 8
1 libsystem_c.dylib 0x323de29f abort + 94
2 ImageIO 0x37eca8bf png_error + 114
3 ImageIO 0x37ec9fe3 png_write_end + 46
4 ImageIO 0x37ec6069 writeOnePng + 2260
5 ImageIO 0x37ec578b _CGImagePluginWritePNG + 82
6 ImageIO 0x37ec56fd CGImageDestinationFinalize + 132
7 UIKit 0x37342fa7 UIImagePNGRepresentation + 274
@atomicbird
atomicbird / NSObject+setValuesForKeysWithJSONDictionary.h
Created January 11, 2012 02:35
NSObject category for handling JSON dictionaries. Described in detail at http://www.cimgf.com/2012/01/11/handling-incoming-json-redux/
//
// NSObject+setValuesForKeysWithJSONDictionary.h
// SafeSetDemo
//
// Created by Tom Harrington on 12/29/11.
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@jonathanpenn
jonathanpenn / unix_instruments.sh
Last active January 26, 2016 19:09
Make Instruments play nice with unix by returning > 0 status code if build fails
#!/usr/bin/env bash
#
# Copyright (c) 2013 Jonathan Penn (http://cocoamanifest.net)
#
# 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 Software is
# furnished to do so, subject to the following conditions:
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//