Skip to content

Instantly share code, notes, and snippets.

View numist's full-sized avatar

Scott Perry numist

View GitHub Profile
@oogali
oogali / tmbo.sh
Created January 8, 2011 03:39
tmbo command-line uploader
#!/bin/sh
## tmbo.sh -- my attempt at posting from the command line
## tmbo: lnk, twitter: @oogali
##
BASE_URL=thismight.be/offensive
TMBO_CONFIG=${HOME}/.tmbo
TMPPATH=/tmp
usage() {
echo "$0 <options> <image to upload> [filename]"
@benstiglitz
benstiglitz / sys_param-better.h
Created August 11, 2011 15:37
Hygenic and shadow-safe MIN.
#define MIN_PASTE(A,B) A##B
#define MIN_IMPL(A,B,L) ({ __typeof__(A) MIN_PASTE(__a,L) = (A); __typeof__(B) MIN_PASTE(__b,L) = (B); MIN_PASTE(__a,L) < MIN_PASTE(__b,L) ? MIN_PASTE(__a,L) : MIN_PASTE(__b,L); })
#define MIN(A,B) MIN_IMPL(A,B,__COUNTER__)
@erisdev
erisdev / Poser.m
Created March 11, 2012 04:09
Miss +[NSObject poseAsClass:]? Don't use this, you might hurt yourself or someone you love.
#import <objc/runtime.h>
#import <stdlib.h>
// declare some of the Objective-C runtime's private parts where we can see them
typedef struct _NXMapTable NXMapTable;
extern NXMapTable *gdb_objc_realized_classes;
extern void *NXMapInsert(NXMapTable *table, const void *key, const void *value);
@implementation NSObject (Poser)
@iamleeg
iamleeg / pileOfPoo.m
Created March 22, 2012 01:51
The pile of poo Objective-C method
#import <Foundation/Foundation.h>
@interface A: NSObject
@end
@implementation A
void pileOfPoo(id self, SEL _cmd) {
NSLog(@"💩");
}
- (BOOL)isNetworkActivityIndicatorVisible {
return _activityCount > 0;
}
- (void)incrementActivityCount {
[self willChangeValueForKey:@"activityCount"];
OSAtomicIncrement32((int32_t*)&_activityCount);
[self didChangeValueForKey:@"activityCount"];
}
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 7, 2024 06:03
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@steipete
steipete / gist:3933090
Created October 22, 2012 18:13
Simple main thread usage detector that I'm using in PSPDFKit to find performance problems early on.
// Smart little helper to find main thread hangs. Enable in appDidFinishLaunching.
// Only available with source code in DEBUG mode.
@interface PSPDFHangDetector : NSObject
+ (void)startHangDetector;
@end
@implementation PSPDFHangDetector
+ (void)startHangDetector {
#ifdef DEBUG
@steipete
steipete / gist:4666527
Created January 29, 2013 18:43
Exif -> UIImageOrientation
// Convert an EXIF image orientation to an iOS one.
// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html
+ (UIImageOrientation) exifOrientationToiOSOrientation:(int)exifOrientation {
UIImageOrientation o = UIImageOrientationUp;
switch (exifOrientation) {
case 1: o = UIImageOrientationUp; break;
case 3: o = UIImageOrientationDown; break;
case 8: o = UIImageOrientationLeft; break;
case 6: o = UIImageOrientationRight; break;
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
///////////////////////////////////////////////////////////////////////////////////////////
#pragma mark - Warn if we KVO a weak property
// Doesn't support key paths.
static BOOL PSPDFIsWeakProperty(id object, NSString *keyPath) {
objc_property_t property = class_getProperty([object class], keyPath.UTF8String);
if (property) {
// https://developer.apple.com/library/mac/documentation/cocoa/conceptual/objcruntimeguide/articles/ocrtpropertyintrospection.html
const char *attributes = property_getAttributes(property);
return attributes && strstr(attributes, ",W");