Skip to content

Instantly share code, notes, and snippets.

#import <UIKit/UIKit.h>
@interface UIScrollView (KeyboardInsets)
- (void)addInsetsForKeyboardHandlers;
- (void)removeInsetsForKeyboardHandlers;
@end
@mattyohe
mattyohe / gist:3d3fb08cb29e459a7442
Last active August 29, 2015 14:14
This will crash kexmex!
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self addObserver:self forKeyPath:@"DERP" options:NSKeyValueObservingOptionNew context:nil];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
@mattyohe
mattyohe / gist:4f685131b0674e4354c4
Created March 10, 2015 21:57
uncompiled swift code (probably has errors!)
class PlayerView : UIView {
var player: AVPlayer {
get{
var layer = self.layer as AVPlayerLayer
return layer.player
}
set {
var layer: AVPlayerLayer = self.layer as AVPlayerLayer
layer.player = newValue
@mattyohe
mattyohe / PSPDFUIKitMainThreadGuard.m
Created September 25, 2015 19:36 — forked from steipete/PSPDFUIKitMainThreadGuard.m
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.
#import <objc/runtime.h>
#import <objc/message.h>
// Compile-time selector checks.
@mattyohe
mattyohe / gist:1193584
Created September 4, 2011 21:58
Simple sorting of an array of dictionaries using the NSComparator block
NSMutableArray *mutArry = [[NSMutableArray alloc] init];
// Fill array with 20 dictionaries that each contain a NSNumber for key "num"
for(int i = 0;i<20;i++){
NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithInt:arc4random()%100], @"num", nil];
[mutArry addObject:dict];
}
@mattyohe
mattyohe / gist:1370876
Created November 16, 2011 18:21
My Drupal 7 Profiler script that corrects taxonomy vocabulary and loads terms from an xml file
<?php
!function_exists('profiler_v2') ? require_once('libraries/profiler/profiler.inc') : FALSE;
profiler_v2('ppc_test');
/**
* Implement hook_install().
*
@mattyohe
mattyohe / Evil.m
Created February 2, 2012 01:47 — forked from PsychoH13/Evil.m
Debauching ObjC's dot-syntax and blocks in ObjC
#import <Foundation/Foundation.h>
@interface NSString (Evil)
@property(assign, setter=initWithString:) NSString *initWithString;
@property(assign, readonly) NSString *test;
@property(assign, readonly) NSArray *(^split)(NSString *);
@end
int main(int argc, char *argv[])
{
#
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
#
# Do NOT simply read the instructions in here without understanding
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
# make ls display colors, reinforce with CLICOLOR and LSCOLORS
export CLICOLOR=1
# LSCOLORS order: DIR, SYM_LINK, SOCKET, PIPE, EXE, BLOCK_SP
# CHAR_SP, EXE_SUID, EXE_GUID, DIR_STICKY, DIR_WO_STICKY
# a = black, b = red, c = green, d = brown, e = blue,
# f = magenta g = cyan, h = light gray, x = default
@mattyohe
mattyohe / gist:2624831
Created May 6, 2012 22:30
Stringify the the value of a macro and turn that into an NSString constant
#define DERP 1234
#define MACRO_NAME(str) @ #str
#define STRINGIFY(str) MACRO_NAME(str)
NSLog(@"%@",MACRO_NAME(DERP));
NSLog(@"%@",STRINGIFY(DERP));
// Output: