HTML to PDF With PhantomJS

PhantomJS Tricks: HTML to PDF Conversion

PhantomJS is widely known as the brains powering headless javascript testing. But as a standalone WebKit executable, it also has a screen capture functionality that can render web pages to PNG or PDF. For very simple document conversions, PhantomJS is a fairly straightforward tool. But I warn you, severe headaches will occur with any conversion of substance: repeating header/footers, images, SVG, fonts, etc – issues aren’t mentioned in the sparse documentation or example snippets, and can lead to some serious frustration. Hopefully I can help save you a few days with these tricks.

  • Document Structure
  • Page Frame Border
  • Images (Header/Footer)
  • SVG

Ruby on Rails - Gotchas

How to Gain a Few More Hours of Sleep

Ruby on Rails has become my goto web framework. I’m a big fan of the conventions, the gems, and the plethora of tutorials and resources. But like anyone, I’ve had my fair share of scrambling through stack overflow and scratching my head at curious behavior. Here are a handful of simple gotchas that will hopefully save you several hours of frustration.

  • Callback return values
  • Manipulating Strong Parameters
  • API usage: as_json, to_json
  • Postgres and the Array type

Chrome Extension Message Passing With Injected Code

Chrome Extensions: Javascript Injection, Message Passing, and Shutdown.

My latest side-project is stereopaw, a bookmarking service that timestamps streaming music. Imagine a del.icio.us meets Pinterest for music: a user clicks on the browser extension, and the current track’s metadata is available to save in real-time. In building the extension, I wrestled with how to handle cross-communication within the chrome browser ecosystem; namely, how to control injected javascript code on a page, from an extension’s background or content script.

I’ll show an example of javascript injection, and through basic message passing, prevent runaway code when the extension closes by listening for a “shutdown” event.

Startup Weekend Zagreb [Summer 2013]

My First Startup Weekend: Zagreb, Croatia – Summer 2013

About a year ago during a backpacking trip I found myself reading Hacker News, stumbling over to a blog, and somehow ending up on the Startup Weekend page. Out of curiosity, I searched for a nearby event. Lo’ and behold: Zagreb, Croatia.

I had always wanted to try one of these Startup Weekends, foreign country or not, and figured I’d give it a go. I was in the neighborhood, the timing was right – time for some “Geek Tourism.”

Custom Rails Mailer and Mandrill

Using the Mandrill API with Action Mailer in Rails

Mandrill is a popular transactional email service created by the folks over at Mailchimp. There are a number of Mandrill community gems for Rails, but several motivations exist for wrapping the Mandrill API with Action Mailer, primarily if you envision possibly swapping out email providers in the future (i.e. quota limits and costs, different template preferences, etc.), or you want more control customizing the actual content and design of your emails beyond the Mandrill templates and templating language.

We’ll walkthrough how to customize Action Mailer to use Mandrill, while attempting to keep our code modular and straightforward:

  • Set up the Mandrill API and credentials
  • Create our Mailer and actions to populate the Mail object and render our message views
  • Create our Mandrill delivery model to send our object via the mandrill-api gem
  • Configure Action Mailer to use our custom Mailer

Hacking Collision Detection With Slick2D

A Brief, Java-based Primer On Collision Detection

Collision detection is a game programming fundamental. If your spaceship fires a ray gun or evades enemies, you’ve likely implemented some form of detection. If you’re using Slick2D or a similar game engine, things might not be working exactly as expected. Below is a quick primer covering:

  • Basic collision detection in Slick2D (or similar game engine)
  • A collision detection dirty hack when you entities are stuck post-collision.

Slick2D: Deploying a LWJGL Applet

Java Applet Pains

I recently had the pleasure of building a low-fi promotional video game. One of the requirements? The game needs to deploy as an in-browser Java Applet. When was the last time you created one of those?

Blog 2.0: Reboot

Hello World

Today roughly marks a year and two months on the road. Travel is wonderful, and I ony wish I had started earlier. But I can’t get over the nagging need for productivity. It’s too easy to play tourist; to explore, exchange, consume – I need to produce.