Tag Archives: tech

Swift: println isn’t NSLog

After banging my head against this the last few days, I thought I might share a little insight as I delve deeper into Swift. As tempting as it may sound to believe it, println IS NOT NSLog.

If you’ve looking to use the Devices function in the iOS Simulator to test an application launching via a push notification, or perhaps via a location update, you’re stuck trying to race to connect the debugger or better yet rely on printed statements and watching them.

The magic trick here is to remember that println does not show up in the iOS Simulator Console, but NSLog does. Further NSLog also works on device so can play with app while disconnected from your dev machine, then plug it back in and pull the logs via the Devices tool in Xcode.

Some additional details are here, which I sadly found far after figuring this out myself.

Loading Shapefiles in to MongoDB

I’ve been playing a bit recently with a small geospatial/location based app. After haggling with a bunch of tools and MongoDB a bunch, here are a few tips on importing a set of ESRI Shapefiles in to a MongoDB. I’m looking at SF Street Sweeping data but you can use any Shapefiles you wish.

Get the shapefiles

For example, grab the SF Street Sweeping data, and download and unzip those.

Convert Shapefiles to WGS84 Projection

The SF shapefiles are in Northern California specific projection (2227). Lat/long coordinates are in WGS84 projection (4326). Download the GDAL tools to get access to the ogr2ogr tool to directly convert them. Or use QGIS to load the shapefile as a vector, then export it out using the WGS84 projection.

Convert Shapefile to GeoJSON

ogr2ogr -f geoJSON sweeping.json sfsweeproutes_in_wgs84.shp

Clean up the resulting GeoJSON

MongoImport doesn’t like the ogr2ogr generated GeoJSON. Remove the first two lines:

"type": "FeatureCollection",

and the last line:


and save that to `sweeping_clean.json`

Import the data to Mongo

mongoimport --db sfstreets --collection streets < sweeping_clean.json

Create a 2dsphere spatial index

Mongo needs an index to query on geospatial data. To create it from the mongo command line:


Where streets is your collection name and `geometry` is the object in your document that contains the GeoJSON location data.

That’s it!
You now have in the sfstreets database a streets streets collection. I’ll follow up in the next post on how to query this data.<

Static Site Hosting on Heroku with Node.js

I’ve been moving a lot of my web content off of a personal server which has been kept in to my apartment to various hosting services while on break this year.  Sites like Ask An Asian Person and other small inside jokes I used to host on a Windows 2003 Server with IIS on a Dell machine that ran in my closet. That setup is/was so very, well, 2003. In addition, it’s always a good move to reduce and remove any ingress points to my home network.

So for a bunch of the silly small sites I have, I’ve moved them over to one-dyno free hosting on Heroku. To do that, I made up a little template to use called static-heroku-node. It’s a tiny 10 line Node.js + Express application that deploys applications out of the /public/ folder in the app. Quick and easy to use, I managed to move a few sites over in short order.

As an aside, I moved my blog over to DreamHost. I looked at Heroku for hosting WordPress — there are a bunch of options on how to do it, but any production setup (e.g. > 1 dyno and any of their production level Postgres databases) would cost something like $25-$50 per month which is a bit rich for just a blog. DreamHost’s 1-click WordPress setup is much cheaper and more flexible than trying to scaffold the same thing up on Heroku/Dotcloud/etc.

Getting Maven to Work with Android 17

I just suffered through this for a good part of an afternoon, so figured I’d blog it for anybody else. Apparently a bunch of stuff moved around between some versions of Android, so make soft links to:

./sdk/tools/aapt to ./sdk/build-tools/17.0.0/aapt
./sdk/tools/dx to ./sdk/build-tools/17.0.0/dx
./sdk/tools/lib/dx.jar to ./sdk/build-tools/17.0.0/lib/dx.jar

So, if you’re in your ./sdk/tools directory, you can:

ln -s aapt ../build-tools/17.0.0/aapt
ln -s dx ../sdk/build-tools/17.0.0/dx
ln -s lib/dx.jar ../build-tools/17.0.0/lib/dx.jar

iOS6 Frustrations

I upgraded to iOS 6 yesterday and so far have been far from impressed. Here’s what’s irking me:

  • Passbook is unusable. I installed the iOS 6 compatible version of the United Airlines app, which clearly states Passbook support and yet Passbook only shows me the splash screen. On top of that, the App Store shows the Cannot Connect to iTunes error. Fixes aside, even with the United app I can’t get it to work.
  • Turn by turn navigation in Maps is rubbish. I had to drop off some stuff across the city last night, so I thought from my house to Embarcadero I’d use Maps to get me directions. It took me via the freeway which was odd to start, but as I drove city streets at like 15/20mph, it kept getting my location wrong and subsequently rerouting me to different routes. On top of that, if often jumped the gun and gave me the next turn before I had arrived at the current turn.
  • I’m not a fan of the new multi-colored status bar. It updates with all the apps and the Mail and System app seem jarring with the new colors. This one is just personal preference though, nothing functional.
  • I miss the YouTube app. I downloaded the Google one and it’s just not the same.

Okay, those are only four complaints, but the Maps one is really exceptionally frustrating.

Sencha Architect 2

The very first thing my boss at Sencha asked me to work on when I joined was: “figure out what we’re doing with Designer”. Having known nothing then and only a skeleton team we started to sketch out what would become Sencha Architect 2. That was a year ago, and thankfully we’ve been lucky enough to be joined at Sencha by a great team from engineering, to product management, to UX that made Sencha Architect 2 happen. It’s crazy to look back to see in the last year all the amazing products we’ve released, such as Sencha Touch 2, the preview of Sencha.io, and now Architect 2. It’s such a huge step forward for us and for the web.  I’ve been on the road demoing it at conferences and people go crazy when you see how easy it is to build an HTML5 app, which is a testament the work the team has put in to make the product easy and productive to use.

Thoughts on SenchaCon 2011

I’m back at home after an exciting time at SenchaCon 2011, in Austin, Texas. What an event. A great bonding experience for the company, and an even better opportunity for us to spend time with customers and the community. I don’t blog often enough about Sencha, but this was so much fun and so exciting that I had  to toss out a few things that were my favorite from the show:

  • The Sencha Platform: we articulated our platform for the web using Sencha technologies. Built on tools, frameworks and the cloud the Platform gives developers all they need to get up and running building world class web apps. So stoked about building out the Platform over the next year.
  • Sencha.io, Ext JS 4.1, Sencha Touch 2, and Designer 2. Awesome launches for all of our products. Congrats to the teams for making it happen.
  • Multi-device, Shared, and Enriched: our vision on how the future is going to shape web apps and content in general. Abe did a fantastic job articulating how the web will evolve over the next few years.
  • BBQ at Stubbs! So much fun hanging out and have a drink with folks from the community, and an awesome live performance by Black Joe Lewis and the Honeybears. They’ll be at the Fillmore next month if you want to catch them in San Francisco.
  • Hackaton! I’m always amazed at what people can put together at a hackathon, and I’ll brag just a bit: the teams at our hackaton produced some of the best apps I’ve ever seen at a one-day hackathon. Hats off to the community for kicking ass hacking on our products.
SenchaCon was easily one of the best tech conferences I’ve been to, and I’m proud to have been a part of it. Now, time to sleep for the next few days. Can’t wait for SourceDevCon in London next year — hope to see you there if you didn’t make it to SenchaCon Austin.

Seven Days with Windows Phone 7

Last Friday I decided to put the Blackberry down for a week and use a new phone for seven days. If you know me, you’ll know I’m an avid Blackberry user. I pretty much don’t need a laptop, on my Blackberry I’m nearly as efficient as I am when I’m sitting at my desk at my computer. For this test, I chose a Samsung Focus, a Windows Phone 7 device with the stock operating system (no Mango) and used it for a week. Here are some of my observations:


  • The screen is beautiful. Inky blacks, vibrant colors, everything looks beautiful on the device.
  • The UI. For the iOS diehards out there, you might find Windows Phone’s animations a bit over the top but I’m absolutely in love with them. I found myself often swiping the UIs to just play with the animations.
  • The phone feels alive with data. It does a fantastic job integrating my Facebook, Google and Windows Live accounts and giving me a holistic view of my friends and contacts.
  • Live tiles. I wish there was more of this, but the live tiles as the app icons is sexy. They pulse with information that’s hiding under them. Some of them aren’t really that useful or interesting like the Zune app or the Photos app (I don’t need to see Lady Gaga’s for two straight days — show me my album art).
  • The browser. Before you jump down my throat, remember I’m coming from a Blackberry. Even though it’s IE7, the browser to me is a huge step forward from what I’m used to.
  • The camera. Beautiful photos and great videos. Love taking photos with this phone.
  • Windows 7 Phone Connector for Mac. I was surprised to see how much care and attention went in to making the phone work on the Mac. Music syncs seamlessly over from iTunes (altho there’s no audiobook suport and the Zune app keeps forgetting my location within a podcast).


  • The keyboard. Oy, I miss a real keyboard. Of course compared to a Blackberry keyboard, the on-screen keyboard holds no salt. On the other hand, I also own an iPad and I have an iPhone, and I feel that I’m 10x more accurate typing on iOS devices and it’s 100x better at making suggestions than Windows Phone. This, more than anything, holds me back from making it a full time phone. I constantly found myself having to backspace because I accidentally started a new line, pushed space by accident, or something else equally obnoxious. I never had these issues typing on an iOS device.
  • Windows Live, Twitter, Linkedin. You can’t turn off the Windows Live contacts. Once you hook your device up to your Windows Live account, you can only turn off email sync from Hotmail but you can’t disable Contacts sync. Come on guys. My Hotmail address book is so dated and unused so showing me all those contacts is silly. Let me turn it off. No Linkedin app, which is a minor annoyance, but the Twitter app is a trainwreck. It’s slow, buggy and doesn’t integrate at all with the phone well.
  • Apps. The Marketplace has a dearth of content, and half of it seems like it’s made by Microsoft. In addition, navigating the Marketplace is impossible and it seems totally chaotic and disorganized.

There were other minor annoyances, such as there being no unified Inbox (e.g. my Sencha email and my personal Gmail have their own icons), but that’s more on the minor side. My understanding is a lot of this is fixed up and better in Mango, so I’m looking forward to that.

Overall, I think if I were to buy a phone, it’d be a two horse game between Windows Phone (assuming Mango is all that) and iOS. I haven’t spent a ton of time with Android, but based on what I’ve seen and having now used Windows Phone, I think the experience of Windows Phone is far better than Android’s.

Introducing Quick Group Chat

I’ve been working on a litte side project the last few weeks called Quick Group Chat. The site/service came from some IM conversations I was having with friends. I was talking to one friend on Gtalk and the other was on AIM and we were trying to plan a trip. There was no way for us to get in to a ‘quick group chat’ that let us ad hoc talk with each other.

I’d been looking for an excuse to play with nodejs and jquery, so I forked the node_chat example app. Since I started with the node_chat demo, I had a good structure to get started with. The app is basically built out of four files: server.js, client.js, style.css and index.html. To start off I added in a layer called ‘rooms’ in to the server that encapsulated a session, which represents a user. When a user joins, if they aren’t trying to join a room or if the server can’t find a room they were trying to join, a new room is created and an ID is given to it. The user’s session is assigned to that room and the chat buffer is kept for that room. The ID is passed back to the client, and the client updates the location.hash with the room’s ID.

From then anybody who has the URL with the location.hash can join the room. When the user navigates to that URL, the client passes the room ID to the server, and the server joins the user to the room. Since the chat buffer is kept for the room, every time a user joins the room they get to see the prior chat log. When the last user leaves a room, the room is destroyed along with all the data. Hence, quick group chat. Once you’re in the room, the URL is they to invite other people in.  It’s all pretty simple.

I also added in some styling to make it little more fun and easier to read. Each user is assigned their own color based on a color wheel. The formula is kind of fun and easy. For each user’s nickname the code goes over the nick and sums up the ASCII code for each letter in the name, then mod’s it against the total number of colors in the color wheel then assigns a CSS class for that color to the message. That way every time “Aditya” logs in, the user’s color is the same. There’s one exception, and that’s the “me” user. Your typing always looks the same always; thus, the way other people see “Aditya” is always consistent and they see a consistent color for you. I may change that later but it makes other people’s chat pop and your own words a bit more subdued.

Lastly, I hosted it on duostack. This was one of the coolest parts. Once I set up some SSH keys, I added duostack as a remote to my git. Every time I do a “git push duostack”, their remote repository is updated and the app recycles. It’s crazy easy to deploy to their service and it runs really well there. I’ve been amazed at how easy it is and really happy with the service.

Check it out, use it yourself, or fork it and let me know how it goes!