Skip to content

Instantly share code, notes, and snippets.

View indragiek's full-sized avatar

Indragie Karunaratne indragiek

View GitHub Profile
@zachwaugh
zachwaugh / ZWDictionaryOfVariableBindings.m
Last active July 29, 2016 12:39
Experiment to figure out how NSDictionaryOfVariableBindings works, and try to make a more flexible version. This version strips underscores and supports self.* variables, but I'm sure there is a better way to do it.
#import <Foundation/Foundation.h>
// Experimental improvement to NSDictionaryOfVariableBindings where keys are simplified to remove underscores and "self." prefixes
// so you can use the simple version within the VFL string
//
// Example:
//
// [NSLayoutConstraint constraintsWithVisualFormat:@"|-[_foo]-[self.bar]-[baz]" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_foo, self.bar, baz)];
// -> this doesn't work, gives an error about "self."
//
@steipete
steipete / UITableViewMore.m
Last active January 29, 2018 14:19
Using the "More" button. Of course the simple way that Apple uses in Mail/iOS is not public. rdar://16600859
- (NSString *)tableView:(UITableView *)tableView titleForSwipeAccessoryButtonForRowAtIndexPath:(NSIndexPath *)indexPath {
return @"More";
}
- (void)tableView:(UITableView *)tableView swipeAccessoryButtonPushedForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"I wanted to be a pretty public API, but then time ran out and they forgot me...");
// Hide the More/Delete menu.
[self setEditing:NO animated:YES];
}
@kylesluder
kylesluder / ObjCSuper.m
Last active August 29, 2015 13:56
An Objective-C analogue to the Python super class.
// % clang -framework Foundation -o ObjCSuper ObjCSuper.m SuperTrampoline.s
// % ./ObjCSuper
//
// 2014-02-15 23:03:32.498 ObjCSuper[1296:507] Subclass impl
// 2012014-02-15 23:03:32.498 ObjCSuper[1296:507] Subclass impl4-02-15 23:03:32.500 ObjCSuper[1296:507] b respondsToSelector:@selector(retain)? YES
// 2014-02-15 23:03:32.500 ObjCSuper[1296:507] b respondsToSelector:@selector(subclassMethod)? YES
// 2014-02-15 23:03:32.501 ObjCSuper[1296:507] Superclass impl
// 2014-02-15 23:03:32.501 ObjCSuper[1296:507] b_super respondsToSelector:@selector(retain)? YES
// 2014-02-15 23:03:32.501 ObjCSuper[1296:507] b_super respondsToSelector:@selector(subclassMethod)? NO
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active July 16, 2025 04:34
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@andrewmichaelson
andrewmichaelson / PSPDFUIKitMainThreadGuard.m
Last active March 15, 2016 09:36 — forked from steipete/PSPDFUIKitMainThreadGuard.m
Modified to work with AppKit on OS X instead of UIKit on iOS.
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2013 Peter Steinberger. 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>
#import <Foundation/Foundation.h>
@landonf
landonf / xcode-gripes.md
Last active August 21, 2020 09:06
Every time I hit something that annoys me in Xcode, I add the feature/UX improvement/change I'd like to the list.

Xcode Wish List:

Legacy Support

  • Additional optional downloads:
    • Older SDKs, eg, for building ancient projects.
    • Older compilers (for same).
  • Either ship gcc/llvm-gcc or don't. Don't ship clang and call it 'gcc', that just breaks anyone who actually needs GCC and finds your not-gcc in the PATH.

UX

Project/File Navigation

@mertdumenci
mertdumenci / rdio_collection_export.js
Last active January 1, 2016 13:49
Switch to the list mode in collection view, scroll to the bottom and load all the songs and run this code. You can import it to Spotify using Ivy (ivyishere.org).
javascript:(function() {
var bookmarklet = {
init: function() {
this.parse();
},
parse: function() {
page = "";
$(".collection")
.children(".collection_items")
.find(".Track")
@rnapier
rnapier / gist:7515273
Created November 17, 2013 16:38
Exploration of thread priorities vs queue priorities
// Main thread priorty = 0.758065
NSLog(@"main:%@:%f", [NSThread currentThread], [NSThread threadPriority]);
// High priority = 0.532258
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSLog(@"high:%@:%f", [NSThread currentThread], [NSThread threadPriority]);
// run forever! Note that other queues still happily process, even though our high-priority block never ends
while(1) {}
});
@philfreo
philfreo / gist:7257723
Created October 31, 2013 21:44
Facebook Perl source code from 2005. When browsing around thefacebook.com in 2005 the server spit out some server-side source code rather than running it. I believe this was for their old graph feature that let you visualize the graph between all your friends. The filename is `mygraph.svgz` and contains some gems such as a commented out "zuck" d…
#!/usr/bin/perl
use Mysql;
use strict;
use vars qw($school_name);
use vars qw($pass);
require "./cgi-lib.pl";
@numist
numist / gist:6929738
Last active December 25, 2015 06:09
No clang diagnostic pragmas, the only trick is stuffing NSAutoreleasePool into a local to avoid the deprecation-under-ARC warning.
// Built for ARC, remove the __bridge and it should work in MRC as well.
void *NNCFAutorelease(CFTypeRef cfObject)
{
if (cfObject) {
static Class arp = Nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
arp = NSClassFromString(@"NSAutoreleasePool");
Assert(arp);
});