Skip to main content


Showing posts from November, 2012

How to pass a Rails or Sinatra variable into JQuery.

A few days back I got a code challenge for a cool job position. For whatever reason the test was very light on Rails very heavy on JQuery, which I didn't know much about frankly. So in less than 24 hours I had to not only learn enough of it but also make it work into a modal window widget. I got it done, but it wasn't elegant at all. I clobbered it even if it worked.

The first challenge was to get information into webpage from a Rails application, I chose JSON and thought it'd be easy-peasy, but transferring a JSON object is a cross-domain script violation and most browsers won't let it pass. So I learned about JSONp which wraps the JSON object in a JQuery call-back. Lacking the easy Ruby ways of determining what things are, at first I'd no idea what the JSONP object was and just had my Rails app send JSON. Once I figured what it was, it was trivial to get Rails to do it. All I had to do was add: :callback => params[:callback] to the format property in the contr…

A Clockwork Orange

A milk bar. It left me confused. I imaged a bar, like as a night club, where under-aged kids would do drugs and drink milk. I remember hollering with glee when I saw a milk bar in Australia and suddenly got the book A Clockwork Orange in it's entirety, years after I'd read it, a bored week I spent in Princeton before shipping out to Japan. [A milk bar is what in America is called a convenience store! A place to buy milk, not a crazy night club.]

The whole confusion on the book arose from having watched or partially watched the film of the same name. In the film it's all about the 'horror-show' which is literally a visual tour of violence. Where a pack of young men meet out ultra-violence made cool, made strangely attractive, glorified not for it's meaning like wars, but for it's act, like art. The book is different, thought.

Upon realizing what a milk bar was, I got what the story is about. It's not about violence but about boredom. The kids go to the m…

Solo Travel Pt.1

"And if you can't find a loyal companion,
  travel alone..."

I slept in late. I didn't want to get up. I couldn't stay there any longer and as if to confirm it my aunt started the conversation with "I don't want to kick you out, but when --" But I cut her off. "I'm leaving today." All the stuff was packed in the car. After a year of sleeping on the floor on an air mattress, having my car stolen, recovered and broken into again, learning photography and co-directing a documentary, the time had finally come to leave. The next day, after staying one final night in Florida at my friend's apartment in Tampa, the inherent adventure of solo travel would take me over, I would wake up early the next day, ready to travel across the country, ready for a journey with an uncertain destinations. I was uncertain and ready. I put on my Princeton T-shirt to remind myself of what I had accomplished and gassed up the car and set off.

The drive was ex…

Kindle Paperwhite 3G, a crippled device

In my quest to find a good e-reader that beats my iPhone, I've tried a Nexus 7, a Kindle 3G Keyboard and a now a Kindle Paperwhite 3G. By far the most useless device is the last.

I could write a long review but there is no need. A Kindle Paperwhite 3G is the same machine as the Kindle Paperwhite WiFi, except $60 more expensive. The 3G is limited only to and your own books. It's miniscule 2GB storage means you have to be connected to a network if you have a lot of files.

The Paperwhite also removes features the previous Kindle had, like an MP3 player, a headphone slot or the ability to read text to you (if allowed by the publisher/author). The storage is reduced from a previous 4GB to now 2GB. Though that would be plenty for most people. It also lacks speakers but that's a feature I don't miss, since the speakers weren't great to begin with. The device is much much sharper and brighter than the Kindle 3G Keyboard, but it is comparable to the Nook Glo (tho…

Advantages of Different Ruby Implementations

Some one asked me what where the advantages of JRuby lately. I had to think and that got me to this post.

- Runs on Android
- Can be uses to pre-comple code to Java Byte code for speed and code obscurity. :thumbs up:
- Runs on a Java-Virtual-Machine server.
- Runs on any computer w/ Java (whether it has Xcode or not)

- Scottish.
- GUI apps that use native cocoa frame work.
- iPhone apps through Ruby Motion.

This is 'embedded ruby' and it hasn't been released yet but from what I know:
- Very light, requires little memory and space to install.
- Gives you Ruby expressiveness where a program language like Lua could only go before.

Sadly semi-abandoned. This Ruby's goal was to compile on Microsoft's .Net framework.
- All those poor .Net developers doomed to MS's C++++ (C#) would be able to taste salvation in Ruby.

Ruby that is mostly written in Ruby. Apparently this is good for thread-safe running of multiple rubies in one mach…

Retraction – Installing Ruby 1.9 on a Mac.

Nothing is worse than having to print a retraction, one of my posts is on the lightest way of installing a new Ruby on the Mac.

Turns out the rbenv and ruby-build do indeed require Xcode. Even though the website and even some people believe it's not required, ruby-build needs a compiler. Suddenly the case for rbenv is nil, null and void. I am a bit upset that this requirement is not clear from the documentation, and its harder configuration, coupled with the need to always preface your Rails commands with 'bundle exec' and its lack of advantage of rvm in size, make rbenv a looser and I can't recommend it anymore.

I have just switched to RVM, which while it requires the behemoth of Xcode or possibly just the 'command line tools for Xcode' is a far better choice. RVM or Ruby Version Manager, allows you to create gem sets per project that then can be shared with the project itself. It's command line interface is super polished, and there is way more informatio…