Skip to content

Instantly share code, notes, and snippets.

View hollance's full-sized avatar

Matthijs Hollemans hollance

View GitHub Profile
@ingramj
ingramj / brainfuck.rb
Created February 25, 2009 00:37
A Brainfuck interpreter written in Ruby.
#!/usr/bin/env ruby
class BrainFuck
def initialize
@ops = create_ops
@tape = Array.new(1024,0)
@tp = 0
@code = []
@cp = 0
end
#!/usr/bin/perl
#
# This script parses a crashdump file and attempts to resolve addresses into function names.
#
# It finds symbol-rich binaries by:
# a) searching in Spotlight to find .dSYM files by UUID, then finding the executable from there.
# That finds the symbols for binaries that a developer has built with "DWARF with dSYM File".
# b) searching in various SDK directories.
#
# Copyright (c) 2008-2009 Apple Inc. All Rights Reserved.
@PsychoH13
PsychoH13 / NSMutableData+PSYDataWriter.h
Created August 3, 2010 23:00
A class enabling NSData object scanning and a category enabling NSMutableData writing.
/*
NSMutableData+PSYDataWriter.h
Created by Remy "Psy" Demarest on 22/01/2012.
Copyright (c) 2012. Remy "Psy" Demarest
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
@alloy
alloy / FTAccessibleActionSheet.m
Created May 3, 2011 13:28
A UIActionSheet subclass that customizes the accessibility labels of the options in the sheet.
// Copyright (c) 2011 Eloy Durán <[email protected]>
// Available under the MIT license: http://www.opensource.org/licenses/mit-license.php
#import <objc/message.h>
@interface FTAccessibleActionSheet : UIActionSheet
- (void)copyAccessibilityMetadataFrom:(NSString *)title toControl:(UIView *)control;
@end
@implementation FTAccessibleActionSheet
@omz
omz / gist:1102091
Created July 24, 2011 01:40
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
dispatch_block_t RecursiveBlock(void (^block)(dispatch_block_t recurse))
{
// assuming ARC, so no explicit copy
return ^{ block(RecursiveBlock(block)); };
}
typedef void (^OneParameterBlock)(id parameter);
OneParameterBlock RecursiveBlock1(void (^block)(OneParameterBlock recurse, id parameter))
{
@mikeash
mikeash / blockforward.m
Created October 21, 2011 02:38
NSInvocation works for blocks too!
#import <dlfcn.h>
#import <Foundation/Foundation.h>
struct BlockDescriptor
{
unsigned long reserved;
unsigned long size;
void *rest[1];
#import <UIKit/UIKit.h>
@class BDSegmentedControl;
@protocol BDSegmentedControlDelegate <NSObject>
- (NSUInteger)segmentedControl:(BDSegmentedControl *)segmentedControl numberOfMenuItemsForSegmentAtIndex:(NSUInteger)segmentIndex;
- (UIImage *)segmentedControl:(BDSegmentedControl *)segmentedControl imageForMenuBackgroundForSegmentAtIndex:(NSUInteger)segmentIndex;
- (UIImage *)segmentedControl:(BDSegmentedControl *)segmentedControl imageForMenuItemAtIndex:(NSUInteger)menuItemIndex forSegmentAtIndex:(NSUInteger)segmentIndex;
- (UIImage *)segmentedControl:(BDSegmentedControl *)segmentedControl imageForSelectedMenuItemAtIndex:(NSUInteger)menuItemIndex forSegmentAtIndex:(NSUInteger)segmentIndex;
@mattt
mattt / uiappearance-selector.md
Last active September 24, 2024 12:59
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' | \
//
// NudgeModel.h
// NudgeFoundation
//
// Created by Jeremy Tregunna on 10/7/2013.
// Copyright (c) 2013 Jeremy Tregunna. All rights reserved.
//
#import <Foundation/Foundation.h>