nathaniel bibler

Random thoughts, links, and code by Nathaniel Bibler

God Damn Tropicana…

Of course, my last entry is a rant on how horrible the box design is for Tropicana. Now, two days ago, my wife sent me to the grocery store (“uhh ohhh”) … and what’d I get ? Tropicana, No Pulp. Low Acid.

Seriously? All the f’n boxes look the same. REALLY? ReaLLY? I swear I stared at that shelf for .. easily 2 minutes, if not longer … trying to decipher their insidious code. Obviously I’m not smart enough, man enough, or what have you… I failed.

I hate you Tropicana. If you didn’t make such tasty orange juice, I’d leave and never come back.

And, by the way, let me just give Pepsi a big f* you for changing the Tropicana brand packaging to such a thoroughly terrible design.  We easily buy Tropicana once a week (or sometimes more) and even with the redesign having been on the shelf for the better part of a month now, we still can’t find the versions we like without gawking at the IDENTICAL BOXES for 5 minutes in an attempt to discern flavors.  Also, I should apologize to the Publix employee whom we yelled at for discontinuing Tropicana the first week the design was introduced, while we were standing directly in front of it.  We swore it was Publix brand in its place.

And, by the way, let me just give Pepsi a big f* you for changing the Tropicana brand packaging to such a thoroughly terrible design. We easily buy Tropicana once a week (or sometimes more) and even with the redesign having been on the shelf for the better part of a month now, we still can’t find the versions we like without gawking at the IDENTICAL BOXES for 5 minutes in an attempt to discern flavors. Also, I should apologize to the Publix employee whom we yelled at for discontinuing Tropicana the first week the design was introduced, while we were standing directly in front of it. We swore it was Publix brand in its place.

I don’t honestly believe that the general public will notice the subtle differences in the new Pepsi branding stripes (wider white for Pepsi Max, thinner for diet Pepsi, etc.).  Terrible waste + global recession …

I don’t honestly believe that the general public will notice the subtle differences in the new Pepsi branding stripes (wider white for Pepsi Max, thinner for diet Pepsi, etc.). Terrible waste + global recession …

Using the Ruby Array#uniq with custom classes

You may (or may not) have noticed that when you create a custom class in Ruby, Array#uniq — and friends — no longer work as advertised. You can override the eql?, equal?, ==, and still not get it right.

For the solution, you must override both the eql? and hash member methods of your custom object:

class MyFoo
  
  attr_reader :custom_unique_id
  
  # Internally, Ruby converts your array
  # objects each into a hash (identifier, 
  # not object), using #hash.  By default
  # this is #object_id.hash, which is no
  # longer appropriate.  The purpose is 
  # to recognize which objects have the 
  # same hash and which do not, thus they 
  # are unique.  So, override.
  def hash
    custom_unique_id.hash
  end
  
  # Simply delegate to == in this example.
  def eql?(comparee)
    self == comparee
  end
  
  # Objects are equal if they have the same
  # unique custom identifier.
  def ==(comparee)
    self.custom_unique_id == comparee.custom_unique_id
  end
  
end

Now, your objects and their containing enumerables will acts as you have come to expect.

Incredible waste of money.

Incredible waste of money.

Fox News, Fear Imbalance. God, I hate Fox News. Smite them, please.

Snow Hill Mountain Bike Trails (Little Econ State Park)

Snow Hill Mountain Bike Trails (Little Econ State Park)

Phusion Passenger 2.0.5 and Ruby

After an hour or so of configuring a new, fresh CentOS 5.2 server, primarily relying on yum repositories, I thought I was nearly done. I installed Apache2, Ruby, rubygems, passenger, …. I was good to go.

Passenger spawn server: symbol lookup error: /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.5/ext/passenger/native_support.so: undefined symbol: RARRAY_LEN
*** Exception NoMethodError in spawn manager (undefined method `[]' for nil:NilClass) (process 15937):
Awesome. Apparently Phusion Passenger 2.0.5 requires Ruby 1.8.6 or greater. That pretty well screws yum repo installs of Ruby for CentOS 5.2, which is currently at the oh-so-up-to-date 1.8.5 (2006-08-25) version. Hurray. Time to yum remove and start over.

git and opendiff

git config --global merge.tool opendiff

Remotely Securing CentOS

Lets assume you’ve got root access to a CentOS VPS. Further, lets assume you want to secure it in some way. Lets go with the following: First, create a new, non “root” user which will have sudo privileges. This creates the user, expires their password (prompting them to immediately change it), and sets the password empty.

$ /usr/sbin/useradd my_user_name
$ /usr/bin/chage -d 0 my_user_name
$ /usr/sbin/usermod -p "" my_user_name

$ su my_user_name
my_user_name$ passwd
# Set the new password
my_user_name$ exit

$ groupadd sudoers
$ visudo
# Add the following line to the file:
%sudoers ALL=(ALL) ALL

$ usermod -G sudoers my_user_name
So, that gets us off of using the root user for everything. Now, the my_user_name user will have full sudo access to accomplish your administrative tasks. Now, to secure the SSH connection. First, sign into your sudoer user and make sure you install your local public keypair in .ssh/authorized_keys (or authorized_keys2). Log out and log in using the keypair to be sure it works before proceeding. Usually the only hiccup here is file permissions. Now, on to the securing:
$ vi /etc/ssh/sshd_config
Be sure the following are set:
Protocol 2

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys

PasswordAuthentication no

PermitRootLogin no
Then, restart sshd:
/etc/init.d/sshd restart
If you’re ultra paranoid, you can always change the SSH listening port in the sshd_config with:
Port 1617