dholm.com
msgbartop
I need this baby in a month send me nine women!
msgbarbottom

29 Oct 08 Installing RubyGems on Solaris 9

We are using some Ruby on Rails applications at work and I’m impressed with how well they all work so I decided to install it on my private server as well. I’m using Ruby from Sunfreeware but they do not provide a packaged RubyGems. Considering it has its own package management I decided to install it manually.

I followed the installation instructions and executed “sudo ruby setup.rb –prefix=/usr/local” which proceeded to install gems into /usr/local/lib/rubygems. After the installation completed I executed gem in order to see that it had installed correctly but was greeted by:

bash-2.05$ gem
/usr/local/bin/gem:8:in `require': no such file to load -- rubygems (LoadError)
        from /usr/local/bin/gem:8

Which wasn’t quite what I had expected. After some googling I found that in order to get a list of dirs which ruby looks for libraries in you should execute “ruby -e ‘puts $:’” which produced:

/usr/local/lib/ruby/site_ruby/1.8
/usr/local/lib/ruby/site_ruby/1.8/sparc-solaris2.9
/usr/local/lib/ruby/site_ruby
/usr/local/lib/ruby/vendor_ruby/1.8
/usr/local/lib/ruby/vendor_ruby/1.8/sparc-solaris2.9
/usr/local/lib/ruby/vendor_ruby
/usr/local/lib/ruby/1.8
/usr/local/lib/ruby/1.8/sparc-solaris2.9

As you can see /usr/local/lib is not in this list so I moved rubygems, rubygems.rb, ubygems.rb and rbconfig to /usr/local/lib/ruby/site_ruby/1.8.

After these steps I was able to run gem and I performed a successful install of rake.

27 Oct 08 Tumblelog: 081027

Smile to QuickBird, a russian city organizes a cool Google Earth/Maps hack.

The Thirteen Greatest Error Messages of All Time, Technologizer takes us back through time to look at the thirteen greatest and least useful error messages.

Lego V8 by Brickshelf

the commentator, time commenting could be time coding. Non-free windows software but I still find it funny.

JLog is a thread and process safe message queue which utilizes journaling to assure delivery of messages.

The Sprite Resource holds a library of sprites captured from various popular games.

SqueakNOS is an attempt at removing the operating system underneath squeak.

TequilaCat Book Reader is a free book reader for alla Java-enabled phones.

20 Oct 08 Tumblelog: 081020

The Ten Greatest Hacks of All Time lists some of the coolest hacks of our time. Ben Heckendorn made the list, one of the greatest hardware hackers of this decade.

From "Best images of January 2008"

Metal Gear Solid 4 part 1, an article showing how Softimage is being used in the design of Metal Gear Solid 4.

Review: EFiX Dongle Perfectly Transforms PC to Mac, Gizmodo takes a look at the EFiX dongle. I wonder how long this thing will last before Apple quashes it.

Refactorings in Alphabetical Order, a simple list of refactorings. This is one of those lists that are handy to have bookmarked.

Run Mac OS X on an Eee PC, and you thought everything that could run on an Eee PC already was.

ViEmu, vi/vim emulation for a broad range of microsoft products. If your hand has been forced at least you can make the applications work with you.

Uninformed, “Informative Information for the Uninformed“. The title says it all, almost. A site with various information collected through reverse engineering and similar practices.

14 Oct 08 Rescheduling ISC cron jobs

We have a SLES server running at work and recently we’ve had issues with the groupware server failing to respond during certain hours of the day. After some sleuthing I found out that it is caused by the backup scripts for the database server. At first glance you might think that the database is being locked during the backup process but it happens even if I’m just copying the (transaction) log files using cp so I’m blaming it on the really slow drives in that particular server.

Now I wanted to reschedule the cron jobs so at least they would run the backups during off hours but no matter how much I googled I couldn’t find any good information on how to do this. The server is running ISC cron and the crontab only points to run-crons which in turn executes the scripts in /etc/cron.{daily|weekly|monthly}. After some more manual labor I found out run-crons is just a script and as it turns out it simply touches files in /var/spool/cron/lastrun whenever it runs a job in order to keep tack of when to run it again.

I’ve never had to fake creation times of files in a Unix system so again I turned to Google and apparently the answer is really quite simple. The touch command has an option, -t, which allows you to set the timestamp of the files rather than just fetching the current system time so I just modified the time of the cron files to some nice value in the middle of the night when very few people access the groupware system and vóila, problem solved!

13 Oct 08 Tumblelog: 081013

ASCII Table - The Pronunciation Guide, get your syllables straight!

EmailaCar.com, leave a public message for any car in the world.

Design, Modeling and Fabrication of the Möbius Gear by Aaron M. Hoover

One Day I Chanced Upon a Mystery at a local dollar store market. A photo story written in witty language by a guy who happened to chance upon a couple of mystery bags.

Stupid htaccess Tricks for your everyday Apache needs it’s a superb resource.

Portable AirConditioner, build your own rather than buying an expensive one.

Crunching your abs, taking a look at how min, max and abs are related mathematically.

Land of the Free, Steve Schofield has photographed nerds in their natural habitat doing what they do best.

06 Oct 08 Tumblelog: 081006

Amazingly Simple Home Remedies to some of life’s common problems.

Origin of Quake3’s Fast InvSqrt(), an analysis of the function for finding the inverse square root in Quake 3.

Continuous Integration Enhancement: The Broken Build Token! presents a cute idea for “punishing” whoever broke the latest build.

Git Quick Reference and Git - SVN Crash Course, being somewhat of a Git newbie I find these simple resources highly useful.

01 Oct 08 The idea of the thread throttling class

One particular problem in programming is when you have a thread which only serves the purpose of doing some trivial repetetive work in a timely manner. Most often these threads are implemented as:

while (isRunning) {
    doSimpleJob();
    sleep(Seconds(1));
}

In a perfect world all threads wait for signals rather than implementing this kind of busy-wait polling but when you need something simple like above I believe something as simple as busy-wait could be considered good enough in most cases.

The purpose of the sleep in the case stated above is to ensure that if doSimpleJob() completes in very few ticks we won’t end up unintentionally starving other threads while doing our trivial low priority task.

The downside to this is that if it is difficult to determine how long doSimpleJob() takes to complete, i.e. if it’s waiting for I/O, it will also be difficult to set a good timeout for sleep. If it takes five seconds to complete the job there is hardly no need to sleep for another second, and maybe you even want to run it again as fast as you can if it took a long time to complete. The solution I’m proposing is to implement a type that can determine how long we should sleep, if at all. Some pseudocode:

class Throttle {
public:
    Throttle(Milliseconds timeout) :
        m_start(Time::now()),
        m_timeout(timeout) { }

    void sleep() {
        Milliseconds duration(Time::now() - m_start);
        if (duration < m_timeout) {
            sleep(m_timeout - duration);
       }
    }

private:
    Time m_start;
    Milliseconds m_timeout;
}

Using this implementation the example mentioned above would become:

while (isRunning) {
    Throttle throttle(Seconds(1));
    doSimpleJob();
    throttle.sleep();
}

Now if doSimpleJob() takes less than a second one loop iteration would not take up more than one second and if it takes more than a second it will be instantly restarted.

One danger to this is that if doSimpleJob() is computation bound rather than I/O bound it might end up starving threads if it takes more time than the throttle timeout so it has to be applied with care.

For the sake of the argument lets assume that the implementation of sleep() being used actually sleeps for the whole duration of the specified time, no more no less.