Ruby devs are probably all too familiar with seeing this error:
NoMethodError (undefined method `foo' for nil:NilClass)
Most of the time, it’s probably due to a typo, but every now and then we end up having to do something like:
defined?(bar) && bar.foo
# returns nil if bar is nil
If you’re on Rails, or are using ActiveSupport, you can use
Continue reading “Ruby’s Safe Navigation Operator &. and is it a Code Smell?”
Have you ever wanted to make your own programming language? Maybe a template engine? A JSON parser? If you have ever built any of those, you might have noticed it’s not exactly easy to get started. We’d like to help with that.
Welcome to Part 3, the final in this series on Writing a Markdown Compiler!
Continue reading “Writing a Markdown Compiler – Part 3”
Have you ever wanted to make your own programming language? Maybe a template engine? A JSON parser? If you have ever built any of those, you might have noticed it’s not exactly easy to get started. There are a lot of concepts to digest before you get going. That’s why lots of devs just give up. We’d like to help with that.
Continue reading “Writing a Markdown Compiler – Part 1”
This post is about pretty code (with examples in Ruby), plus how to get nil out of the way and be more confident.
Does this code look familiar?
user && user.ask_for_email
Continue reading “Avoid nil-checks. Code confidently. Be happy.”
If you are a developer, chances are very good that you know what Object-Oriented (OO) code is. You might have also heard about OO Design Patterns, things like single responsibilities, decoupled code, and my subject here: Dependency Injection (DI).
Continue reading “What is Dependency Injection”
What must an Operating System do to satisfy web developers’ needs? This is a tricky question, as each person is a whole different world, so it’s impossible to have a single answer to satisfy every person.
Continue reading “A Web Developer’s OS”
[Authored by Alex G]
There are many cases where FileMaker’s scripting isn’t always the best tool for the job and where a language like Ruby can bring a lot of power to your FileMaker development. The following is a description of a simple technique for using ruby scripts from within a FileMaker solution without the use of a plugin. I’ve found this technique useful for employing regular expressions for complex text parsing, making web requests to work with web APIs, and for parsing and generating XML and other serialized data structures. Ruby has a wealth of great libraries for doing anything you can imagine and is just plain fun to write.
Continue reading “Ruby scripting in FileMaker”
[Authored by Ian]
I’ve probably written a hundred render_not_found methods in my life as a Rails dev. Usually they just render a static file under /public, and maybe, if I’m feeling nice, give an XML response. No more!
Continue reading “Never write a render_foo method again”
[Authored by Sam]
In beezwax’s webdev division we generally work in pairs, but our commit logs didn’t used to show this. We wouldn’t bother to reconfigure the git author every time we sat down with a new pair so our git log only recorded one of the programmers’ names. Bryan Helmcamp has a nice script for setting your git commit author in pair programming situations. Here’s another one which works interactively.
Continue reading “Setting the Commit Author to Pair Programmers’ Names in Git”