This file contains hidden or 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
| #!/bin/bash -e | |
| # Ensure we're running in location of script. | |
| cd "`dirname $0`" | |
| for f in *; do | |
| if [[ $f == *@3x* ]]; | |
| then | |
| echo "$f -> ${f//@3x/@2x}, ${f//@3x/}" | |
| convert "$f" -resize 66.66666% "${f//@3x/@2x}" |
This file contains hidden or 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
| // Warn if this is the first run of this new version | |
| NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary]; | |
| NSString* version = [infoDict objectForKey:@"CFBundleVersion"]; | |
| NSString* defaultsKey = [NSString stringWithFormat:@"hasRunVersion%@", version]; | |
| BOOL hasRunThisVersion = [[NSUserDefaults standardUserDefaults] boolForKey:defaultsKey]; | |
| Log(@"hasRunThisVersion is %d", hasRunThisVersion); | |
| if (!hasRunThisVersion) { | |
| // Do things you want to happen only once |
This file contains hidden or 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
| //======================================================================== | |
| // Add this bit in, one line for each audio file | |
| //======================================================================== | |
| var nameToAudio = { | |
| "audio/story1.mp3":"What I had for breakfast", | |
| "audio/story2.mp3":"What'll have for dinner" | |
| }; | |
| // This function returns the track description if there is one, otherwise returns the name of the audio file. | |
| function nameFromAudio(audio) { |
This file contains hidden or 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
| /** | |
| * Utility function to load JSON file a .json file in the Files tab. | |
| * | |
| * Params: | |
| * @filename - the filename to use. Use the path to the file, e.g. "data.json" for a file in the root, or "data/content.json" for a file in a folder called content. | |
| * @callback - a function to call with the data when it's loaded. You'll need to provide a function with a parameter called 'data'/. e.g. function (data) { popup("I've got data!"); } | |
| * | |
| * Example: | |
| * | |
| * // Load a file called data.json.... |
This file contains hidden or 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
| // GPS Audio Player Example v1 | |
| init(); | |
| ///////////////////////////////////////////////////////////////////////////////////// | |
| // Audio Channel Setup | |
| ///////////////////////////////////////////////////////////////////////////////////// | |
| // When app starts, create two channels and setup 'watches' (so we know what the channels are doing) | |
| function init() { | |
| af.audioChannel.init(2); |
This file contains hidden or 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
| var ua = navigator.userAgent; | |
| if( ua.indexOf("Android") >= 0 ) | |
| { | |
| var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8)); | |
| if (androidversion < 2.3) | |
| { | |
| ... | |
| } | |
| } |
This file contains hidden or 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
| #!/bin/sh | |
| a=1 | |
| for i in *.png; do | |
| new=$(printf "%04d.png" "${a}") #04 pad to length of 4 | |
| mv "${i}" "${new}" | |
| let a=a+1 | |
| done | |
This file contains hidden or 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
| UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; | |
| spinner.hidesWhenStopped = YES; | |
| [spinner startAnimating]; | |
| UIView* view = [[UIView alloc] initWithFrame:CGRectZero]; | |
| view.frame = CGRectMake(0, 0, 20, 30); | |
| [view addSubview:spinner]; | |
| spinner.center = CGPointMake(width/2, 15); |
This file contains hidden or 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 called 'image' | |
| NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
| NSString *documentsDirectory = [paths objectAtIndex:0]; | |
| NSString *filePath = [documentsDirectory stringByAppendingPathComponent:@"foo.png"]; | |
| NSData *imageData = UIImagePNGRepresentation(image); | |
| [ imageData writeToURL:[NSURL fileURLWithPath:filePath] atomically:YES]; | |
| NSLog(@"written to %@", filePath); |