Skip to content

Instantly share code, notes, and snippets.

@sergeytimoshin
sergeytimoshin / notif.mm
Created June 7, 2013 19:36
Catch all notifications
[[NSNotificationCenter defaultCenter] addObserverForName:nil object:nil queue:nil usingBlock:^(NSNotification *note) {
NSLog(@"Catch-All: %@", note);
}];
@sergeytimoshin
sergeytimoshin / uianimationdragcoefficient.m
Last active December 18, 2015 05:19
UIAnimationDragCoefficient
void *UIKit = dlopen([[[NSBundle bundleForClass:[UIApplication class]] executablePath] fileSystemRepresentation], RTLD_LAZY);
CGFloat (*UIAnimationDragCoefficient)(void) = (CGFloat (*) (void)) dlsym(UIKit, "UIAnimationDragCoefficient");
DLog(@"coefficient is %f", UIAnimationDragCoefficient ? UIAnimationDragCoefficient() : 1.f);
@sergeytimoshin
sergeytimoshin / dict.m
Last active December 14, 2015 17:59
Dictionary.app to console output.
/* clang -fobjc-arc -framework Foundation -framework CoreServices dict.m -o dict */
#import <Foundation/Foundation.h>
#import <CoreServices/CoreServices.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
if(argc < 2)
{
@sergeytimoshin
sergeytimoshin / atomic.m
Created October 31, 2012 22:05 — forked from markd2/atomic.m
Exploring the 'atomic' keyword in properties.
#import <Foundation/Foundation.h>
// clang -g -Wall -framework Foundation -o atomic atomic.m
// gcc -g -Wall -framework Foundation -o atomic atomic.m
@interface Blah : NSObject
@property (assign, NS_NONATOMIC_IOSONLY) NSInteger frobnozzle;
@property (assign, ) NSInteger commaAtEnd;
// @property (, assign) NSInteger commaAtBeginning; // Syntax error
@property (atomic, assign) NSInteger blah; // complains in gcc
@sergeytimoshin
sergeytimoshin / gist:3921145
Created October 19, 2012 22:41
mapbox save as image
- (UIImage *) loadMapImage {
const int MINZOOM = 13;
const int MAXZOOM = 17;
// TODO: calculate these from list of cycle hire locations
const float MINLAT = 51.483145; //minimum and max lattitude in degrees
const float MAXLAT = 51.542138;
const float MINLONG = -0.2242237; //min and max longitutde in degrees
const float MAXLONG = -0.002275;
@sergeytimoshin
sergeytimoshin / clean_assets.rb
Created October 19, 2012 21:11 — forked from soffes/clean_assets.rb
Rake task to clean unused images in your iOS project
desc 'Remove unused images'
task :clean_assets do
require 'set'
all = Set.new
used = Set.new
unused = Set.new
# White list
used.merge %w{Icon Icon-29 Icon-50 Icon-58 Icon-72 Icon-114}