Relinuxed

Time for that old laptop to receive Ubuntu 11.04!

Er…

Apparently, the graphics card is too old to run the fancy new Unity UI. Ah well, in any case, it’s a good idea to have a working Linux machine.

Then, the same problem as before. And I hate myself for not detailing precisely what I did to speed up the HDD. I need to fix this ASAP because the system has started doing massive checks to update packages and the machine is completely unusable. So here it goes this time (DISCLAIMER: I don’t really know what I’m doing and I don’t care if I destroy the hard drive and its contents):

– See this link for instructions.

– The problem is that I can’t do these things on a boot partition while happily running the full system on the Gnome desktop.

– Reboot in recovery mode (keep SHIFT pressed while booting), drop down to the recovery terminal.

– ‘mount -no remount,ro /‘ to remount the file system in read only mode with. Ooops! can’t do that while running services that have files open for writing.

– ‘fuser -v -m /‘ lists which services have files open (look for a ‘F’ or ‘f’ in the flags) and get ready to kill some of these processes. Note that not all of them will need to be killed, so use some judgement and go one by one. Start with the ‘F’ ones.

– Try to kill them nicely first with ‘stop servicename‘. In my case, I just did ‘stop rsyslog‘ and tried to remount, it worked even though there were other services (recovery-menu and root) with ‘f’ flags. We have a read only filesystem!

– ‘tune2fs -o journal_data_writeback /dev/sda1
– ‘tune2fs -O ^has_journal /dev/sda1
– ‘e2fsck -f /dev/sda1
– ‘reboot

– Upon reboot, I see that the system is now complaining about a missing disk but it then proceeds. Looking at the /etc/fstab file, the missing disk was used as swap during installation.

– In the /etc/fstab file, add the options ‘data=writeback,noatime,nodiratime‘ for your / drive. Reboot.

– Go to the Synaptyc Package Manager to continue updating the system. Mine complained about broken files, and asked me to do ‘sudo dpkg –configure -a‘. That’s all for now!

Well, I dunno what will be different for you.

Web design

I wrote a minimalistic photo gallery for my wife. It’s a quick mix of php and MySQL on the server, css/html page, and some Javascript+jQuery for a still unfinished slideshow function.

The layout spec was:

– left-side navigation column
– picture to the right of the navigation, with a title centered underneath
– work with pictures of varying sizes
– a screen-wide footer
– as little else as possible

I wanted to make it as friendly as possible to screen sizes and form factors, so that even in the smallest or weirdest screen, you would see as much of the picture as possible. Therefore, I stuck the title in the nav bar rather than as a horizontal banner, so that the picture would not have wasted space above it.

As far as I can see, it looks great on everything from large monitors to an iPhone. The photo uses all the height available the device, the left bar will squeeze and word wrap in horizontally narrow screens, the photo will be pleasantly centered in wide screens, and it will adapt nicely to on-the-fly changes in screen size.

Being the old dog that I am, I laid out the page using classic html tables rather than the more modern css layout paradigm (of course, I still used css for styling). When I was done, I looked into doing it the css way; table cells and nested tables are hard to keep track of in html, and the design is so simple, that css should make it much easier. Conclusion?

It can’t be done with css.

Separate elements in css can’t have the kind of flexibility and influence on each other that table cells have. In essence:

– you can’t dock two elements together with css, so if you have two elements side by side, in narrow screens the element on the right will wrap to the "next" line, ending up below the left element.

– to force elements to stay on the same line, you have to take them out of the normal layout flow, which means they can’t influence each other anymore or dynamically resize to adapt to their content and the size of their container.

So tables it is. How disappointing! If you know how to solve this, please give me a shout. (And no, solutions that include any sort of hardcoded position or size are not acceptable)

Posted in Uncategorized

MySQL

In the previous post, I made references to MySQL but didn’t say anything about a quick local setup. So here’s what I did for mine:

– Download MySQL binaries from http://dev.mysql.com/downloads/mysql/. I chose the huge 64-bit Zip archive.
– I unzipped the /bin/, /data/, /docs/ and /share/english/ folders into my destination MySQL folder. Then I deleted all the *.pdb files.
– Start the server via start mysqld. You can later stop it with mysqladmin.exe shutdown -u root.
– By default it has a root user without password, and an anonymous user.
– Run the client with mysql -u root.
– Delete the anonymous user or it will mess up with your ability to connect using other users you create: DELETE FROM mysql.user WHERE user=”; FLUSH PRIVILEGES;
– Create your database and your development user: CREATE DATABASE MyDatabase; GRANT SELECT, CREATE, DELETE, UPDATE, INSERT ON MyDatabase.* to MyUser@’%’ IDENTIFIED BY "MyPassword";
– Now you can connect as your development user with mysql -u MyUser -pMyPassword.
– I recommend downloading MySQL Workbench from http://dev.mysql.com/downloads/workbench/ to perform database maintenance.

Posted in Uncategorized

nginx 1.0

Since I started working on Pyro’s server backend for its social games, I have grown to love the nginx web server. Compact, efficient and fully featured, it’s a great alternative to Apache if you are in full control of your web server and apps.

A few days ago nginx came of age with the release of 1.0, so I did a refresh of my simple web dev setup at home:

– Download nginx 1.0 Windows binary here
– Download thread-safe php Windows binary here
– Unzip them to their own folders
– Copy php.ini-development to php.ini. Edit php.ini and uncomment the lines containing extension=php_mysql.dll and extension_dir = "ext".
– Start php by running php-cgi.exe -b 127.0.0.1:9000. You can later stop it with Ctrl-C, taskkill /IM php-cgi.exe or with your favourite process killing method.
– Make the following edits to conf\nginx.conf:
– If you are running Vista or later with IPv6, change the line listen 80 to listen [::]:80. This makes nginx listen on both IPv4 and IPv6. Even if you are not doing any work related to IPv6, your Windows hosts file will probably contain the IPv6 loopback entry for localhost (::1), and your browsers will try to use that IPv6 address for localhost. Enabling IPv6 in nginx lets you use all three loopbacks (http://127.0.0.1/, http://[::1]/ and http://localhost/) intercheangeably and without problems.
– Uncomment the block lines starting with location ~ \.php$ to enable php scripts.
– Change the fastcgi_param line to eliminate the hardcoded "scripts" folder path. It should be fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;.
– Add index.php to the index line so it looks like index index.html index.htm index.php;
– Remove all the root html; lines and leave a single root d:\dev\mywebdevfolder line at the server scope. I usually put it just below the server_name localhost; line.
– Start nginx by running nginx.exe or, since it can’t be killed with Ctrl-C, start nginx.exe.
– use the command-line signals to control nginx: nginx -s quit to stop it, nginx -s reload to reload the configuration.

That should be it, nginx+php in 5 minutes or less!

Posted in Uncategorized

Ping

Still alive… cleaned up some of the hacks I did with dates a while ago. Now I must test them. 🙂

Posted in Uncategorized

Linuxing like it’s 1993

Well not exactly, Linux distributions these days are much more organized and documented than in the wild west days before 1.0 hit. But I have installed Ubuntu Desktop 10.04 on my old Laptop, a 7-year old thing with 512Mb RAM, some Centrino CPU and a slow-ass ATI 9200.

Windows XP on that laptop had slowed down noticeably over time, especially since I installed an antivirus, but back in the day it was a decent PC. I used to play World of Warcraft on it shortly after it was released. I was hoping that Linux would infuse some new life into the machine, but I was in for quite a surprise!

The laptop’s hard drive is horrendously busy, and it seems to interfere with everything else in the system, so under heavy HDD activity, even the mouse pointer barely functions.

I found some notes on the ext4 about disabling journaling and access time writes, which improved things a lot, but it’s still barely usable as soon as I have more than 2-3 programs open. I don’t know if I will have patience to tweak it, or maybe such a fancy Linux distro is just too heavy for this old machine. I may try the lighter xubuntu and see what happens. Besides the performance issues, I must admit that the system was very nice to use.

Posted in Uncategorized

Replies and Captchas

Hey gang,

I have inserted Google’s reCAPTCHA widget to validate user registration.

The Captcha is a bit annoying right now because pressing Enter after typing it in will default to Login rather than Register, forcing you to manually click on the button. I think I don’t really need two separate buttons anymore, so I may fix that soon.

I’ll probably wipe the user database because by now everyone who ever posted here may have forgotten their password. 🙂

Posted in Uncategorized

Taskbar vs Tray

Dismayed to find out that MSN’s and Skype 4.2’s lack of a proper tray icon in Windows 7 is by design. According to this: "This icon pattern is no longer recommended for Windows 7. Use regular taskbar buttons instead if your program has desktop presence."

I think the taskbar is not the right place for icons that we use very rarely, but what do I know… For now the best approach if you don’t like this feature is to set the programs to run on Vista SP2 compatibility mode; in the long run I guess I’ll just have to get used to it. A pity, I love everything else about Windows 7.

Oh, and I still think there’s a bug with MSN showing two separate taskbar buttons.

Posted in Uncategorized

RSS Fixes

At the insistence of Cesar, I took a look at the date issues in the RSS Feed generator. It should be fixed now. The timezones used are not correct and the time shown in the RSS is different than the time shown in the Blog itself. Ah well.

Posted in Uncategorized