Skip to content

Instantly share code, notes, and snippets.

#import <AppKit/AppKit.h>
#import <objc/runtime.h>
#import <objc/message.h>
@interface NSBitmapImageRep (Mapping)
- (void)map:(void (^)(NSUInteger[4]))aBlk;
@end
@implementation NSBitmapImageRep (Mapping)
- (void)map:(void (^)(NSUInteger[4]))aBlk
{
//
// NSObject+setValuesForKeysWithJSONDictionary.h
// SafeSetDemo
//
// Created by Tom Harrington on 12/29/11.
// Copyright (c) 2011 Atomic Bird, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@codeswimmer
codeswimmer / ShareController.m
Created August 21, 2012 17:22
MFMailComposeViewController issues
// ShareController.m (Conforms to MFMailComposeViewControllerDelegate)
- (void)createMailSheet {
MFMailComposeViewController *mailSheet = [MFMailComposeViewController new];
mailSheet.delegate = self; // Yells at me about conforming to UINavigationControllerDelegate, _not_ MFMailComposeViewControllerDelegate
[self.delegate presentShareSheet:mailSheet];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
NSLog(@"Hello");
@codeswimmer
codeswimmer / defconvid-downloader.sh
Created August 21, 2012 17:47 — forked from Famicoman/defconvid-downloader.sh
Def Con Video Downloader
#!/bin/bash
#Usage: ./defconvid-downloader.sh $id
#Where $id is the conference number
wget -c -nc -e robots=off --wait 5 -i -- `curl "http://defcon.org/html/links/dc-archives/dc-$1-archive.html" | grep -o "https.*\.m4v" | sed 's/ \+/%20/g'`
@codeswimmer
codeswimmer / memo-dyn.txt
Created August 24, 2012 18:44 — forked from fogus/memo-dyn.txt
Memoization vs dynamic programming
Memoization is fundamentally a top-down computation and dynamic
programming is fundamentally bottom-up. In memoization, we observe
that a computational *tree* can actually be represented as a
computational *DAG* (the single most underrated data structure in
computer science); we then use a black-box to turn the tree into a
DAG. But it allows the top-down description of the problem to remain
unchanged.
In dynamic programming, we make the same observation, but construct
the DAG from the bottom-up. That means we have to rewrite the
@codeswimmer
codeswimmer / fizzBuzzObjectiveC
Created August 24, 2012 19:04 — forked from pkamb/fizzBuzzObjectiveC
fizzBuzz in Objective-C
- (void)fizzBuzzObjectiveC
{
for(int i = 1; i <= 100; i++) {
NSString *output = @"";
if(i % 3 == 0)
output = [output stringByAppendingString:@"Fizz"];
if(i % 5 == 0)
output = [output stringByAppendingString:@"Buzz"];
@codeswimmer
codeswimmer / gotham.py
Created August 24, 2012 20:13 — forked from jart/gotham.py
Lorem Gotham w/ Rhyming
r"""
gotham
~~~~~~
Gothic Poetry Generator
"""
import marshal
@codeswimmer
codeswimmer / gist:3467178
Created August 25, 2012 15:37 — forked from hzlzh/gist:3467170
Chrome for iOS user-agents

Chrome for iOS user-agents

iPhone

Mozilla/5.0 (iPhone; U; CPU iPhone OS 5_1_1 like Mac OS X; en-gb)
AppleWebKit/534.46.0 (KHTML, like Gecko)
CriOS/19.0.1084.60 Mobile/9B206 Safari/7534.48.3

//
// iTahDoodleAppDelegate.m
// iTahDoodle
//
// Created by Henry Brock on 8/25/12.
// Copyright (c) 2012 brockbackups. All rights reserved.
//
#import "iTahDoodleAppDelegate.h"
NSString *docPath()
@codeswimmer
codeswimmer / ExampleClass.m
Created September 13, 2012 17:47
Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end