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.
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.
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 config --global merge.tool opendiff
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