Showing posts from January, 2014

Another diversion

I was working through the Koans and got distracted.  I'm still learning Ruby, I promise!

Somewhere, I stumbled across Ruby Warrior, and it looked fun.  Plus it looked like something I could do without need to concentrate quite so hard, which helps if you're stuck on the couch watching "kid shows", for instance.

This is a turn based game where you can only do one action on your turn.  It is a two dimensional board, where you, as the warrior, have only a small set of abilities:

walkfeelattackhealthrestrescue Before you decide what to do, you can also "feel" a square.  This tells you what is there.  The result can be one of five states: emptystairsenemycaptivewall Currently, I am stuck on level 6, but I'll still give you a taste for the code:

class Player
  @last_known_health = nil
  RUNAWAY = 20 * 0.40
  BANZAI  = 20 * 0.75
  @found_wall = false

  def play_turn(warrior)
    @last_known_health = unless @last_known_health
    took_damage = @last_known_…

Your company might be making mistakes if...

I recently found this article about mistakes that companies make with development.  In it, they list out these mistakes:

Paying poorlyProviding inadequate equipmentGoing into technical debtRolling your own when good alternatives existNot providing dedicated project managementUsing developers for non-developer tasksNo learning for learning's sakeOffshoring Development I have worked at firms that have committed all of these, except #1.
So, should you leave to get improvements in any of these?  That, of course, is up to you.  I only really see two options:

Be an agent of changeLeave Being an agent of change is very difficult in my experience.  I wish I had some success stories to share with you, but I don't.
Here's one example:  I have thus far unsuccessfully, argued for a group of developers to write unit tests.
You'd think that this would be easy, because isn't unit testing at this stage a given best practice?  You'd think so, yet, I see many oftheexcuses used.  I…

Ruby's Data::Dumper

I was poking around a bit trying to find the Ruby equivalent of Perls Data::Dumper or Data::Printer.  At first, I didn't think anything like those existed.

Upon further research, it seems that the "normal" way of doing this is to use Marshal or YAML.

These are ok, and I'll probably play with them, but I got more excited when I subsequently discovered Awesome Print.

After installing...

gem install awesome_print

First run:

ctreptow@vm-0:~$ cat 1.rb                                                                                                                                                  #!/usr/bin/env ruby require "awesome_print" data = [ false, 42, %w(forty two), { :now =>,  :class =>, :distance => 42e42 } ] ap data

ctreptow@vm-0:~$ ./1.rb                                                                                                                                                    [ [0] false, [1] 42, [2] [ [0] "forty&…

Ruby Koans: current status

Just finished strings:

your path thus far [............X_____________________________________] 70/280

Knowing When

I was a Computer Science major in college.  This, of course, meant lots of programming.  In my case, the majority was in Pascal, plus I dabbled in others: Modula-2 and C primarily.

So, when it was time to graduate, I needed a job.  I interviewed at a couple of local places (one insurance, one PC software).  Well, neither one worked out, plus I felt I needed to farther away from home.  I eventually took one in Des Moines.

Was I programming?  Nope.  The choice was either program COBOL, or do something in their "Research & Development" department.  So, I became a "Research Analyst".  It was fun, but we didn't do much more than review software and hardware, write up the report and tell people in the company what to buy.

One of those projects was to compare UNIX systems.  That was actually pretty cool, I got to meet employee #33 at Sun (whatever his name was) and got me going on UNIX.

So that led me around to a path of doing DBA work and sysadmin work.  Eventu…

Ruby Koans: Fun With Hashes

So, I was working through getting Enlightened about hashes, when I came across this:

 79 deftest_default_value  80     hash1 =  81     hash1[:one] = 1  82   83     assert_equal 1, hash1[:one]  84     assert_equal nil, hash1[:two]  85   86     hash2 ="dos")  87     hash2[:one] = 1  88   89     assert_equal 1, hash2[:one]  90     assert_equal "dos", hash2[

Ruby Koans

I was sitting with my wife last night and she wanted to watch the rest of the Golden Globes.  I had stopped with my new game for the day and I don't particularly care for awards shows.

What to do?

I know!  Ruby Koans!

So, I've taken a slight diversion before eventually getting back on the path to Ruby on Rails.  I've only completed 12 steps on my path to Enlightenment, and already, I can see that the Codecademy Ruby track leaves just a bit out. :)

Setting up the Ruby environment

So, I want to take a stab at building an app with Ruby on Rails.  Before I start, I want to make sure I can reproduce it on a different machine.  The first step to doing that is to control the version of Ruby I'm using.

I found this guide to get started.  Luckily, I was already familiar with Perl's plenv setup, so this all looked very similar.

Although plenv wants you to run your shell as a login shell and modify .profile, rbenv doesn't seem to work that way.  I needed to follow the instructions exactly, and only modify the .bashrc, and then change my shell to NOT be a login shell.

Install rbenv I used this guide: rbenv

Install ruby-build This is used to provide rbenv the ability to install new versions of Ruby.  I used this guide: ruby-build
Install Ruby I chose to install the latest: rbenv install 2.1.0
However, this produce an error:
The Ruby openssl extension was not compiled. Missing the OpenSSL lib?
So, first you need to install libssl-dev
sudo apt-get install libssl-d…

Healthy Eating

A long time ago, I read Gary Taube's book Bad Calories, Good Calories.  I found it a bit difficult to get through and totally understand, but there were a couple of very basic takeaways for me:

The "healthy eating" ideas most people grew up with is wrong and based on bad or no science.Carbohydrates (refined) and other are bad, as proven by what our bodies actually do with them. Well, since then, I've also watched a few documentaries, such as Food Matters, Fat Head, Forks Over Knives, Hungry for Change.  I found them to be either inspiring, informative, or both.
So, this got me going to make some changes.  Luckily, my wife is also on board.  She must have mentioned something on Facebook about it, because she suddenly had an old friend start telling us about the 21 Day Sugar Detox.
I'm not sure about the "detox" portion, but I am convinced that most of the food I've been eating is actually bad for me.  I'm also not eating enough vegetables, that…

Becoming a Rubyist

So, I've decided to finally "officially" learn Ruby.  A couple of times, I remember having a terminal up and spitting out something like:

puts "Hello, world!

..and then I walked away.  Well this time it will be different...I promise!

So far, I have completed the Ruby track on Codecademy and now Smarterer says I'm proficient.  Time to spit out a couple of answers in Ruby on Code Eval as well.

What next, though?  I think that answer is Ruby on Rails.  Everybody around this area seems to use it, so I may as well put some effort into one of my ideas and see if I can get a site built with it.