Tuesday, March 31, 2009

xhtml v html

I have been struggling with xhtml and html issues. I could cry. I made the mistake of listening to people against my better judgement. The xhtml handling in the real world on web sites is a mess. A complete mess. I have reverted to strict html 4.01 with much better results for rendering simple web pages on all browsers. Here is a good read:

It's a can of worms I'm sure.

Monday, March 30, 2009

The Debian Way

Debian differs from other distros in more ways than mere stability and "common sense". Some of it is hacked in a way not apparent to those of us who do not live and breath Debian. It's a real Linux problem - a different way to do things in various distros. This can often lead, and frequently does, to messed up machines.

My tale today about this, hoping to help someone else with Debian, was an aborted emacs-snapshot install in Debian Lenny on my mail/web server. The PSU on it overheats as the inaccessible fan which cools it has developed a problem - that is by the by. Anyway a sudden huge workload caused it to power off. No problem, reboot. (It wil be fixed btw...) Nothing. No access. What the hell? Damn. It's a headless server tucked away in the hall. So I dragged it out, attached a monitor and keyboard and with horror saw the boot process stall when locating the root file system. Uh oh! After a while it drops out into an initramfs prompt which grandly informs me is powered by the "ash shell". Never heard of it. Uh oh again.

Long story short. After some googling and reading nightmares of the usual "RTFM" replies from dorks who had zero clue how to fix it, it became apparent my file system was not hosed. No. The latest kernel update I had performed (and not rebooted yet) had rewritten my menu.lst file. And it had used Debian "automagic" to specify where the images were stored. It had ignored all the sda1 references and thought that all images were on hda4. Why? I still dont know the reason it picked hda4 since the automagic *commented out* (its how it knows its an automagic variable apparently....) setting for kopt was hd0. This had been correct when I used to have IDE drives. I recently moved to SATA. (HD to SD of cours ...) How does this clash with No idea. And after 4 hours googling and ripping my hair out with no live web or email I didn't really care. So moral of the story - if oyu use Debian read every damn line in every damn config file because otherwise it might just do somethings which you wont like because you are unaware of them.

Black and white : I made a mistake by not updating kopt in menu.lst. Reality : I had not found a Debian howto for transferring a system and had used a generic linux/grub one. It wasn't enough. IMO the automagic should have informed me that it was single handedly rewriting all the device references in my menu.lst. I dont know how. It just should have.

Still, alls well that ends well. And had it been Windows? Wouldn't have had a clue where to start looking.

Sunday, March 8, 2009

xrandr, nvidia, xmonad, cedge and games

So the situation gets better. Now I am using Twinview where both
displays share a single xscreen, xrand now works. This enable cli like
control of the displays. So lets add a load more meta modes to the
screen seciton of my xorg.conf:

Option "metamodes" "DFP:1280x1024,TV:1024x768; DFP:1280x1024,TV:NULL; DFP:1280x1024,TV:800x600;DFP:1024x768,TV:NULL;DFP:NULL,TV:1024x768;DFP:NULL,TV:800x600;"

And now add the xmond lines to control them:

  • -- multi monitor stuff
  • ,((modMask(myConfig) .|. controlMask, xK_1), spawn ("xrandr -s 0"))
  • ,((modMask(myConfig) .|. controlMask, xK_2), spawn ("xrandr -s 1"))
  • ,((modMask(myConfig) .|. controlMask, xK_3), spawn ("xrandr -s 2"))
  • ,((modMask(myConfig) .|. controlMask, xK_4), spawn ("xrandr -s 3"))
  • ,((modMask(myConfig) .|. controlMask, xK_5), spawn ("xrandr -s 4"))
  • ,((modMask(myConfig) .|. controlMask, xK_6), spawn ("xrandr -s 5"))
And bobs your uncle. Want to play Bioshock with the TV off at 1280x1024? Hit C-Mod-1.

C-Mod-0 to get the default desktops back.

xorg.conf and meta modes

I learnt a new technique for getting my X desktop to play ball with full screen games. It's the meta mode set up. One adds a metamode list in the screen definition and X alters the way it works depending on the meta mode invoked. e.g here the TV turns off when a full screen game launches itself on the main display.

Option "metamodes" "TV: 1024x768 @1024x768, DFP: 1280x1024 +1024+0; TV: NULL, DFP: 1280x1024;

NVidia only. Helps a lot in getting games to position properly when run under cedega and using a WM like XMonad.

C Code Completion In The C Programming Language

Just a bit of google fodder here.

Cedet has as new version, 1.0pre6, which pretty much works immediately with the excellent auto-completion package available from the Emacs Wiki.

Alex Ott talks about it in much more details here.

This is important stuff. The completion was there before but people had varying degrees of success as it was quite hard to get ones head around. Now it seems to work a lot better in default mode. This could make a big impact on Emacs adoption IMO.

Saturday, March 7, 2009

Opening a file as root

I found this stuff very handy:

The procedure is to open any file belonging to root, for example, and then hit C-x C-r to reopen it as root using tramp.

1) Keybinding

  1. (global-set-key (kbd "C-x C-r") 'find-alternative-file-with-sudo)

2) Code

  1. (defun find-alternative-file-with-sudo ()
  2. "Open current buffer as root!"
  3. (interactive)
  4. (when buffer-file-name
  5. (find-alternate-file
  6. (concat "/sudo:root@localhost:"
  7. buffer-file-name))))
  8. (defface find-file-root-header-face
  9. '((t (:foreground "white" :background "red3")))
  10. "*Face use to display header-lines for files opened as root.")
  11. (defun find-file-root-header-warning ()
  12. "*Display a warning in header line of the current buffer.
  13. This function is suitable to add to `find-file-root-hook'."
  14. (let* ((warning "WARNING: EDITING FILE AS ROOT!")
  15. (space (+ 6 (- (window-width) (length warning))))
  16. (bracket (make-string (/ space 2) ?-))
  17. (warning (concat bracket warning bracket)))
  18. (setq header-line-format
  19. (propertize warning 'face 'find-file-root-header-face))))
  20. (defun find-file-hook-root-header-warning ()
  21. (when (and buffer-file-name (string-match "root@localhost" buffer-file-name))
  22. (find-file-root-header-warning)))
  23. (add-hook 'find-file-hook 'find-file-hook-root-header-warning)