This file contains 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
struct color { | |
const char* name; | |
float hue; | |
float size; | |
}; | |
color colors[6] = { | |
{ "red", 0.0, 20.0 }, | |
{ "orange" , 30.0, 15.0 }, | |
{ "yellow" , 60.0, 5.0 }, |
This file contains 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
(defn expire-cached-results [cached-results time-to-live] | |
"Expire items from the cached function results." | |
(into {} | |
(filter | |
(fn [[k v]] (> time-to-live (- (System/currentTimeMillis) (:time v)))) | |
cached-results))) | |
(defn my-memoize | |
"Returns a memoized version of a referentially transparent function. The | |
memoized version of the function keeps a cache of the mapping from arguments |
This file contains 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
#import <QuartzCore/QuartzCore.h> | |
- (UIImage*) captureView: (UIView*) view | |
{ | |
UIImage* image = nil; | |
UIGraphicsBeginImageContext(view.frame.size); | |
{ | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
if (context != NULL) { |
This file contains 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
#if GAME_USE_UNDOCUMENTED_API | |
id cameraControllerClass = objc_getClass("PLCameraController"); | |
if (cameraControllerClass != nil) { | |
id cameraController = [cameraControllerClass performSelector: @selector(sharedInstance)]; | |
if (cameraController != nil) { | |
UIImage* viewImage = [cameraController performSelector: @selector(_createPreviewImage)]; | |
if (viewImage != nil) { | |
[self processImage: viewImage]; | |
} | |
} |
This file contains 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
#include <iostream> | |
#include <mach/mach_time.h> | |
#include <stdint.h> | |
#include <CommonCrypto/CommonCryptor.h> | |
struct Timer | |
{ | |
public: |
This file contains 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
// CryptoViewController.m | |
#import "CryptoViewController.h" | |
#import <CommonCrypto/CommonCryptor.h> | |
@interface NSData (Crypto) | |
- (NSData *) cipher: (CCOperation) operation withKey: (NSData *) key; | |
- (NSData *) cipherUsingAES128: (NSData *) key; | |
- (NSData *) decipherUsingAES128: (NSData *) key; | |
@end |
This file contains 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
#!/usr/bin/python | |
# We are the Desktop | |
import sys, simplejson, time, urllib2, hmac, base64 | |
from jpake import JPAKE, params_80, params_112, params_128 | |
from M2Crypto.EVP import Cipher | |
def get(url, etag = None): | |
headers = {} |
This file contains 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
int main(int argc, char *argv[]) | |
{ | |
int retVal = 0; | |
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | |
{ | |
#if YOURAPP_DEBUG_LOG | |
// Redirect stdout to a file in ~/Documents | |
NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; |
This file contains 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
#include <avr/io.h> | |
#include <avr/wdt.h> | |
#include <avr/eeprom.h> | |
#include <util/delay.h> | |
uint8_t red = 0; | |
uint8_t green = 0; | |
uint8_t blue = 0; |
This file contains 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
#include <avr/interrupt.h> | |
#include <avr/io.h> | |
#include <avr/wdt.h> | |
#include <avr/eeprom.h> | |
#include <avr/sleep.h> | |
#include <util/delay.h> | |
// The current values of the RGB LED is stored in three separate | |
// variables. These represent the amount of time that the color |
OlderNewer