Skip to content

Instantly share code, notes, and snippets.

@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

@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 / 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 / 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 / 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 / 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");
//
// 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>
#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
{
@codeswimmer
codeswimmer / url_properties.m
Created August 19, 2012 12:48 — forked from eienf/url_properties.m
check what is what of NSURL properties.
#import <Foundation/Foundation.h>
NSDictionary *dictionaryForURL(NSURL *aURL)
{
NSLog(@"scheme = %@ host = %@ port = %@ fragment = %@ lastPathComponent = %@ parameterString = %@ "
@"query = %@ user = %@ password = %@ resourceSpecifier = %@",
[aURL scheme],[aURL host],[aURL port],[aURL fragment],[aURL lastPathComponent],[aURL parameterString],
[aURL query],[aURL user],[aURL password],[aURL resourceSpecifier]);
NSLog(@"absoluteString = %@",[aURL absoluteString]);
@codeswimmer
codeswimmer / gist:3375904
Created August 17, 2012 04:22 — forked from BrettBukowski/gist:3375895
Display hex code for a UIColor
CGFloat red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0;
[someColor getRed:&red green:&green blue:&blue alpha:&alpha];
[someLabel setText:[NSString stringWithFormat:@"#%02X%02X%02X", (int) red * 255.0f, (int) green * 255.0f, (int) blue * 255.0f]];