Post

What the 20s are about

I loved this comment on a Hacker News post about burnout and shitty jobs:

Also, what happens to most people as they get older is that they have mostly negative work experiences, because most companies are badly managed, and they learn things to avoid. People learn things with experience like, “Working 70 hours per week for months on end doesn’t actually work out well.” IMO, that’s what the 20s, for the smartest people, are actually about: watching people in power fuck up so you know what not to do when you’re in charge. Eventually, you’ll be in a position to do things properly. It might take a while.

Post

Heroku and Oh-my-zsh

If you’re using the Oh-my-zsh configuration (which I highly suggest if you’re using zsh) you may run into an odd error when trying to create a heroku app.

If you receive the error:
heroku is not part of the bundle. Add it to Gemfile.

Alt error

Its due to oh-my-zsh’s bundler plugin. To fix it, edit the plugin’s bundled_commands or remove the plugin if it’s not in use

rm ~/.oh-my-zsh/plugins/bundler/bundler.plugin.zsh

Post

Solutions for Citier’s many errors

I’ve been working on a rails project that really needed to use multiple table inheritance. I really didn’t want to code up mixins for the parent models and I figured there had to be something to take care of this for me. Enter Citier, a ruby gem that aims to solve many of rails inheritance issues.

Citier works, actually pretty well, but there are a few problems that you may run into when getting your models setup.

Problem 1 - Uninitialized constant

Alt Uninitialized

What to check:

  • Verify you did not add create_citier_view to the parent class’s migration, but that it is added to any child’s migration
  • Verify your child models are inheriting from the parent, and not from ActiveRecord::Base

Problem 2 - undefined method `create_view’ forĀ #<AddCitier:0x007ffd694437e8>

Alt create_view

Solution:

  • Add to your gemfile:
    gem ‘rails_sql_views’, git:’https://github.com/morgz/rails_sql_views.git’
  • Add to your environment.rb: require ‘rails_sql_views’

Problem 3 - SQLException: ambiguous column name: created_at

Alt ambigious

This error is easily avoidable, you have to remove the time stamp columns from your child model migrations. But, if you’re like me and don’t pay attention that the time stamps are added by default, and then run the migrations, you have to get those columns removed.

Initially I just created another migration to remove the columns from the child model. This ended up just creating a different error: Alt cascade

My solution to get both of these errors fixed:

  • Delete the migration for removing the timestamp columns
  • Edit the migration for creating the child model’s table and remove the timestamps
  • Run rake db:drop db:create db:migrate to recreate the database and run all migrations again
Post

Ruby 1.8.7 - Stack level too deep

I was recently working on a project that was using Ruby 1.8.7 and anytime I tried to use bundler or rake I was getting an error message like this:

/Users/blake/Developer/.rvm/rubies/ruby-1.8.7-p299/lib/ruby/site_ruby/1.8/rubygems/version.rb:300:in <=>: stack level too deep (SystemStackError)

I was confused. I tried updating ruby gems, rvm, bundler, and just about everything else. None of that worked.

To fix the problem I actually had to increase the stack size. I doubled the stack size from 8192 to 16384, and the application worked.

To increase the stack size from the command line:

ulimit -s 16384

Post

Pow - Fix the Unknown Process Error

Alt Pow

If you run into the “Unknown Process Error” with Pow, try these steps:

  • Run bundle install.
  • If you’re using RVM, upgrade it with: rvm get stable.
  • Run rails s, webrick gives much better error output than Pow, so if there is a syntax errror you missed, webrick will report it.
  • Check your gems. Were any new gems added to your gemfile? Try removing them and see if that fixes it.
  • Check the logs at ~/Library/Logs/Pow/apps/<App Name>.log.
Post

Sublime Text - Markdown to Tumblr Plugin

In my never ending quest to do just about everything from Sublime Text, I added some functionality to the Markdown Preview Plugin that lets you send a markdown file to Tumblr either published or as a draft.

You can get my forked version of the plugin with the added Tumblr functionality here.

There are two new menu items added to the quick panel:

  • Markdown Preview - publish current file to Tumblr
  • Markdown Preview - send current file to Tumblr as a draft

To use these features you will have to edit the plugin’s settings file, MarkdownPreview.sublime-settings, and add your Tumblr email and password. On OS X, the settings file will be located under: ~/Library/Application Support/Sublime Text 2/Packages/Markdown Preview.

Alt Tumblr Plugin

Post

I am a Python Noob - Using different Python Versions on OS X

I don’t use Python often, but when I want to create Sublime Text plugin, it’s my only choice.

For my most recent Sublime Text plugin, I created a quick way to send a Markdown file to my Tumblr. I needed to use the PyYaml module to parse the front matter of my document. To use the PyYaml module in my plugin, I added the import statement: import yaml at the beginning of the file, but everytime I tried to use the plugin I got the error message:

Traceback (most recent call last): File “./sublime_plugin.py”, line 62, in reload_plugin File “./markdown_test.py”, line 2, in <module> import yaml ImportError: No module named yaml

This seemed odd, I followed the module installation instructions, and there were no errors on installation. When I opened up the Python command line, if I typed import yaml everything was fine, and I could use the module.

I knew OS X came with a version of Python pre-installed, and was used system wide, so I assumed the module got installed to that version. I was wrong.

Somewhere along the line an additional version (2.7) of Python was installed on my machine, I believe something I installed through MacPorts actually installed the new version. The default version of Python my system was using was 2.7, but Sublime Text was using the pre-installed version of Python, 2.6.

The way I figured out the module was installed to the wrong version of Python:

  • which python - This told me python was installed in /Users/blake/Developer/bin/python. That didn’t seem like the right location for the pre-installed version.
  • Check /usr/bin - I went to the bin directory and noticed the executables python2.5 and python2.6. This looked better.
  • python2.6 setup.py install - I then ran the PyYaml setup script on python 2.6, and boom, my Sublime Text plugin now worked.