Skip to main content


Showing posts from April, 2014

Steps to follow when the Android Development Tools (ADT) fall out of sync with the Android SDK Tools

In theory the Android Developments Tools (ADT) development environment should auto detect when it needs to install updates, but I've found that in practice there are times when the Android SDK Manager updates the Android SDK Tools to the latest version but the ADT environment doesn't follow suit and this breaks certain parts, for example the launching of apps. In this situation, the first thing to do is:  go to the ADT menu and select 'About...' click on Installation Details check the version number of your Android Development Tools aligns with that of your SDK tools in the SDK manager (Window -> SDK Manager) If the two do not align use the Help menu and select 'Check for Updates', but if this doesn't have anything to offer return to the Help menu and click on 'Install New Software'. Once you've opened the new software dialog box do the following. click on the drop-down menu button for the 'Work with' box and select t

Probably the most useful EPUB export option in the world: Export Tagging in InDesign

If you are utilising paragraph and character styles in InDesign, then you needn't suffer spans and p tags in your exported EPUBs. Instead you can take control using the same paragraph and character style panels as you use for defining the styles themselves. Simply select 'Export Tagging' from the lefthand list and you will see the above dialog box. Here you can select (or type) an HTML tag into the Tag box (to override the automatic assignment by InDesign) and a class into the Class box. (If you omit a class name, your original Style Name will be used.) You'll also notice the Emit CSS box. Unchecking this box will prevent CSS from being created for the style. Limitations Having these options is a great way to reduce span tags, so we have <i> instead of <span class="italics"> and we can also use the correct HTML tags like <blockquote> instead of <p class="blockquote"> but what if we want the HTML to follow the

SHA1 encryption in iOS

The code in this post is adapted from a StackOverflow post. The original returned an MD5 encrypted string. This one returns a SHA1 encryption identical to using sha1(); in PHP. SHA1 Encryption in iOS First you need to import CommonCrypto into your class header file. #import <CommonCrypto/CommonDigest.h> Next within your .m file add the following method: - (NSString *)sha1:(NSString *)str {         const char *cStr = [str UTF8String]; unsigned char result[CC_SHA512_DIGEST_LENGTH];      CC_SHA1(cStr, strlen(cStr), result);     if (result) {     /* SHA-1 hash has been calculated and stored in 'result'. */ NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH];               for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)             [output appendFormat:@"%02x", result[i]];         return output; }     return nil; } see here for an explanation of the %02x. It is also used here  by Apple in the cons

iOS code for saving "Open In" file to Documents directory (and resolving duplicate filenames)

Fully commented code for saving "Open In" file to Documents directory (and resolving duplicate filenames) in iOS. AppDelegate.h - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {     // Copy the file into the documents directory, renaming if there's a duplicate     [self copyItemAtURLtoDocumentsDirectory:url];       return YES; } -(BOOL)copyItemAtURLtoDocumentsDirectory:(NSURL*)url {     NSError *error;     NSURL *copyToURL =  [self applicationDocumentsDirectory];       NSString *fileName = [url lastPathComponent];     // Add requested file name to path     copyToURL = [copyToURL URLByAppendingPathComponent:fileName isDirectory:NO];         if ([[NSFileManager defaultManager] fileExistsAtPath:copyToURL.path]) {               // Duplicate path         NSURL *duplicateURL = copyToURL;         // Remove the filename extension         copyToURL = [cop

MAMP and the iOS Simulator

If you want to test an app that will work with a HTTP server, then one way to do this is with MAMP and the iOS Simulator. Here's a brief and simple example to get you started. There's no special setup, just open MAMP, start the server as usual and run your app in the iOS Simulator. iOS code - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:@""]]; NSError *error = nil; NSURLResponse *response = nil; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString* responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog(@"%@",responseString); } PHP code (hello.php) <?php if(isset($_GET['name'])) echo "Hello &qu

Links for data/file loading, caching and saving with JavaScript

There are some really useful technologies already available to the JavaScript programmer and others on the way that will enable JavaScript to do more useful tasks than have previously been possible. The first task in the implementation of these new methods is to navigate the documentation and to understand which parts are live and ongoing and which parts are deprecated or set to become obsolete. For example, while you can start work with Local Storage, Session Storage, the Offline Application Cache and the File API today, if you are going to be working with a database then you have some more difficult choices, especially if you are looking for cross-browser compatibility. There's also the question of how far into the future you wish to look. If you are specifically working to support the Chrome (or Opera) browser and the associated eco-system then the FileSystem API will be useful to you, but if you're looking to build something that works everywhere then it's too ear