20 September 2007

Preserving time stamps on FAT32 copies

Strange thing about accessing FAT32 in Linux is that you get annoying warnings when manipulating the date and times of files. cp, tar and mv all raise wierd errors when doing the most basic things.

I especially needed to move some photos to my FAT32 mount, with the specific intention of retaining the file creation date and times. The correct command is "cp -p" where the "-p" flag means "preserve".

So we try:

$ cp -rp ../../cdrom/070915 .
cp: preserving times for `./070915/070915_P1250210.JPG': Operation not permitted
cp: preserving times for `./070915/070915_P1250211.JPG': Operation not permitted
$ ls -la 070915/
total 5344
drwxrwx--- 2 root plugdev 32768 2007-09-20 17:47 ./
drwxrwx--- 34 root plugdev 32768 2007-09-20 17:47 ../
-rwxrwx--- 1 root plugdev 593386 2007-09-20 17:47 070915_P1250210.JPG*
-rwxrwx--- 1 root plugdev 596410 2007-09-20 17:47 070915_P1250211.JPG*

The problem here is that the file creation date should be sometime on the 15th of September. NOT today. Did a google, and it brought me to this nugget of information:

This forum post:
if your own user id does not match the 'virtual' user-id, cp can not change the file date back to file date the source file.

The solution is clear - find out your user id (XXX), mount the partition with uid=XXX, and all the files on that partition belong to you - even the newly created ones. This way cp -a can set the original file date.

This works, of course, only for ONE user (and root).
So I changed the /etc/fstab file. Im quite disturbed by the new UUID usage instead of the ole fashioned /dev/hda access:

# Entry for /dev/sda5 :
UUID=41BD-AB60 /media/M vfat defaults,gid=users,utf8,umask=007 0 1

to

UUID=41BD-AB60 /media/M vfat defaults,uid=1000,gid=users,utf8,umask=002 0 0

Please note the changes in bold. A quick remount:

# umount /media/M
# mount -a

and copy:

# cp -rp ../../cdrom/070915 M/Photos/

Gives us:

# ls -la M/Photos/070915/070915_P1250210.JPG
-r-xr-xr-x 1 yky users 593386 2007-09-15 09:47 M/Photos/070915/070915_P1250210.JPG*

woohoo!

yk.

Domino PCs!

14 September 2007

Easily changing theme colours in Drupal

I like the "Garland" theme for Drupal. Its nice an elegant. However I needed to change the hues to represent a certain corporate colour. What I accidentally found while browsing through the CSS files was there there was some "preset" colours.
Intrigued, I did a google search and was pleasantly surprised to find that the Garland theme in Drupal allows easy changing of colours just by clicking on colour wheels! "How to change colours on the Garland theme". Theres even a nice screencast by the author.
However, when I went to "Administer >> Themes >> Garland-configure", I couldn't see the colour pickers as the screenshot above.

So I checked "Administer >> Modules" to double check that the Colors module was installed. And it was.

Checked "Administer >> Logs >> Status Report" and saw that the GD Graphics Library was also installed. All OK.

Then finally, "Administer >> Site Configuration >> File System" must have its "Download method" as "Public - files are available using HTTP directly."

Once that was selected (which it wasn't), the Colour pickers appeared!

[Drupal could improve by telling its admins what to enable to get the pickers to appear]

I changed the colours, and the onscreen colours changed immediately. However, when I clicked on "Save", my new colours refused to save, and it complained that PHP required 2.4MB more memory!

Strange, I checked the computer's memory, swap and harddisk and found no shortage. This link however says that its a PHP setting. /etc/php.ini, under the ; Resource Limits section. I changed it from 8MB to 18MB.

memory_limit = 18M ; Max amount of memory a script may consume

Once that was changed, the new colour scheme worked like a charm. This page "Integrating the Color Module" describes in detail how Drupal uses a PNG template, the GD library to create the nice gradients, and the PHP calls to slice up the images to create the templates for use. Quite fascinating.

yk.

11 September 2007

Move over Spock




You Are Incredibly Logical



Move over Spock - you're the new master of logic

You think rationally, clearly, and quickly.

A seasoned problem solver, your mind is like a computer!

Mighty Mouse Wired!

After trying out the bluetooth MightyMouse, I went to look for a good deal online. I decided against getting the bluetooth model because my laptop doesn't have a built in bluetooth adaptor. Plus I didn't want the hassles of batteries and such.

I did find a good e-bay seller, so I bought a few to bring down the shipping costs. All in all, it was about RM100 for each mouse. Quite a bargain compared to the Mac shops at KLCC which sell it for RM199.

Finally, after waiting 11 days of waiting, my Apple Mighty Mouse has arrived! Plugged it in, and it worked off the bat - as a normal mouse. Left click, Middle click, Right click all ok. Vertical scroll is smooth and accurate. Laser light shows a picture of a mouse too. All OK!

Im now configuring xorg.conf to allow for the horizontal scroll, and this is what you need to do:
Section "InputDevice"
Identifier "MightyMouse"
Option "CorePointer"
Driver "evdev"
Option "Name" "Primax Electronics Apple Optical USB Mouse"
Option "HWHEELRelativeAxisButtons" "7 6"
Option "Buttons" "8"
Option "Buttons" "9"
EndSection
The difference between this Input device and a regular mouse is that the Driver is "evdev". The "Name" should correspond to the name detected by your system. To review, you can check out /proc/bus/input/devices. You should find an entry which looks like:
I: Bus=0003 Vendor=05ac Product=0304 Version=0110
N: Name="Primax Electronics Apple Optical USB Mouse"
P: Phys=usb-0000:00:1d.0-2/input0
S: Sysfs=/class/input/input10
H: Handlers=mouse3 event8 ts3
B: EV=100007
B: KEY=f0000 0 0 0 0 0 0 0 0
B: REL=143
In the xorg.conf, make sure that in the "ServerLayout" Section, you have added a reference to this input device:
  InputDevice "MightyMouse" "AlwaysCore"

Make sure the "AlwaysCore" is there, otherwise the mouse won't be recognised by X.

Restart X (Ctrl-Alt-Backspace), and horizontal scroll should work. You can test with Inkscape.

For Firefox, a little bit more tweaking is required, as the horizontal scrolling of the ball actually maps to the "Back" and "Forwards" button of the browser. As you can imagine, this is "very irritating."
So to configure Firefox to behave properly, type in about:config in the URL bar, and edit mousewheel.horizscroll.withnokey.action from "2" to "0".

Immediately, (Firefox restart not required) you will find that the horizontal scroll will work. Unfortunately, the default direction is reversed! When you scroll the ball to the right, the page goes the the left and vice versa. Very disorientating and worthy of a prank in the future.

To fix this, change mousewheel.horizscroll.withnokey.numlines from "-1" to "1". This will reverse the direction to normalcy.

Compared to the bluetoothed Mighty Mouse, Wired Mighty Mouse is alot lighter, and easier on the wrist. Compared to my trusty old Logitech M-BJ58, the weight is about the same. However because of the construction of the device, it feels a lot more solid. Only time will tell how long the infamous Apple plastic will hold up.

Already Im addicted to the scrollball in moving around web-pages effortlessly. Looking for the scrollbars and aiming is now a thing of the past!

As mentioned above, I ordered a few Mighty Mouse from the seller. So I now have a couple of Apple Mighty Mouse to be resold. If you are interested, contact me. First come first serve, while stocks last, blah blah blah. RM100. A whopping 49.7487% discount! What-a-bargain. Works extremely well with your free desktop.

yk.

4 September 2007

Indexed

Im a big fan of Jessica Hagy's indexed cards of venn diagrams, graphs and connections. Todays edition is the best of all - "Plays well with others":


yk

3 September 2007

Headphones

Check out this picture:

Microsoft Netmeeting is so revolutionary! Skype eat this! Hehhehhhh!

Its so scary on so many levels. This is Steve Ballmer. He is the top guy at Microsoft. He seems to be thrilled at something to do with video conferencing. Look at his face in glee. Even when he's happy, he's scary. But look closely at the picture. The headphones dont seem to be big enough for his smooth big head. That is because the top dog at a high tech company doesnt know how to wear one of these. It should actually be worn like this:

I wonder if the staffer behind him had the guts to tell him how to put it on properly? Maybe it actually works by reverberations on his dome? Or when you are at his level, you dont really need to listen anymore. Just shout your commands. Tear some vocal chords.

yk.