This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSInteger)daysLeftTillChristmas { | |
// prepare to clean up | |
NSAutoreleasePool *daysPool = [[NSAutoreleasePool alloc] init]; | |
// get day | |
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
NSDate *today = [NSDate date]; | |
NSDateComponents *weekdayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:today]; | |
// test for after 12/25 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Boxes</title> | |
<style type="text/css" media="screen"> | |
.box { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -i -H "Accept: application/json" --digest -u "<useremail>:<password>" http://my.cl.ly/items |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reverseNum :: (Integral a) => a -> a | |
reverseNum 0 = 0 | |
reverseNum x = truncate 10 ^ (truncate (logBase 10.0 (fromIntegral x))) * (x `mod` 10) + reverseNum (x `quot` 10) | |
palindrome :: (Integral a) => a -> Bool | |
palindrome x = reverseNum x == x | |
lychrel :: (Integral a) => a -> a -> Bool | |
lychrel _ 100 = True | |
lychrel x y = if palindrome lych then False else lychrel lych (y + 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"); | |
var file = "file.txt", | |
sum = 0, | |
chars = []; | |
/// @summary: aggregate values | |
function aggregater(value) { | |
if (parseInt(value, 10).toString() === value.toString()) { | |
sum += parseInt(value, 10); | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | |
// Override point for customization after application launch. | |
[webView setDelegate:self]; | |
[webView loadHTMLString:@"<html><body><p id=\"content\">My Name is Josh</p></body></html>" baseURL:nil]; | |
[self.window makeKeyAndVisible]; | |
[self.window addSubview:webView]; | |
return YES; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static inline NSString *calculateURLForGravatar(NSString *email) { | |
const char *email_str = [email UTF8String]; | |
unsigned char result[CC_MD5_DIGEST_LENGTH]; | |
CC_MD5(email_str, strlen(email_str), result); | |
NSMutableString *hash = [NSMutableString stringWithString:@"http://www.gravatar.com/avatar/"]; | |
for (int i = 0; i < 16; i++) { | |
[hash appendFormat:@"%02x", result[i]]; | |
} | |
return [hash lowercaseString]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// TTPlaceholderTextView.h | |
// | |
// Created by Joshua Johnson on 1/6/12. | |
// Copyright (c) 2012 Two Toasters. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> | |
@interface TTPlaceholderTextView : UITextView |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSDictionary (Subtraction) | |
- (NSDictionary *)subtractDictionary:(NSDictionary *)dictionary; | |
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSMutableArray+TTAdditions.h | |
// tester | |
// | |
// Created by Joshua Johnson on 5/1/12. | |
// Copyright (c) 2012 Two Toasters, LLC. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> |
OlderNewer