Skip to content

Instantly share code, notes, and snippets.

View st3fan's full-sized avatar

Stefan Arentz st3fan

View GitHub Profile
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 },
(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
#import <QuartzCore/QuartzCore.h>
- (UIImage*) captureView: (UIView*) view
{
UIImage* image = nil;
UIGraphicsBeginImageContext(view.frame.size);
{
CGContextRef context = UIGraphicsGetCurrentContext();
if (context != NULL) {
#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];
}
}
#include <iostream>
#include <mach/mach_time.h>
#include <stdint.h>
#include <CommonCrypto/CommonCryptor.h>
struct Timer
{
public:
// 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
#!/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 = {}
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];
#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;
#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