My First Taste of Pattern Matching in Scala

I just got a taste of some pattern matching in Scala. It was not really like what I had scene in Elixir or Haskell, but seems straight forw...

September 28, 2014

INT J

So, I recently tweeted about my personality type. I'm not exactly sure what lead me down this "personality test" road again.  I think it was linked in some article from LinkedIn.  What I found more interesting this time is the result: 'INT J'.  Huh?

I had never heard of this 'INT J' before.  What was this?  Well, I read the whole description..and I keep reading it.  I cannot believe how this fits me...perfectly.

Just check out some of the quotes:

"INTJs need and want to know why things are the way the are."

"Although quietness pervades, INTs are capable of being real chatterboxes, but not in general or small talk—only on issues which are important to them or which stimulate them."

"INTJs love the intellectual challenge and will come to the fore when there are difficult problems to solve"

"INTJs will overturn established practice by being forward-thinking and truly radical."

"They excel at deep diving and working on the unique, interesting, and complex."

"INTJs love developing unique solutions to complex problems"

I'm just shocked.  It's like someone finally understands me.  Looking back, when I've done the best, a lot, if not all, of these things were happening.  Conversely, when I get frustrated, very few, if any of these are happening.

So, how do I capitalize on this information?  My first thought was to search for "what careers fit INT j".

The fourth result gives ideas about attributes to pursue or avoid.  Go read them, they fit me perfectly...again.

The first result suggests the following:

Possible Career Path for the INTJ:
 
   Scientists
   Engineers
   Professors and Teachers
   Medical Doctors / Dentists
   Corporate Strategists and Organization Builders
   Business Administrators / Managers
   Military Leaders
   Lawyers / Attorneys
   Judges
   Computer Programmers or Systems Analysts


None of this is much of a surprise, I guess.  I'm already doing that last one, and I generally like IT stuff (but I also like science and engineering.  Perhaps this means I should finally pursue that masters degree?  I pursued this for a bit in the last 90's, but never really got started.

The idea of pursuing a masters is intriguing, but I feel like I  should repeat my bachelors in Computer Science because so much time has passed and many things have changed.

I don't know what I'm going to do, but I know that any change will require work and time that is at a premium right now.

Let's see where this goes.

May 20, 2014

Will you be my friend?

I received this email yesterday:

Hello,
 I am Hanna Yapo,I saw your email address when i was searching Google today, I am interested to know more about you and also willing to have you as my friend. Let me know your interest on me.
 Thanks
Hanna Yapo


I really do not know how to take this.

Is this the weirdest spam I've every received?

Is this some sort of phishing attempt?

Is it sincere?

Currently, I'm choosing to not reply.

April 25, 2014

Casting Doubt

So, I'm going about my day when I see this come across Twitter.  So I go and read it.

Wow.  Let's go through it.

It opens with:
Are you trying to bring modern development practices to a… less-than-modern software development environment?
Uh, yeah, I have been for over 2 years.

Then he lists the warning signs:

  • Silos
    • Yup, this kind of "bigger picture" stuff is rarely shared, and only after there's been an issue.
  • Visibility
    • Surprisingly no.  Most everything we have is at least in SVN.
  • "We're too busy for maintenance"
    • That's a definite "yes".

Does my current employer have a problem?  Yup.

I've been trying to just get simple things accomplished for over two years now.  We're talking little things, like upgrading Perl to something in the last decade and writing unit tests.

Of those two, only the Perl upgrade has any traction (also strangely with a move from Windows to Linux).  However, we are on year two of the upgrade and are in exactly the same place with it as last year.  This time, I"ll work harder to not let it drop.  Of course there are still outstanding items, like integration testing, using web frameworks, using an ORM, PSGI, etc.

So, moving on to strategies.  Well let's see, top down?  Nope, that has gone no where.  Management poo poos any and all new ideas, with the exception of the upgrade.


Working bottom up, certainly seems like the ticket.  Oh, he starts with testing.  Well, having spent time teaching Perl classes and showing a few coworkers how Perl tests work, you'd think this would be a no brainer.  Nope, the few that would listen to me went "uh huh", and moved on.  I still write them of course, but it's lonely being the only one.  Instead we spend WAY TOO MUCH TIME, clicking on our web app to test stuff.

Well then Jay talks about CI a bit.  Um, yeah.  I guess I should focus on his last sentence: "Small and simple is infinitely superior to nothing".  Of course that's easier said than done in an environment of hostile sysadmins, but I suppose those are stories for another day.

Jay ends with the investment angle.  That's how I've tried to see these things...investing in our future.

As you can probably tell, I work in a very backwards development environment with closed minded "we've always done it this" way people.  It is super frustrating and I'm at my wits end.

I could give all of this another shot, but that means time and patience.  I don't think I have the patience, and my time is likely better spent learning stuff I can use somewhere else.

That's where my head is at.  Perhaps yours is in a different place.

April 10, 2014

...and it begins

Ok, let's let the cat out of the bag, today I ran the following in my Cloud 9 workspace:

rails new name-that-book

Exciting isn't it?

One idea I had was to recreate something like the old "Name That Tune" show.  In the show, contestants had to name the tune in as few of notes as possible.

I intend to recreate that with music, but let's start with something that might be a bit easier.

So, I still need to start fleshing out all the ideas, features, and details, but at least I've got a repo to hold some of my original thoughts and code on this.

The first step, I think, is to ignore the front end and get a backend RESTful thingy working with tests.

May this be my first baby step into a new job.

Wish me luck.

April 3, 2014

Distractions...

So, I said earlier that I was out to become a "Rubyist".  This is still true, and I'm finally ready to get back on that wagon.  What have I been doing?  Well, I've been spending time on CodeSchool.  I found a Groupon a while back and just went for it.

I'm pretty happy with CodeSchool so far.  According to them I am now a master in HTML/CSS and Javascript.  Since most future work is probably going to be for the web, I thought this was a good investment.  I like the modern HTML elements, I learned a bit about SASS which I knew nothing about before.

The other "win" is with Javascript.  I could get simple things done in JS, but I feel much more equipped to do something "real" with it.  They even had courses on Bootstrap and Ember (with an Angular course coming).  Although I probably couldn't write an Ember app from scratch without a lot of help, I did learn quite a bit and it solidified some concepts.

So, with those two tracks accomplished, I'm excited to get back to Ruby and Rails.  I've even thought of a couple of ideas of apps I want to build...one of which should be really fun if a few details pan out and when I get it working.

So, I'm going to get busy with Ruby, but I might just make the Rails project to provide the backend for an Ember app. We'll see where this all leads.

One last thing that I'll probably put on twitter also: I'm bummed that I'll never use this at my employer, so yes, I'm on the market for a progressive Perl or Ruby or Python shop.  I'm ready to experience agile, pair programming, and modern web techniques.

January 29, 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:

  • walk
  • feel
  • attack
  • health
  • rest
  • rescue
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:
  • empty
  • stairs
  • enemy
  • captive
  • wall
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 = warrior.health unless @last_known_health
    took_damage = @last_known_health > warrior.health
    
    if !@found_wall
      if warrior.feel(:backward).captive?
        warrior.rescue! :backward
      elsif warrior.feel(:backward).wall?
        @found_wall = true
        warrior.walk!
      else
        warrior.walk! :backward
      end
    else
      if warrior.feel.empty?
        if took_damage
          if warrior.health <= RUNAWAY
            warrior.walk! :backward
          else
            warrior.walk! :forward
          end
        else
          if warrior.health < BANZAI
            warrior.rest!
          else
            warrior.walk! :forward
          end
        end
      else
        if warrior.feel.captive?
          warrior.rescue!
        else
          warrior.attack!
        end
      end
    end

    @last_known_health = warrior.health
  end
end

It doesn't really feel like I'm taking advantage of any of the Ruby idioms.  Or maybe I am?

Time to go for a think about this...



January 18, 2014

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:

  1. Paying poorly
  2. Providing inadequate equipment
  3. Going into technical debt
  4. Rolling your own when good alternatives exist
  5. Not providing dedicated project management
  6. Using developers for non-developer tasks
  7. No learning for learning's sake
  8. Offshoring 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:

  1. Be an agent of change
  2. Leave
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 of the excuses used.  In fact, the "Word has been given" that we shall not write them at all on one project, and we may not commit them to the repository with the rest of the source on any other project.

So, I can write unit tests, somebody else will break them and be completely clueless about it.

I have tried to educate, but so far, it has meant nothing.  If people don't want to change, it is unlikely they will.

As for the other points in that list.

#2 and #3 affect you every day when you start working.  Does your PC work?  Does the code stink?  Both of those suck to deal with every single day you work.  Incurring technical debt is natural, but if you can never go back and fix it, then that load of debt keeps growing and bogs down everything you do.  Projects stall, or take longer than expected.  Bugs are very difficult to fix, as well.

The worst thing is that without doing #7, people may not even know they are incurring more technical debt.  Unaware of unit testing?  Writing huge monolithic procedures?

That's debt that you may never get out from under and you may not even know it.

January 16, 2014

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 => Time.now,
 :class => Time.now.class, :distance => 42e42 } ]
ap data


ctreptow@vm-0:~$ ./1.rb                                                                                                                                                   
[
    [0] false,
    [1] 42,
    [2] [
        [0] "forty",
        [1] "two"
    ],
    [3] {
             :now => 2014-01-15 22:49:02 +0000,
           :class => Time < Object,
        :distance => 4.2e+43
    }
]
ctreptow@vm-0:~$  

I like that.  I think it will come in handy when I get around to actually making something.


Ruby Koans: current status

Just finished strings:

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

January 15, 2014

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.  Eventually, I was sick of sysadmin work and wanted to program.  Of course, since I hadn't been doing programming, I didn't think I'd ever get a programming job.

That's when an old friend called and said "we need good people, will you come back?".  "Is there programming?", I said.  "No, not really".  I took it anyway.

The position was to manage our networking devices, thousands of routers, switches, and hubs.  I also managed DHCP, and DNS.  I did manage to find some programming, though.  I modified the DHCP server using C, and wrote bunches of scripts in bash and Perl.

That position turned into a dead end, but I didn't know when to call it a day and leave.  I stayed probably 10 years too long.

I finally did get another internal position supporting some software.  I also found a way to get a little programming in using Java.  I should have left after that first year, but once again, I didn't know when to leave.

I and my team got transferred out to another area where I stuck it out for another two years.  Here again, I didn't know when to leave and should have after the first year, because this new area was horrible.

I finally did get out of there and into my current position.  I think I've finally learned something, because in this case, I do think I know when to leave.  More on the in the future perhaps.

The lesson for you is: figure out when it is time to leave and leave.  Sticking it out in something you hate is horrible, don't do it.

January 14, 2014

Ruby Koans: Fun With Hashes

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

 79   def test_default_value
 80     hash1 = Hash.new
 81     hash1[:one] = 1
 82 
 83     assert_equal 1, hash1[:one]
 84     assert_equal nil, hash1[:two]
 85 
 86     hash2 = Hash.new("dos")
 87     hash2[:one] = 1
 88 
 89     assert_equal 1, hash2[:one]
 90     assert_equal "dos", hash2[:two]
 91   end
 92 
 93   def test_default_value_is_the_same_object
 94     hash = Hash.new([])
 95 
 96     hash[:one] << "uno"
 97     hash[:two] << "dos"
 98 
 99     assert_equal ["uno","dos"], hash[:one]
100     assert_equal ["uno","dos"], hash[:two]
101     assert_equal ["uno","dos"], hash[:three]
102 
103     assert_equal true, hash[:one].object_id == hash[:two].object_id
104   end
105 
106   def test_default_value_with_block
107     hash = Hash.new {|hashkey| hash[key] = [] }
108 
109     hash[:one] << "uno"
110     hash[:two] << "dos"
111 
112     assert_equal ["uno"], hash[:one]
113     assert_equal ["dos"], hash[:two]
114     assert_equal [], hash[:three]
115   end

It's easy to cheat and get these to pass, but I want to know what is going on, specifically in lines: 86, 90, 94, 96/97, 109/110, and 114.

Time for some research!

So, doing this, hash = Hash.new("dos"), means that "dos" will be used for all default values in that hash.

That explains line 90 and why the correct value is "dos", rather than nil, like I originally thought.  Turns out if we don't provide a default value, nil is what you'll get.  Makes sense, I guess.

So then on line 94, we are setting the default value to an empty array.  What I forgot before was that << is pushing a value onto an array.  In this case, the empty arrays that are the values associated with the keys: :one and :two.  Cool, it makes sense!

This brings us to line 114.  It is related to how this hash was created on line 107.  In this case, it was created with a block.  This is defaulting the value to an empty array each time, but would pay attention to the value of the key if you pass one in.

The docs are good and illustrate the difference:

h = Hash.new("Go Fish")
h["a"] = 100
h["b"] = 200
h["a"]           #=> 100
h["c"]           #=> "Go Fish"
# The following alters the single default object
h["c"].upcase!   #=> "GO FISH"
h["d"]           #=> "GO FISH"
h.keys           #=> ["a", "b"]

# While this creates a new default object each time
h = Hash.new { |hash, key| hash[key] = "Go Fish: #{key}" }
h["c"]           #=> "Go Fish: c"
h["c"].upcase!   #=> "GO FISH: C"
h["d"]           #=> "Go Fish: d"
h.keys           #=> ["c", "d"]

Wow, I think I just learned some things here, but the trick will be to remember them.

January 13, 2014

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. :)

January 12, 2014

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-dev


Set the default version to Ruby 2.1.0

ruby env global 2.1.0

Ok, so now that this is all complete, I can now be confident about what Ruby version I'm working with.

Next up is bundler to manage the versions of gems I want to use.


January 11, 2014

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's for sure.

So, armed with some information and support, we are making some changes.

I bought a juicer and the two 21 Day Sugar Detox books, and off we go.

My plan is to have a glass of juice everyday when I get home, rather than eating whatever may be within reach.  I've started with variations of the Dr. Oz green drink.  It's actually pretty tasty.

The easiest thing so far has been to replace cereal in the morning with an omelet.  They are easy and quick to make, plus I can add things (veggies and meats) depending on what is in the fridge.

It is suddenly, very hard to eat out AND avoid the bad carbs, because they are everywhere, embedded  in all sorts of meals.  I did find a bacon and shrimp spinach salad at Applebee's that is very tasty.

So, less sugar and more veggies.  Let's see how this goes.

January 8, 2014

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.