Fixing Ning’s Malformed JSON Archives

Ning provides a tool for downloading much of the content from your Ning network. The catch is that the JSON it gives you is malformed. Add to that that the files are quite large (~70MB for the discussions from a 3-year-old community of about 1000 people), and it’s even more unwieldy. Here’s a quick way to fix it without crashing your text editor.

First thing is to remove the opening and closing parentheses at the beginning and end of the file.

sed -e '1s/^.//' ning.json > ning.json.tmp && mv ning.json.tmp ning.json
sed -e '$s/.$//' ning.json > ning.json.tmp && mv ning.json.tmp ning.json

Next, ensure there are always commas between hashes.

sed -e 's/}{/},{/g' ning.json > ning.json.tmp && mv ning.json.tmp ning.json

Finally, validate the JSON to ensure there aren’t any other bugs.

npm install jsonlint -g
jsonlint ning.json

If that checks out, you should be good to go!

48 Hours to MVP Using Twilio SMS Platform, Rails, And Twitter Bootstrap

I help entrepreneurs make minimum viable products fast. If you have questions email me at joshweinstein.me at gmail.

I’d only been in Saigon for a few days but my friend encouraged me to meet up with Mona Nikhanj. Mona had the wireframes for her idea, but no software.

The idea: ItsReadyText.com lets businesses send text messages to their customers when their orders are ready to be picked up. (Think businesses like optometrists, repair shops, and restaurants.) Mona had a good idea and a meeting with a potential customer in just a few days. She needed an MVP asap.

DAY1 : Choosing the relevant APIs.

I grabbed the excellent Twilio gem and started banging away at it in the console. A few minutes later I’m sending text messages. I love this API!

The Twilio gem is great. For the MVP I made a tiny service class to wrap the Twilio interface. Mr. Demeter might cry, but this is basically the entirety of our Twilio code:

client.account.sms.messages.create(params)

sms

DAY2 : Choosing and deploying the platform.

Next we just needed a web app to save phone numbers and let our customers text them. That should do for the demo.

comp-coffee

Lately I’ve been writing a ton of JavaScript and Backbone.js code, making modern, thick-client apps, but for this project all that felt like overkill.  Your standard Rails app and ActionView form helpers should do the trick.  I knew I’d need some JS eventually, as making the thing dead simple to use was a high priority, but I figured I’d see how far I could go with vanilla Rails.

So I fired up a new Rails 4 stack with Turbolinks in tow. Yes, Turbolinks.

I’d never used it before, so I wanted to see it first hand. Initially it made things impressively speedy for free, but in short order I ran smack into its DOM-ready squandering ways. So enter the band-aid gem that proxies turbo-ready to dom-ready. That seemed to take care of the issues I was seeing, but I’m pretty sure there’s a little caching glitch lurking there somewhere. So, it’s been fun Turbolinks, but I don’t think you’re going to make it through the next rev.

one-does-not-simply-turbolinks

So, all that said, how far did I get things with vanilla Rails? Pretty far. I ended up having to code up some JS to do a smart autocompleting find-or-create style dropdown for creating notifications and possibly creating new customers, all in the same go. Select2, I think you’re a keeper.

This project also gave me the opportunity to stretch my localization chops in a telephonic way, as It’s Ready is being marketed in multiple countries. So I leveraged the countries gem for telephone country codes and paired it with the venerable country_select gem.

Finally, I wrapped the thing in Twitter Bootstrap with a flat UI theme, worked out a few bugs, and pushed to Heroku.

So, a little consoling, a nice-lookin but hastily written Twitter Bootstrap “theme”, a handful of resources and views, some JavaScript icing, a little Heroku, and a couple days’ work, and the thing was online.