Skip to content

Instantly share code, notes, and snippets.

@ttscoff
ttscoff / searchlink.rb
Last active Jul 30, 2020
SearchLink creates Markdown links from automatic searches based on special syntax.
View searchlink.rb
@Shchvova
Shchvova / Match.py
Created Aug 27, 2012
Match 3 game for Pythonista app. Yes, typed all on iPad. Copy/Paste it to app
View Match.py
from scene import *
from random import choice, randrange
import sound
TILE_SIZE=64 #size of tile
SDX=4 #selection frame size
M=3 #match 3(?) game
NOS = (-1, -1) #constant to indicate clear selection
FALL_S=0.2 #speed of fall per each tile
FALL_T=0 #constant fall tile
@gillibrand
gillibrand / air_hockey.py
Created Aug 6, 2012
An Air Hockey game for Pythonista on iPad and iPhone. Yes, I typed this all on my iPad. A little painful.
View air_hockey.py
# Hockey
#
# A air hockey game for two players. First to
# seven wins.
# Most of the game is drawn with the scene
# module. Goal and winner messages are animated
# with layers.
from scene import *
from sound import *
@brentsimmons
brentsimmons / EmptyChecks.m
Created Jul 28, 2012
Checking if an object is empty
View EmptyChecks.m
BOOL RSIsEmpty(id obj) {
return obj == nil || obj == [NSNull null] || ([obj respondsToSelector:@selector(length)] && [(NSData *)obj length] == 0) || ([obj respondsToSelector:@selector(count)] && [obj count] == 0);
}
BOOL RSStringIsEmpty(NSString *s) {
/*22 Feb. 2011: added NSNull check. JSON parser can put a null where we expect a string, and NSNull throws an exception when checking length. Since [NSNull null] is, arguably, emptiness, it makes sense to include it.*/
return s == nil || (id)s == (id)[NSNull null] || [s length] == 0;
}
@tibr
tibr / NSFileManager+DoNotBackup.h
Created Mar 8, 2012
Setting the do not backup attribute in different iOS versions
View NSFileManager+DoNotBackup.h
@interface NSFileManager (DoNotBackup)
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL;
@end
@Jyczeal
Jyczeal / CGFontToFontData.m
Created Feb 23, 2012
Read Table Data from a CGFont, then wrap them into a OTF/TTF font.
View CGFontToFontData.m
typedef struct FontHeader {
int32_t fVersion;
uint16_t fNumTables;
uint16_t fSearchRange;
uint16_t fEntrySelector;
uint16_t fRangeShift;
}FontHeader;
typedef struct TableEntry {
uint32_t fTag;