Skip to main content

Engineering & Code

Engineering & Code explores the full stack of modern tech—from bits and transistors to cloud fleets and formal proofs. Here you’ll find clear, rigorous walk-throughs of software design, embedded hardware, security architecture, and the physics that underpins them, always paired with code, schematics, and reasoning you can put to work.

Render CSV in Rails

First I read the docs at: rubydoc.info to understand how FasterCSV is now in the ruby standard library. Then, I set up the following code: https://gist.github.com/tbbooher/1700200 This gives me a pretty flexible solution to render csv, but I’m really interested to see if this is a good way to go. Your comments are appreciated. read more

Your key with fingerprint … is not authorized to access heroku with Ubuntu

This error was pretty hard to solve. I emailed heroku support and they recommended: “https://github.com/ddollar/heroku-accounts”:https://github.com/ddollar/heroku-accounts bq. For git commands to work git needs to use the ssh key associated with that account. It’s probably choosing a key associated with a different account which is causing these permissions errors. You can use a ~/.ssh/config file to […] read more

Mongoid counter_cache with has_and_belongs_to_many

If I have two Mongoid models joined by a has_and_belongs_to_many relationship, Users and Groups. I need to quickly and efficiently sort by the most popular groups which really should be done with a counter_cache. However, counter_caches are implemented in rails by setting a callback to update the counter cache every time a child model is […] read more

How do you deploy an application.yml based config to heroku

In one of my applications, I have the following config files that are excluded from git: * config/mongoid.yml * config/application.yml * config/mailserver_setting.rb * config/omniauth_settings.rb For deploying to a regular server, I just add tasks to my capistrano deployment file to create sym-links to a shared directory. In this case I have to modify my application […] read more

Hard drive mirroring With Unison and the DNS-323

My requirements: – All files on my laptop will be on my DNS-323 Network attached storage device – Any changes made to the shared drive on the DNS-323 will propagate to my Mac – This happens securely and safely The problem is that there are scant resources online to do this. (Isn’t this done frequently?) […] read more

Convert avi’s, mkv etc to the iphone

Handbrake is amazing with active development and a great community. When I wanted to transfer a bunch of lectures to iphone/ipod touch format, I faced the time-consuming challenge of converting a hundred files using the Handbrake gui and figuring out the complicated set of options for HandbrakeCLI — their nightly build standalone. So, here is […] read more

Recovering Rails Data Using Production.log

So you didn’t set up automatic backups and need to recover your data? Don’t try digging it out of mysql, look no further than your rails production log. OK, try a bit with mysql, because the rails production log is a terrible way to recover your data. Only use as a last resort, but when […] read more