Posts tagged with hack
Generating your holiday photos automatically with the iPhone location database
As you may have read, the iPhone 4 stores a database of your location over time, and it's simple to access this database on your computer. Notwithstanding the privacy implications, it provides an interesting source of data to play with!
I've spent the last few months travelling while working for ReignDesign, and my iPhone has been faithfully recording the trip. I extracted the consolidated.db file which the iPhone stores in its backup, and wrote a small Python script to extract my location history. The script finds the first recorded location for each day, and then:
1. Looks up the city name and country using Google's Geocoding API
2. Searches for photos with the Flickr API taken close to the latitude/longitude I was at, on that day
Note that not every day has a location recorded. When I was in Tonga and Samoa, I didn't have a SIM card. Since the consolidated.db file uses cell towers to calculate location, not GPS, there are gaps. Also, sometimes there are no photos on Flickr for a (location, date) pair.
With those caveats, put it together and you have what I call "the lazy man's holiday photos":
Fixing “Upload Aborted or Timed Out” errors in iTunes Connect
When you're uploading screenshots to iTunes Connect, you may run into the error "Upload Aborted or Timed Out". This can be very frustrating if you're on a slow connection. Sometimes, retrying the upload may succeed, or converting the files to JPGs.
This is not ideal: we'd like to be able to upload nice hi-res iPad screenshots, even on a slow connection. I did some digging in iTunes Connect's Javascript. It turns out it uses a component called LCUploader to handle the uploading. Deep in the bowels of a file called lc_ajaxcomponents.js, we find this code:
self.timerId = setInterval(function() { self.checkUploadHeartbeat(); }, 10000);
...
this.checkUploadHeartbeat = function() {
if (this.lastProgressDate == 0) { return; }
var now = new Date().getTime();
var diff = now - this.lastProgressDate;
if (diff > 10000) {
// We have waited more than 10 seconds without any bytes being pushed
clearInterval(this.timerId);
// Mark the request as being aborted
this.aborted = true;
// And finally abort the XHR
this.xhrRequest.abort();
this.displayErrorMessage("Upload Aborted or Timed Out.");
this.reset();
this.stopSpinner();
Aha! It appears that this check is incorrectly causing the upload to time out after 10 seconds. We can override this function at runtime. Paste the following code into your browser's address bar:
javascript:LCUploader.prototype.checkUploadHeartbeat = function() {};void(0);
This overrides the function with an empty one. Now we're able to upload larger files with no issues, even on a bad wifi connection in Tonga
Weekend hack: Posting to Twitter via SMS in China
Twitter provides phone numbers to allow you to update your status via SMS. Unfortunately, local numbers are only available in a few countries: the US, Canada and India. Elsewhere, you need to text their international number in the UK, which can be quite expensive. ReignDesign is based in Shanghai, China - so how to update Twitter for the price of a local SMS? Via a local Twitter-like service Fanfou.com, and a simple PHP script, it's possible!
Continue reading...