Part 1 | Part 2
Let’s say you’re writing an app, either on iOS or the desktop, and you want to download some JSON data from a web service.
Sigh, if only.
Well, technically you could do this in one line:
But if you do that, you’ll block the main thread until it completes, after which I will come over to your house and stab you in the face.
To perform asynchronous, cancellable HTTP requests in Cocoa, we have
NSURLConnection. Now, this is a pretty nice class. It gives you a great degree of control over the lifetime of the request and for managing the incoming response data. It also handles caching and system proxy settings and global request pooling and other useful things. So we want to use it.
Things you may need to look for when encountering unknown bugs
- Package manager version (npm version in package.json file, Heroku Node.js app)
- File generator version (e.g. texture packer .pvr.ccz)
- Data synchronization (calling [NSUserDefaults synchronize];)
For anyone that don’t know what Dropbox is, it’s a free and awesome cloud file sync/backup service. You’ll get an initial 2GB of space and more 250MB if you completed the get started quest, or invite your friends to use Dropbox. It is great for storing files across computers. You and your friends will be able to see the files just like it is in a local folder.
The good news is, according to this forum post, Dropbox is recently launching a beta test version which will test the camera upload feature, which anyone can join and upload their photos,videos. For every 500MB you uploaded, you get 500MB of bonus space! - up to 5GB.
I think the forum doesn’t have a good example of how this whole process works, so I want to create this post to explain it.
Alright, here are the steps:
- Download and install Dropbox 1.3.15 here…
Mac OS X: http://dl-web.dropbox.com/u/17/Dropbox%201.3.15.dmg
Linux x86_64: http://dl-web.dropbox.com/u/17/dropbox-lnx.x86_64-1.3.15.tar.gz
Linux x86: http://dl-web.dropbox.com/u/17/dropbox-lnx.x86-1.3.15.tar.gz
After install and launch, a popup will ask you if Dropbox should automatically start importing files when a device is connected. Choose “Start Import”. Don’t worry if you miss this step, just go to Dropbox Preference and enable it.
- Connect your device (camera, iPhone, or SD card). If they have photo or video contents, Dropbox will import them automatically.
- After import, you can unplug your device and wait for sync to finish. (UPDATE: or you can delete the files right away. You will still get the bonus space.)
In this case, “Import” means Dropbox will create a folder named “Camera Uploads” and it will copy all photos and videos into this folder. Syncing will start afterwards. Only files auto-imported from device to ”Camera Uploads” folder and uploaded successfully will count for bonus.
After files are imported (copied) to your computer. You can unplug your device and pause the sync. Then, you can later do it whenever you want, like during bed time or after work if you use your office’s internet.
Here are some snapshots of my increased bonus, I first have 2.2GB…
Then after uploading about 1.5GB, now I have 3.8GB!!! Pretty sweet eh? :D (The usage % is lower because I deleted some synced files.)
UPDATE! This is kind of awkward after I have taken time explain all these steps. But it turns out you don’t really need to upload all the files. Just import 5GB worth of files and then delete them right away during sync will to do the trick, even though they haven’t finished uploading yet. I thought Dropbox has already fix this hole but it appears that it still works. I realize this while uploading a 2GB file, I thought the file was too big and deleted it to stop its sync in order to start syncing new smaller files. That’s when a popup comes up and tells me I got the 2GB extra space O_o!!!
Now someone might have a nifty idea of throwing a DVD iso into Dropbox. But sorry, I tried and it didn’t work :P. Duplicating existing files won’t work either because Dropbox is smart enough to check that.
So, if you regularly take pictures/shoot videos with your phone of have a SD card full of vacation images, you should have no trouble finding files to upload. I am bit short of 5GB so I shoot some blank videos and upload those (lol). You can safely delete files that are already synced (files with green tick). It will not affect the bonus.
Lastly, try to not make the file too large as you get bonus after a file has finished uploading. If you upload 2GB files, you can end up waiting forever or even run out of space before getting bonus space! Anyway, this should be totally legit since the whole point of Dropbox for this beta is to test the auto-import-and-sync feature.
Have fun with your 7.25GB+ Dropbox space!
=== Reference ===
Why didn’t I get my free space for beta testing the latest forum build?
Can I manage files after they have been uploaded into my Camera Uploads folder?
Finally found a workaround to fill color between two lines of graph in Coreplot. Just extend the line back under it. There’s a problem when I experiment to draw one point of the line below to peak up above. The result? - the fill in gone, and when I ⌘+z back to the way it was and pun it again, the fill just doesn’t come back! I had to ⌘+z back more until it works and paste the code back. May be the Coreplot project doesn’t get compiled?
So, beware of this when you try something unusual with coreplot :))
LOCATION: Parc Des Exposition, France
CAMERA: Canon IXUS 95IS (Orange :)
DATE: 3 July 2010
A picture album of me visiting Japan Expo. There were so many cosplayers! เสียดายมัวแต่เดินดูร้านขายของด้านนอก ไม่ได้เข้าไปดูโชว์ในฮอล T T คนเยอะมากก ตอนกลับนี่แทบจะเหยียบกันขึ้นรถไฟกลับเลย =*= แต่ก็แซงคิวไปมิใช่น้อย ฮาๆ
1. Sorry many pictures are blur. Blame my compact camera XD
2. Sorry for late post :)
- Python 2.6
- (Optional) OpenCV - used in example for cv.WaitKey() It has nothing to do with the program but it is for making quiting application easier.
Platform: Windows 7
Description: This uses SWMixer to get microphone input and measure its max data, or the volume of the sound at real-time. It detects sharp increase of volume and trigger the sound as a tap on the table or a snap of fingers.
micsnd = None
vol = 0
prev_vol = 0
frame = 0
print 'Tap the table or snap finger near the microphone'
print 'Press ESC or Ctrl-C to stop'
vol = #max 32767
if vol > 12000 and prev_vol < 4000 and prev_vol != 0:
print vol, prev_vol
vol = 0
prev_vol = vol
if == 0x1b: