Programming Rambling

mrzard's ramblings in the wild

Failed to Connect to Socket /com/ubuntu/upstart ? Upstart Jobs Cannot Be Run on Chroot

| Comments

Thanks to http://www.ashang.org/2010/10/unable-to-connect-to-upstart.html I was finally able to upgrade my system while chrooted.

Being on chroot will cause some packages to fail when they are upgrading. Giving us an error message like this one:

start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
dpkg: error processing procps (–configure):

You can workaround this limitation by running these commands

$dpkg-divert –local –rename –add /sbin/initctl
Adding ‘local diversion of /sbin/initctl to /sbin/initctl.distrib’
$ln -s /bin/true /sbin/initctl

Then you can run the upgrade, or do a dpkg –configure -a to upgrade the packages that were previously failing.

Choosing a Method to Store Passwords Safely.

| Comments

As seen in the Gawker/Gizmodo HUGE problem with having their passwords compromised, I found a short and excellent post about why using speed-oriented hash functions is a bad idea for password encryption.

In a nutshell, MD5, SHA1 and the like are designed to work fast with large amounts of data, so they are most useful when calculating data integrity and the like, but being fast, they are also easy to attack by brute force.

On the other hand Bcrypt is ‘slow’ when compared with other hashing algorithms, which makes it strong against brute force attacks. You can find the original post here: http://codahale.com/how-to-safely-store-a-password/

I do not necessarily agree with the ‘uselessness’ of salting passwords, as that makes it harder to find a general pattern to attack ALL of the accounts protected by a single password in the system, but I see the point of it not being able to prevent or slow brute force attacks.

The Two Things About Computer Programming (by Charles Miller)

| Comments

This article by Charles Miller says there are only two things that are really important to any discipline. This may or may not be true, but I really think he nailed it when it comes to programming.

Computer Programming:

  1. Every problem can be solved by breaking it up into a series of smaller problems.
  2. The computer will always do exactly what you tell it to.

Software Engineering:

  1. Writing the code is the easy part. Writing it so someone else can understand it later is the important part.
  2. Make it work, then make it elegant, then make it fast.

It’s very nice to see there are people out there who can summarize things in such a comprehensive and spot-on manner.

WebP, the New Google Image Format

| Comments

WebP is the new format Google is pushing to come to the rescue of broadband usage and get the place now JPEG holds. Tests seem to put WebP ahead of JPEG by a 39% file size margin, while holding at least as much quality as an equivalent JPEG. The format is lossy, as JPEG is, but seems to achieve better quality with less file size.

Google says they expect to get better compression percentages when starting from an uncompressed file rather than an already compressed one. I really want to see this at work, but again, people are VERY used to JPEGs by now, and in a broadband world, 100kB vs 61kB is not a big deal. Now, if you’re downloading 100’s of images, that could very well make a big impact, but that’s not the case with a very big portion of users.

Nevertheless, Google again shows they are concerned with making the web lighter, faster and easier, and I will be keeping an eye out for this new format.

More info at Google Code Blog on: WebP, a new image format for the web

Easy VirtualBox Setup Between Host, Guest and Other Networks

| Comments

At work, we use VirtualBox as our development box. Yesterday due to the strike, I worked from home, and as I grew tired of changing network settings to make my VirtualBox installation accessible, I gathered some info and found a perfect solution.

First I created a Network adapter that used NAT. In most configurations that will make your Virtual Machine have access ‘to the outside world’ (provided your host machine has access).

Then I created another connection using the host-only adapter. This ensures you’ll have host to guest and guest to host connection no matter where you are. For this connection, you’ll have to assign an static IP with address mask 255.255.255.0 and no default gateway on your host machine, then configure your adapter in the guest with an IP in the same range, also with no default gateway.

With this you can access your guest machine using the IP in the range of the host-only adapter, while the guest machine will be able to access anything available to the host machine via the NAT connection.

Then if you need to have your guest machine available in other networks, you just have to enable another adapter and configure it for the network in question.

With this configuration I now can plug my development machine (host and guest) at home or at the office and just work with no further configuring.

A New Take on PHP Object Oriented Programming

| Comments

I think this is an interesting idea, check it out!

Antipodean - PHP OO Programming reinvented

Author Dennis Hotson says about it:

There are some interesting implications of this:

  • Classes can be hacked / patched / cloned. Methods can be added to classes at any time
  • Classes can be scoped. They’re not global, unless you want them to be.
  • Classes can be temporary (and garbage collected).

Although I don’t think it’s that useful or advisable, it’s a great example of how far you can push PHP’s limits.