Setting up the Chromium yum Repository on Fedora 12

I recently discovered, while setting up a Fedora 12 system, that Tom “spot” Callaway maintains a Chromium yum repository for Fedora 12. The easiest way (despite what Google may say) to install these is just to create a new file:

at /etc/yum.repos.d/chromium.repo. Then run yum install chromium, everything should install, then use chromium-browser to actually run Chrome. Note: if you get a “permission denied” error, this is from SELinux – see here for details of a similar problem.

Setting up X.org on Wii Linux (whiite, xf86-video-cube)

I decided to start my Wii Linux install on my new SD card from scratch. I saw that in the couple of months since I last checked, there haven’t been any new distro releases – this was disappointing as I was looking forward to a public beta of Miight.

I also saw that there have been no new releases of XWhiite, and the latest is based on Debian Etch! Etch! Lenny is old enough, but Etch?! Unfortunately, I had to install and configure X myself.

As the Wii uses graphics hardware very similar to the GameCube, which is proprietary, it needs specialised drivers to run X. These come in the form of the xf86-video-cube module.

(Note: Once I set up the Wi-Fi, I did most of this from SSH sessions – only testing needs to be done locally.)

  1. Run apt-get update – without this, apt-get wouldn’t download libc6-dev and a few other packages for me.
  2. Run apt-get install xserver-xorg-core cvs build-essential xterm hal module-init-tools pkg-config xserver-xorg-dev x11proto-randr-dev libxrandr-dev x11proto-video-dev x11proto-fonts-dev x11-xserver-utils xinit.

    Packages to note:

    • xserver-xorg-core – the actual X server
    • cvs – needed to download the cube driver source code
    • build-essential – contains a C compiler, make, etc., which are needed to compile the source code
    • *-dev – libraries which are needed by the driver code
    • pkg-configpkg-config is a tool which helps developers avoid hard-coding library paths in Makefiles, which can break things on different distros.
    • hal – the X server won’t start without this; you’ll get a “couldn’t initialise context” error
    • xinit – provides ’startx’, etc.
    • xterm – when running ’startx’, the X server will immediately close. This is because it hasn’t been told to run anything; xterm will do for now.
    • x11-xserver-utils – provides xrdb. A warning is shown on startup if this isn’t present.
    • (some packages come from http://wiibrew.org/w/index.php?title=User:Wiibrewfan4)

  3. We now need to download the source code for the driver to the Wii’s VI (video interface). Run these commands to get the source:
    cvs -d:pserver:anonymous@gc-linux.cvs.sourceforge.net:/cvsroot/gc-linux login
    cvs -z3 -d:pserver:anonymous@gc-linux.cvs.sourceforge.net:/cvsroot/gc-linux co -P xf86-video-cube
    

    This will download the small source package to a directory xf86-video-cube/.

  4. To compile this code, enter the directory, cd xf86-video-cube, and run ./configure && make.
  5. The driver needs to be installed as root, so run su to become root, if you’re not already. Now, type make install.

    I needed to also run cp src/.libs/cube* /usr/lib/xorg/modules/drivers, or X wouldn’t find it. This may or may not be needed for you, and it’s not in the README.

  6. Don’t exit out your root shell yet! The /etc/X11/xorg.conf file needs to be configured as specified in the xf86-video-cube README.
    The editors that come in-the-box with whiite seem to be vi (yes, plain old vi!) and nano. Use whatever you prefer.

    I did this, and came up with this:

    Section "Device"
       Identifier    "WII/Gc Card"
       Driver        "cube"
    EndSection
    Section "Module"
       Load    "dbe"
       Load    "ddc"
       SubSection  "extmod"
         # Option    "omit xfree86-dga"
         # Option    "omit XFree86-VidModeExtension"
       EndSubSection
       Load        "freetype"
       Load    "dri"
    EndSection
    Section "Screen"
    	Identifier    "whiite"
            Device        "WII/Gc Card"
            DefaultDepth    16
            Subsection "Display"
                      Modes       "640x480"
            EndSubsection
    EndSection
    

    The only difference to the ‘official’ one is that I removed the Load "type1" line, as neither I or X could find the module.

  7. Run a quick sanity-check: type ‘X’ at the local console (not SSH) prompt. Your TV should show a green background at first, and then a patterned one. An ‘X’ cursor should also be showing.

    If this is the case, press Ctrl-Alt-Backspace to kill the server, and you should be returned to the prompt. If the X server doesn’t work, post the X log (the command-line output should say where this is located) along with some background to a forum of your choice.

  8. Your xsession file now needs to be tweaked to run xterm on startup. Open /etc/X11/Xsession in your favourite editor, and move to the bottom of the file.

    Just before the line exit 0, add a line with the text xterm. Then, save and exit.

If everything’s worked fine, when you run startx, an xterm should pop up, ready for you to start typing in your commands.

Enabling X Forwarding

X Forwarding over SSH works quite well. To use it, first make sure that X
forwarding is enabled in the SSH server config file. (SSH docs on this topic.)

Open up the file /etc/ssh/ssh_config. Verify that it has the line, ForwardX11Trusted yes, and that it is not commented. (If it begins with a ‘#’ character. Remove that character if it’s there.)

When connecting over SSH, remember that the X server needs to be started before you connect. I connect, first without the -X option, then run su -c startx &. Once it’s loaded, I exit, and run the client with -X. It usually works fine after that.

Otherwise, read over the README file in the driver source directory, Google about, e-mail me (lucas@lucasjones.co.uk), or post in the comments or on a forum or Q&A site (superuser.com might be helpful) of your choice.

Windows Live Phishing: Terms and Conditions

Sigh. Another MSN “legit” phishing scam making the rounds. The terms that accompany this particular site, and many others, are actually quite, erm, funny:

Terms of Use / Privacy Policy:

By filling out this form, you authorize A COMPANY to spread the word about this 100% real and upcomming [sic] Messenger Community Site. You will receive your share of the credit in helping us spread the word. This is a harmless Community site which is offering users a platform to meet each other for free.

We do not share your private information with any third parties. By using our service/website you hereby fully authorize A COMPANY to send messages of a commercial nature via Instant Messages and E-Mails on behalf of third parties via the information you provide us. This is not a “phishing” site that attempts to “trick” you into revealing personal information. Everything we do with your information is disclosed here. If you are under eighteen (18), you MUST obtain permission from a parent or guardian before using our website/service.

[snip]

ANY LIABILITY, [snip] SHALL BE STRICTLY LIMITED TO THE AMOUNT PAID BY OR ON BEHALF OF THE SUBSCRIBER TO THIS SERVICE.

We may temporarily access your MSN account to do a combination of the following: 1. Send Instant Messages to your friends promoting this site. 2. Introduce new entertaining sites to your friends via Instant Messages.

This is a free service. You will not be asked to pay at any time. You will not be subscribed to anything asking for payment. This service is made possible by many hours of human effort.

[snip]

You understand that this agreement shall prevail if there is any conflict between this agreement and the terms of use you accepted when you signed up with MSN. You also understand that by temporarily accessing your msn account, A COMPANY is NOT agreeing to MSN’s terms of use and therefore not bound by them.

[snip]

If any provision of this agreement is held to be invalid, illegal or unenforceable for any reason, such invalidity, illegality or unenforceability shall not effect any other provisions of this agreement, and this agreement shall be construed as if such invalid, illegal or unenforceable provision had not been contained herein.

All emphasis mine, A COMPANY’s name is replaced.

Firstly:

“By filling out this form, you authorize A COMPANY to spread the word about this 100% real and upcomming [sic] Messenger Community Site. You will receive your share of the credit in helping us spread the word. This is a harmless Community site which is offering users a platform to meet each other for free.”

Funnily enough, most websites that “advertise” themselves as “100% real” and “harmless” are probably not. Especially in their terms and conditions. The spelling mistake, along with the capitalisation and minor grammar errors, say: “I was not written by a professional company that proof-reads their contracts thoroughly.”

I already knew that, though.

What I did though, was sign up to this site with a bogus account – aptly named thisisabogusaccountfortesting. As I expected, when I logged in, I was greeted with – guess what – an advert! An advert for one of the most common browser/mail client pieces of useless junk around – MyWebSearch. (More info.) Nothing else.

This is not a “phishing” site that attempts to “trick” you into revealing personal information.

Right. Same point as above. While they strictly may not be phishing in the sense that they do not pretend to be, say, Microsoft, most users/victims do not read T&C’s. They don’t even know that they’re sending these messages, as they are offline when A COMPANY signs in.

ANY LIABILITY, [snip] SHALL BE STRICTLY LIMITED TO THE AMOUNT PAID BY OR ON BEHALF OF THE SUBSCRIBER TO THIS SERVICE.

You will not be asked to pay at any time. You will not be subscribed to anything asking for payment

Copy-and-paste. Copy-and-paste. Copy-and-paste.

Oh, well. As you can imagine, these sites spread fast, due to the automatic messaging passing the word on. The number of people that get caught by these sites is amazing.

If you see anybody with a compromised account, then send them an e-mail, or an IM later (they won’t get any you send at the time), asking them to change their password. Explain why, too!

Project Euler Problem #1: One-line Python Solution

Project Euler #4: One-line Python Solution

This is not very efficient (takes a couple of minutes on this slooow netbook), but I think it’s quite neat:

This is about as short as I think it is possible to make it.

With help from the brilliant (as always) StackOverflow’ers

Reverse Polish Notation (RPN) Evaluator in JavaScript

My latest little JavaScript project required an expression evaluator. So, why not do it the easy way and use RPN (Reverse Polish Notation)?

Here’s my implementation:

The code is simple enough to just have a look through. As you can see, operators are specified in the respective objects – just make sure that you don’t have a unary operator with the same name as a binary one – it won’t work. (This is why the unary minus is written as a double minus.)

Also remember that in RPN, “10 5 /” isn’t 2, it’s 0.5!

Formatting a USB drive NTFS on Windows

My new 16GB flash drive (only £16.99 from Amazon!) arrived earlier. The first thing I do when I get a flash drive is format it NTFS – I value the free space more than performance for the data partition. (I usually put an ext3 Linux partition on later.)

So, I right-clicked the drive in Windows Explorer, then chose “Format…”. I go to choose NTFS as the filesystem, but, lo and behold, it’s not there.

Thinking this is something odd in the GUI, I open up a command prompt and type “format F: /FS:NTFS /X“. Aha! This tells me that NTFS isnot supported on flash drives optimised for removal.

There are two ways round this:

  1. Type at the prompt, “CONVERT F: /FS:NTFS /X“. This will convert the existing (probably) FAT32 to NTFS. No files should be lost in the process, but you can never be sure with filesystem operations – do a backup first.
  2. Optimise the drive for performance. To do this, right-click the drive in My Computer, and select Properties. Open the Hardware tab, and click the appropriate device. Finally, select Properties.In the dialog that appears, open the Policies tab. Then, choose the radio button marked “Optimise for performance.” OK all the dialogs, and the NTFS option should return to the Format dialog. Note: Restarting the computer is unnecessary; for some reason Windows will ask you anyway.

DataMapper OR/M: Giving MySQL/others authentication credentials

This one stumped me for a while before I guessed. Need to give a username and password to your DBMS in DataMapper? Just use the same format you would use for HTTP authentication:

DataMapper.connect(:default, 'mysql://user:password@localhost/db')

Building Inkscape on Debian: Easy as 1, 2, 11 (ish)!

On my brand new, very cool Jolicloud installation, I needed to use Inkscape for some vector work. However, the version of Inkscape in the repositories is 0.46, which does not feature the toolbar menu. (When all the toolbar items can’t fit on the screen at once, a menu appears at the bottom, showing the remaining.)

This makes it unusable on a netbook.

So, I decided to take the adventurous step of building Inkscape from source. It’ s not actually too difficult if you have experience with building software.

Before you start, make sure that you have the C++ toolchain installed: sudo apt-get install build-essential automake autoconf.

Now, follow these simple eleven-ish* steps to build the latest, greatest Inkscape from their Bazaar repository:

  1. bzr branch lp:inkscape
    This downloads the latest source code from Inkscape’s repository.
  2. cvs -d:pserver:anonymous@bdwgc.cvs.sourceforge.net:/cvsroot/bdwgc login
    (Just press Return when asked for a password.)
  3. cvs -z3 -d:pserver:anonymous@bdwgc.cvs.sourceforge.net:/cvsroot/bdwgc co -P bdwgc
    The previous two commands retrieve the latest code for the Boehm Conservative Garbage Collector.
  4. cd bdwgc
  5. ./configure
  6. make && sudo make install
    These commands build and install the Garbage Collector library into your system library directory.
  7. cd ../inkscape
  8. sudo apt-get install libboost-dev libgtkmm-2.4-dev libxml2-dev libxslt1-dev libsigc++-2.0-dev libgsl0-dev libpopt-dev libpoppler-dev
    Yes, that’s just about all of Inkscape’s dependencies – in total they come to about a 40MB download.
  9. ./autogen.sh
    Autogen generates the configure script…
  10. ./configure
    The configure script generates the Makefiles…
  11. make && sudo make install
    And finally, make runs the Makefiles to run the compiler which runs the linker which generates the executables!

* You’ll notice there are actually thirteen commands being executed.

This will take a while, but when it’s done, you should have a working copy of Inkscape! If you want to update to the latest release, just run bzr update, then re-run from step 9.

If you’re more of a copy-and-paste kind of person, here’s the full script:

bzr branch lp:inkscape
cvs -d:pserver:anonymous@bdwgc.cvs.sourceforge.net:/cvsroot/bdwgc login
cvs -z3 -d:pserver:anonymous@bdwgc.cvs.sourceforge.net:/cvsroot/bdwgc co -P bdwgc
cd bdwgc
./configure
make
sudo make install
cd ../inkscape
sudo apt-get install libboost-dev libgtkmm-2.4-dev libxml2-dev libxslt1-dev libsigc++-2.0-dev libgsl0-dev libpopt-dev libpoppler-dev
./autogen.sh
./configure
make
sudo make install

Quick Tip: Wii Internet Channel Supports USB Keyboards

You read it right! Although not publicised, you can plug in most USB keyboards into your Wii and use it with the Internet Channel!
No more fiddling about with the virtual keyboard and hitting the wrong key!