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 "Config.h" | |
const Config& Config::get() { | |
return getWriteable(); | |
} | |
Config& Config::getWriteable() { | |
static Config inst; | |
return inst; | |
} |
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
class DirtyFlag | |
{ | |
public: | |
DirtyFlag() : _dirty(true) {} | |
void setDirty(bool dirty=true) { _dirty = dirty; } | |
bool dirty() const { return _dirty; } | |
private: | |
bool _dirty; | |
}; |
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/env python | |
from random import choice | |
def main(): | |
verbs = open('verbs.txt').read().split() | |
nouns = open('nouns.txt').read().split() | |
for i in xrange(100): | |
print '{0} the {1}'.format(choice(verbs).title(), choice(nouns).title()) | |
if __name__ == "__main__": |
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/env python | |
from random import choice | |
def main(): | |
verbs = open('verbs.txt').read().split() | |
nouns = open('nouns.txt').read().split() | |
for i in xrange(100): | |
print '{0} the {1}'.format(choice(verbs).title(), choice(nouns).title()) | |
if __name__ == "__main__": |
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
#ifdef DEBUG | |
[[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidStartNotification | |
object:nil | |
queue:nil | |
usingBlock:^(NSNotification *note) { | |
NSURLRequest* req = [[note object] request]; | |
dbgLog(@"REQUEST: %@ %@", [req HTTPMethod], [req URL]); | |
}]; | |
[[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification |
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
- (NSString*)getTestString { | |
NSArray* superlatives = @[@"fabulous", @"excellent", @"cute", @"energetic", @"furry", @"beautiful", @"lovely", @"amazing"]; | |
NSArray* animals = @[@"cats", @"lemurs", @"bears", @"fish", @"sheep", @"sloth",@"aye-ayes", @"platypuses", @"zebras", @"pandas", @"albatross"]; | |
NSUInteger r1 = arc4random()/(float)0x100000000 * [superlatives count]; | |
NSUInteger r2 = arc4random()/(float)0x100000000 * [animals count]; | |
return [NSString stringWithFormat:@"%@ %@", superlatives[r1], animals[r2]]; | |
} |
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
// somewhere | |
const Color4b Color4b::White = Color4b(0xFF,0xFF,0xFF,0xFF); | |
const Color4b Color4b::Black = Color4b(0x00,0x00,0x00,0xFF); |
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
- (void)notImplemented | |
{ | |
[self performBlockOnUI:^{ | |
MBProgressHUD* hud = [MBProgressHUD showHUDAddedTo:[self viewForProgressHUD] animated:YES]; | |
hud.labelText = tr(@"Not implemented"); | |
[self performBlockOnUI:^{ | |
[MBProgressHUD hideHUDForView:[self viewForProgressHUD] animated:YES]; | |
} afterDelay:1.5f]; | |
}]; |
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 "IsControlCharacterFSM.h" | |
// This is a state machine to determine whether or not the passed character is part of a | |
// TELNET control sequence. | |
// It must be called for every character read in order to manage state appropriately. | |
// Credit where credit is due: | |
// Ryan Rawson ([email protected]) wrote this for FreeTrade. some time around 2000. | |
bool IsControlCharacterFSM(char ch) | |
{ | |
static enum {norm,riac,rddww,rsb,rsiac} state = norm; |
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
UIImage* aspectFitImage(UIImage* source, CGSize size) | |
{ | |
const float wr = source.size.width/size.width; | |
const float hr = source.size.height/size.height; | |
const float scale = 1.0f/MIN(wr, hr); | |
const float width = ceilf(source.size.width*scale); | |
const float height = ceilf(source.size.height*scale); | |
CGRect rect = {(size.width-width)*0.5f, (size.height-height)*0.5f, width, height}; | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f); |
OlderNewer