rubycoloredglasses


I'm Jason, a web applications developer in the Denver, Colorado area.


  1. InstructureCon Hack Day

    Disclaimer: The opinions or statements expressed herein should not be taken as a position of or endorsement by the University of California, Berkeley.

    I’m currently at InstructureCon attending the “Hack Day” event, which is simply an event where any developers wishing to integrate their systems with Canvas can ask questions, talk to Canvas developers, etc.

    Here are some things I’ve clarified with their developers thus far, thanks to Eric Berry and Brian Palmer (codekitchen.


  2. Strong Parameters with Spree Extensions

    I’m currently working on an extension for Spree, an e-commerce solution for Ruby on Rails applications. The developer documentation for Spree is very helpful, letting developers know that they should use certain Ruby meta-programming methods to extend the functionality of the Spree system. The extension I’m working on was setup under a version of Spree that used Rails 3.

    Now that Spree v2.2.1 uses Rails 4.0.4, I’m having to refactor some parts of this extension to adapt to new practices.


  3. Ruby Class Name

    I noticed that in a module used on the CalCentral project that logger expressions used in a module referenced ‘self.name’ many times. I checked ApiDock.com for a reference to this class in the Ruby or Rails documentation, but I couldn’t find one. The module itself didn’t define a #name method, so I was perplexed.

    The module I was inspecting is meant to be used to extend other classes, meaning that it establishes the methods as class methods. It turns out that the ‘Class’ class is officially documented as having a #name method that returns a string version of the class name. This is a valid way of logging which class the log message originates from.


  4. Using 'for in' in Javascript

    Today our lead front-end developer pointed out to me that when using a ‘for in’ loop in Javascript that you want to make sure to use hasOwnProperty() on the element to make sure it belongs to the object, and not properties that were inherited through the prototype chain.

    More information is available on this page describing common Javascript code mistakes caught by JSLint.


  5. How to 'head' a text file in Ruby

    I wanted to just view the first 20 lines of a 10,000 line CSV file returned by an API in a Ruby on Rails project I’m working on. Here is the chain of Ruby commands I came up with to effectively ‘head’ the CSV document returned.

    >> csv = "first line\nsecond line\nthird line\nfourth line\nfifth line\nsixth line\n"
    >> csv.split("\n")[0..3].join("\n")
    => "first line\nsecond line\nthird line\nfourth line"
    

  6. Objective C Notes

    I’m exploring Objective C right now. There are some things that I notice and am curious about, so I’m going to note what I find here.


  7. Recommended Sublime 3 Packages

    If you haven’t already switched to Vim, and you’re hacking everything out from the command line, you might want to check out Sublime Text 3. Sublime Text is supported for Mac, Ubuntu, and Windows.

    Once you’ve obtained a copy of Sublime Text 3, make sure you install Package Control by wbond. Using the SHIFT + COMMAND + P keystroke provides you with a whole menu of options to choose from. Here are packages that are highly recommended for use with Sublime Text 3.


  8. Setting up PostgreSQL for Rails

    I’ve always used either SQLite (the default) with new Rails projects, or I’ve used MySQL because I’ve been using it ever since 2002 when I started doing web development with PHP. Recently however I was challenged with deploying an application to Heroku as part of a code challenge I’m taking part in. Unfortunately, Heroku doesn’t support SQLite, and recommends PostgreSQL. Rather than waste time trying to create a MySQL app and running into problems, I’m going to go the easy route and use PostgreSQL.


  9. ComputerName: not set

    I recently installed Oh-my-Zsh on a new Macbook Pro running Mountain Lion. When I opened up my terminal, I received the message “ComputerName: not set”.

    I tried to use the ‘sudo hostname’ command, but this didn’t seem to work. I ended up opening System Preferences -> Sharing, and then set my Computer Name.


  10. Bundler Definitions

    I’m currently starting work on a Ruby gem, Github profile for Annotate Gemfile, that will grab the title, description, homepage URL, or source URL for every defined gem, and then add them as an annotation / commented for each gem definition in the Gemfile.

    As part of this exploration, I’m digging into the source for Bundler to try an understand how it imports details on the gems from the Gemfile, how it queries for details on each from RubyGems. Here are some discoveries I’m making.