benfalk.com

my travels through time.

‘Raise’ in Ruby Is Just a Method

Today I was coding up a tricky bit of logic where I was using BasicObject to delegate all methods to another object it was encapsulating and I learned that raise is not a keyword in ruby.

Testing Against Multiple Rails Versions

Recently I wrote a Rails engine gem password_required. One of the first problems I ran into was not knowing what versions of Rails it would work with, so I kept the dependency rigid, “~> 4.1.6”. That of course alienated anyone working from the 4.0.x branch. I looked around at different packages to see how they handle this, and here is the solution I landed on.

Visiting South Cumberland State Park

Had a great time today with my wife and dog today! We decided to try and hit up a couple different state parks today but quickly discovered that maybe just one a weekend is more our pace. Did a fair amount of serious trail hiking and saw some really great waterfalls.

Bash Tips and Tricks

Using the up arrow to run previous commands in bash? If so you’re doing it wrong! Get to know you’re bash history and how you can use it to your advantage. When you press the up arrow you are cycling through you bash history, which you can see at anytime with the history command.

Love Visiting the Farm

Drove back to the farm for a wedding and it has been a great weekend. The fall air and spending time with the family has really reminded me how much I miss the rural area of Indiana. This breath of fresh air has helped super charge my programming itch and I am excited to put more into my open source packages!

CTags Are the Bomb

Recently I discovered what may be the best find yet on my path to enlightenment with vim, ctags. This nugget is amazing! It works with an impressive list of languages, of which Ruby and Erlang can be found. With Ubuntu it can be installed simply with

1
sudo apt-get install exuberant-ctags

From the working directory of your project the command “ctags -R” will index all the source files found in your project and put them in a file called “tags”. For this reason I added “/ctags” to my git global ignore file found here. Once the ctags file is created you can start up vim, and with your cursor under any language constant you can press “ctrl+]” and will jump to the file:line were it is defined.

Fast Active Record Setup

Was doing some prototyping today that required some deeper knowledge of how active record transactions work. From doing my spike I found a great light weight setup to tinker around with Active Record and felt it should be shared.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'active_record'

ActiveRecord::Base.logger = Logger.new(STDERR)

ActiveRecord::Base.establish_connection(
  :adapter => "sqlite3",
  :database => ":memory:"
)

ActiveRecord::Schema.define do
  create_table :widgets do |table|
    table.column :name, :string
  end

  create_table :bits do |table|
    table.column :widget_id, :integer
    table.column :name, :string
  end
end

class Widget < ActiveRecord::Base
  has_many :bits
end

class Bit < ActiveRecord::Base
  belongs_to :widget, touch: true
end

Mumble Bot With Ruby

Last week my brother wanted to make a Music Bot for mumble that would stream music from di.fm. He found a pretty cool project that was started in ruby for a headless client. Here is the link to that project. Being a ruby inclined person this seemed like a chance to relax and do some code tinkering.

Watch Your Burn Rate

Straight from a Google search “define: burn rate” — ‘the rate at which an enterprise spends money, esp. venture capital, in excess of income.’ This really isn’t a term I have heard of before for that context, and I am here to tell you it’s something you’ll want to be mindful of.

"Investors don't want to see this"