Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / Trie.swift
Created June 9, 2014 21:17
//
// Trie.swift
// SceneTest
//
// Created by Greg Titus on 6/7/14.
// Copyright (c) 2014 The Omni Group. All rights reserved.
//
// This is essentially the same data structure as OFTrie in OmniFoundation, except that the OmniFoundation version is mutable and ephemeral,
// and this version is immutable and persistent. Every time you add a string to the trie, it replaces all the nodes along the string's path
@kgn
kgn / gist:3012995
Created June 28, 2012 18:11
Noise in Cocoa
+ (void)drawNoiseWithOpacity:(CGFloat)opacity inRect:(CGRect)rect{
static UIImage *noiseImage = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
NSUInteger width = 64, height = 64;
NSUInteger size = width*height;
char *rgba = (char *)malloc(size); srand(124);
for(NSUInteger i=0; i < size; ++i){rgba[i] = rand()%256;}
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef bitmapContext =
@shayne
shayne / gist:885579
Created March 24, 2011 18:30
[iOS] Simulate memory warning on device
[[UIApplication sharedApplication] _performMemoryWarning];