At a recent Upstate Ruby meeting I had the opportunity to share a really cool editor I’ve been learning called Spacemacs (technically an Emacs starter kit). Here’s my screen recording including audio of the talk:

Epic Key Bindings Used

Spacemacs organizes key bindings under the space bar in a mnemonic form (p for…

So this is cool. Elixir allows you to define a simple test module like so:

Which is cool and does things! But what exactly does it do? It runs code examples in documentation comments.(If …

Earlier this month I had the opportunity to attend Ancient City Ruby 2016 in St. Augustine, FL. (No, Florida will not become my second home.) The talks were varied and the opportunity for geek socializing were well thought out. …

March has been both an exciting and crazy month. Let’s review what happened and what’s been going on.

  1. ElixirDaze on March 4th. A whole bunch of folks got together and talked about Elixir with many neat applications, from robotics to embedded to web to telephony. …

Today I spent a good bit of time working on an algorithm to generate a primary navigation from an ordered list of pages using awesome_nested_set. This should be easy, right? Let’s try this out a few different ways.

The Wrong Way

Here’s the quick and dirty way to create an ordered hash from…

Today’s bits follow a random set of notes about the language syntax and me geeking out about a functional language and how it’s different from OO. In other words, you’ve probably read this before. Programming Elixir 1.2, here we go!

They’re in a queue. Clearly.

Lists are not arrays. Lists are not arrays. Lists are…

Because spaceships.

Elixir 1.2 has been released and so has a beta version of Dave Thomas’ book Programming Elixir. I’m taking the opportunity to read a new book and play with a new language all at once. Functional programming? I’m here for you!

Anyway, these are my notes from reading the book…

While reading an article today about what functional programming is, a comment rang true to me about the side-effects that might occur when a function calls a global element, such as a queue:

Can we test this code? Not in isolation. Unlike a circuit board, we can’t just plug into…

A random collection of logic to remember:

Logic: Ruby likes to return a value with the result of a boolean test, such as && or ||. This value varies depending on the operation:

  • && returns the last true value or false
  • || returns the first true value or false

after_initialize

Lastly an after_find and after_initialize callback is triggered for each object that is found and instantiated by a finder, with after_initialize being triggered after new objects are instantiated as well. http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html

I found myself in the position today of needing a method run when a temporary model was instantiated but not saved. In other words, the code should happen in a typical class init function. I suppose this is one of the few areas where monkey-patching Ruby functions isn’t highly appreciated, but hey, I’m good with a callback.

In my testing, after_initialize is not a place to store code that should run every time a model is saved. For instance, if a model is instantiated, updated, and saved, the after_initialize will only occur on instantiation. Duh.

Here’s the gist of things:

Andrew Anderson

Geek, husband, father, and Christian. Not necessarily in that order.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store