Blogs

Today...

...I decided to tackle problem I recently found out about in fwbackups. If there is a large amount of stdout or stderr output in a short amount of time from the backup subprocesses, fwbackups hangs. That level of output should never normally happen while backing up user files, but if /proc or /dev is included in a backup for example then it could trigger the problem.

After 8 hours [1] of backup benchmarks, I've concluded that not only is python's tarfile module horrendously slow (with gzip compression enabled, it is consistently two times slower than calling "tar" from the command line as a subprocess) but that I unfortunately have to reverse the feature I added in 1.43.3rc3 that adds the display of the file currently being backed up in the GUI. Sorry in advance, but it was the only way to keep both performance and prevent fwbackups from hanging mid-backup in certain situations.

[1] which as it so happens, is also how many hours there are in the first season of How I Met your Mother. It's a hilarious show!

Rating: 
Tags: 

Fixing the iTunes 10 badness

I think many will agree that iTunes 10 was more of a marketing ploy than anything else... I found that iTunes 10.0 was worse than 9.x, primarily because of the "traffic light" style buttons in the window corner and graystyle icons. That was bearable though, and then the update to 10.0.1 came along made things even worse. No more Genius sidebar, and obnoxious "Ping" buttons every time a song is selected.

So I went on a quest to fix it, and found these commands on various forum threads and blogs:

(If you are unsure how to run these commands, quit iTunes and open Application > Utilities > Terminal. Copy/paste these commands in, hitting <Enter> after each to execute it.)

defaults write com.apple.iTunes hide-ping-dropdown 1
Disables the obnoxious "Ping" drop-down menu I mentioned earlier.

defaults write com.apple.iTunes show-store-link-arrows -bool TRUE
Restores the store arrow links present when a song is selected in 10.0 and earlier.

defaults write com.apple.iTunes disablePingSidebar 1
Disables the ping sidebar. Sadly, I haven't found a way to re-enable the Genius sidebar.

defaults write com.apple.iTunes full-window -boolean YES
Puts iTunes in "full window" mode, removing the traffic light window controls.

Now, the last thing is to restore color in iTunes. To do this, download the iTunes.rsrc file linked to in comment #7 on this thread. Next, right-click on iTunes in the Applications folder and select Show Folder Contents. Inside the Contents/Resources folder, copy the downloaded iTunes.rsrc file and opt to replace existing files when prompted. Restart iTunes and you should have coloured icons!

Note: If you're reading this but you're running iTunes on Windows, a user on Apple Discussions has posted how to do the same on Windows.

Rating: 

Cryptic MySQL error

Today as I was attempting to test one of my PHP applications, I received this error after attempting to connect to a MySQL database:

Warning:  mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter
than expected in index.php on line 29

Warning:  mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to
MySQL 4.1+ using old authentication in index.php on line 29

The script giving the error was running on OS X 10.6.4 with the stock PHP 5.3.1. After doing a bit of searching and reading the MySQL documentation on the old password format, I was a bit confused because I ran this on the server:
[user@host ~]# rpm -q mysql mysql-server
mysql-5.0.77-4.el5_5.3
mysql-server-5.0.77-4.el5_5.3

Both the server and client should support the new authentication version, which was introduced all the way back in MySQL 4.1. So why wouldn't it connect?

It turns out that CentOS 5 disables the new password hashes by default in favour of remaining compatible with 3.x (and earlier) MySQL clients. All you have to do is edit /etc/my.cnf and comment the old_passwords=1 line. After restarting the server, you should notice that running SELECT PASSWORD('foobar'); in a MySQL prompt will return 41-character hashes, not the old-style 16 character hashes. Reset the user passwords to start using the new hashes and you'll be good to go.

Rating: 

Heads up!

I'm going to be testing a module that emails commenters when there has been a reply.

Rating: 

Some quick PHP performance stats: suPHP vs prefork+mod_php vs itk+mod_php

I have been doing lots of research on how to properly secure PHP on a shared server, especially with regards to finding the best way to sandbox users. On stock apache installations, the apache user must have access to web content in order to serve it which has the unfortunate side effect that every user on the shared hosting server can read the files of every other user.

The solution to them is "sandboxing" them, or in other words having Apache serve each user's web files as that user. I will post a tutorial relatively soon detailing how to do so (along with configuring many other services) but in the mean time here are some benchmarks:

prefork: 2.720166 seconds
suphp: 13.621006 seconds
itk: 4.263002 seconds

These benchmarks were generated using the "ab" benchmark included with the httpd server. They represent the time it took to load the front page of my blog 200 times:
ab -c 1 -n 200 http://www.firewing1.com/
prefork is the standard apache MPM working with mod_php. It's the fastest, but for the reasons outlined above also the most insecure. suPHP tackles the problem by using a SUID executable and running PHP under CGI, but it is extremely slow - even for this modest drupal site, it is just over 5x slower than stock. I compiled the ITK MPM for Apache which also offers the feature of running files under different users but it is based on Prefork and uses mod_php. The performance is still worse (2x slower) than stock, but much better than suPHP.

Rating: 
Tags: 

The sequel to my Ubercart i18n adventures

It has been a while since I last wrote about Ubercart, but I'm still working on some multi-lingual stores for clients. I have opted for disabling the stock Catalog module and using Views instead since Views is so much more flexible and easier to theme. I have a very simple setup; some terms in a vocabulary that is localized per-term, and then a custom View that takes a term name as an argument and returns nodes belonging to that term and displays them in a nicely themed grid.

Recently, I ran into an irritating issue where the View would return results from the wrong language if two languages had the same term name. After hours of investigating (and learning all about how to implement View handlers and plugins), it seems that the stock taxonomy term argument validator for Views cannot differentiate between terms of the same name in different languages. So if multiple languages contain the term "Stewart Adam" for example, the view will just returns nodes for whichever term (and therefore language) comes first in the database query. To be fair, the i18n module adds the "language" column to the term_data table so it's not really View's fault... Nonetheless, I was surprised that the i18n module had not already corrected this issue.

I've just reported Drupal issue #832100, Taxonomy term argument validator should not validate terms defined in other languages that includes a fix to the problem by limiting query for term names to terms within the active language. It's not the greatest way to go about solving it since it essentially just copies the original validator and makes two tiny modifications in the SQL query, but it's better then modifying the View module directly.

Rating: 

XMLmind's XML Editor

DocBook is a great tool for any documentation writer, but it can be a real pain to get adjusted to. I had decided to use it for the fwbackups 1.43.2 user guide the end result was great (less a few spelling mistakes), but coding it by hand took a long time and isn't something I would want to do again

I have been using XMLmind's XML Editor to rewrite the documentation for fwbackups 1.43.3 in DocBook 5 and it's been great. It has a WYSIWYG interface and although the program has a small learning curve, once I got used to the hotkeys my productivity went way up. Version 4.6.0 (released about two weeks ago) also includes a new Link tool can be enabled in the Preferences (under General > Features) that is excellent for creating cross-section links in your documents. After giving a section an xml:id name in the Attributes section, highlight a piece of text and select Edit > Add or Change Link... from the menu. All of the document's xml:ids for will be listed and selecting one will create the link automatically.

The license for the personal edition license allows XMLmind's XML editor to be used to write documents for any open source software (as defined by the OSI) - if you need a quick way to write great looking documentation, consider paying XMLmind's website a visit.

Rating: 

Random thought

In any of my future classes related to operating systems, I want to try saying "sudo" instead of "please" and see how many people get it :P

I'll keep you updated.

Rating: 
Tags: 

Some hidden gems in the iTunes 9 visualizer

It's more or less well known that the stunning visualizer in iTunes 9 is actually a modified version of The Barbarian Group's Magnetosphere. I recently downloaded a copy of the original magnetosphere visualizer, and one thing I enjoyed was the ability to control the amount and intensity of the particles (the glowing, moving dots). The following is displayed in the visualizer's help screen:

+/- Increase or decrease the intensity
A/S Add or Subtract particles (100 at a time)

While these commands are not listed in the help screen of the official iTunes version of the visualizer, to my surprise I found that they still work! They've proved useful for when the iTunes visualizer seems to get stuck for a bit with one of the big black stars blocking the view.

Rating: 

My thoughts on Java after having used it for 2 months

One thing that has always annoyed me during my CEGEP studies is that although my CEGEP actually offers a computer programming profile, I can't take it. It is much easier for me to study pure & applied sciences in CEGEP and then apply to software engineering or computer science at university afterwards than it is to take the computer programming route at CEGEP because then I would be stuck catching up on a bunch of the requirements like calculus and physics after CEGEP.

You might ask, "Pure & applied sciences aren't so bad... So why is it annoying?" It's annoying because I cannot take more than one computer science-related course throughout my two years of studies at CEGEP in pure and applied science. Anyways, that ranting just to say that I've been saving that one computer-related class for my last semester, so this term I've been attending Introduction to Computer Programming in Engineering.

To my disappointment, I found out that we were going to be using Java throughout the entire class in class (I was hoping for a more modern programming language like Python, which I think would have been better suited for programming beginners). I've also always hated Java. Up until now I didn't really have a solid foundation for the hate - I just didn't like anything about it.

Now that two months of the course have gone by, I can say that I still dislike Java. I'll keep my reasons quick and to the point, but keep in mind that I'm saying this from the perspective of designing user applications to be run on a desktop machine:

  • For the longest time, Java was closed-soure and remained under the sole control of Sun Microsystems (now Oracle). Although most of Java has now been open sourced, the OpenJDK implementations are still incomplete.
  • Have you ever seen a GUI Java project? Even with a good deal of theming, they tend to look terrible next to some of the C++ GUI projects using Qt or WxWidgets for example. I'm a big fan of ease of use and good user interfaces, and Java does this very poorly with very little integration with the OS running the JVM. This point alone is enough to make me never touch Java again.
  • Java has much of the complexity of C or C++... So why not just program in C or C++? Doing the bit of extra work to handle garbage collection and getting it to work on multiple platforms will just make you a more experienced and better programmer in the long run. In addition, if you decide to use a toolkit like Qt or WxWidgets then much of the multi-platform work is done for you already.
  • Java has many annoying quirks:
    • Only one public class per file allowed
    • The filename must be the same as the name of that one public class
    • For all functional purposes it doesn't matter, you cannot make a simple, global "subroutine" in Java; everything must be a method and belong to a class.
  • It's clunky. If you start to add in GUI, networking and a few other components to your program it starts to get pretty large and resource-intensive. A C++ equivalent of the same program would be more efficient.

And there you have it: why I don't like using Java for real world application programming. Java certainly has its place - I think that it takes care of the mobile market/niche wonderfully - but for desktop applications Java is the wrong tool for the job.

Rating: