Materialized View Alternatives

A while back I wrote about materialized views in Postgres. My main motivation was making Postgres’ full-text search faster, and to be able to filter and sort using indexes when searching over data coming from many different tables. Since then, I’ve learned about some alternatives that I want to share. First, a note about why materialized views are not always the right tool for the job: 1. When creating materialized views, you end writing SQL that duplicates logic you’ve already implemented in Ruby, like this: In that example, you have to write two versions of how to find and format…

Slim for static sites

I’m a big fan of preprocessing. I prefer Slim, Sass, and CoffeeScript to plain HTML, CSS, and Javascript. They are cleaner to read and easier to type. They are also very easy to use in Rails. But what about using them for static sites, without Rails? Although Sass and CoffeeScript have command line compilers, I couldn’t find anything as easy to use for Slim. In the end, I realized that the right way to go is using Middleman, a Ruby framework for building static sites and blogs. It uses the same sort of asset pipeline as Rails does, so all of the compiling…

Fixing font-awesome on Heroku

My icons from the font-awesome-rails gem were showing up fine in my development environment. But in production on Heroku, some showed up as empty boxes, and others did not show up at all. In the “Network” tab of Google Chrome, I saw that the http response status for the font assets was: 206 Partial Content. Not very informative. A more useful message came from the “Console” tab: Font from origin http://shielded-falls-2406.herokuapp.com has been blocked from loading by Cross-Origin Resource Sharing policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin http://expensemanager.teddywidom.com is therefore not allowed access. I had recently…

HTML Resume Template

I just posted my resume on my personal site, teddywidom.com.  I used plain HTML for markup, and SASS for styling, with Bourbon and Neat. I decided to open source the HTML and CSS I used, and it is available on GitHub.  Feel free to use it as a template for your own resume!

Travis CI and Hound

Yesterday, I started using two tools that integrate with Github: Travis CI and Hound CI. “CI” stands for continuous integration. Before new code is merged into a project, there are certain standard steps that should be taken every time.  CI is when those tasks are automated, so that they happen every single time before code is merged, without a person having to remember to do them. For instance, every time a pull request is opened, Hound automatically comments on lines that contain stylistic violations. This way, style guidelines get enforced, but the people doing the code review get to spend their time and energy…

Know your industry

I just finished reading Michael Lewis’ new book, Flash Boys. It was a great book (like everything else by Michael Lewis)! Flash Boys is about high frequency trading (HFT) in financial markets. It has fascinating stories of many different involved parties: from people laying down ultra-straight fiber-optic cables in response to demand for the fastest New York/Chicago internet connection, to a gifted programmer who goes to prison for cloning a Goldman Sachs SVN repository, to a Candian banker who starts his own, fairer stock exchange. There are so many themes in this book that are important for programmers to consider….

Making junk into treasure

At the Steel City Ruby 2014 conference, Franklin Weber gave a talk called Utils is a Junk Drawer.  It was great! He pointed out that in despite of trying to adhere to the DRY principle, and liking sharing our code with others, many projects have a “junk drawer” where general utility code that is unrelated to the project’s own business logic goes. Often, this same code gets copy-pasted between many projects, or multiple people spend time developing the same utilities separately. For instance, here is some utility code from a personal project of mine: On his advice, I made this into a…