Alsa Sound Setup Debian

Hear This

ALSA, the Advanced Linux Sound Architecuture produces great notes and faithful reproduction, but first you gotta get it to sing. Most times, ALSA works out of the box, sometimes it doesn't. You have to roll your sleeves up and start digging.

Step Zero: Sound Card
Do you know which sound card/chip is installed on your system? No? Go dig out your motherboard box, or computer manual and identify your sound card/chip. You need this before you can fix your problem. Some systems don't have a plug-in card. The sound card is on-board chip on the motherboard.

Go find it.

Once you have the name/make/model of your sound card/chip, you can start.

Step One: ALSA
Is alsa installed on your system?

cat /proc/asound/version

cat /dev/sndstat

Displays ALSA version. Confirms ALSA installed. If not install it. As root do:

aptitude install alsa-base alsa-utils

Step Two: AlsaMixer
Check sound levels using alsamixer. Fire up alsamixer and check volume levels. The majority of sound problems relate to volume levels too low or mute set. Run alsamixer do:

alsamixer

Use up and down arrow keys to increase/decrease volume levels. Increase volume levels at least 50% or halfway. Ensure Master level is turned up. Ensure PCM is turned up. Also turn up Front level. This applies if your card is multi-channel, 5.1 or similar.

Note
If the volume levels are set high and you still have no sound, check if any channel is marked [MM] It means the channel is muted. Press 'M' on the keyboard to un-mute the sound on that channel. Press 'M' again to toggle the setting.

Make sure 'Master', 'PCM' and 'Front' are all un-muted and volume turned up. Press 'Esc' to exit. You can run a simple sound test using 'speaker-test' to check for sound output.

Step Three: Sound Card/Chip
Is the sound card/chip detected? I have an Intel on-board sound card.

# cat /proc/asound/cards

# cat /proc/asound/cards
 0 [Intel          ]: HDA-Intel - HDA Intel
                      HDA Intel at 0xf9ff8000 irq 22


lspci | grep Audio
00:1b.0 Audio device: Intel Corporation 82801JI (ICH10 Family) HD Audio Controller


lspci -v -s00:1b.0
00:1b.0 Audio device: Intel Corporation 82801JI (ICH10 Family) HD Audio Controller
        Subsystem: ASUSTeK Computer Inc. Device 82fe
        Flags: bus master, fast devsel, latency 0, IRQ 22
        Memory at f9ff8000 (64-bit, non-prefetchable) [size=16K]
        Capabilities:
        Kernel driver in use: HDA Intel

Step Four: Sound Card Modules
Is the right sound card device module installed for your sound card??

cat /proc/asound/modules

The 2.6.x kernel has modules in-built for common sound cards. If the module for your sound card is not installed. Google it, download and install using modprobe. As root do:

modprobe -v module-name.ko

Also see man modprobe.

Step Five: Reconized Cards
Your card recognised by the system? Run aplay -l to list recognized cards: 

aplay -l

**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC1200 Analog [ALC1200 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 1: ALC1200 Digital [ALC1200 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Okay, we can see the card.

Step Six: Default Sound Card

Test the default sound card. Particularly if you have more than one card installed.

aplay -Dplughw:0,0 -c2 /soundfile.wav

If you have a media player use it to play a sound file:

mplayer ~/Music/funky-file.mp3


Further Steps

If you have followed the above and still have no sound, check the ALSA site to ensure your sound card is supported by ALSA.

Check out this ALSA page for details on supported sound cards and click to find your card/model. If its not there, your out of luck. Buy a new card that is supported. Most supported cards are cheap. That will fix your "No Sound" problem.

If you have more than two cards on your system you need to disable or remove one of the cards and that may fix your problem.

Done!

LXDE Main Menu Edit

Change That List

Most Desktop Environments provide a GUI for changing main menu entries. LXDE doesn't provide such a luxury, but I'm not complaining. For a task I might use once or twice in six months I can live with that. I don't need LXDE to suck CPU cycles on redundant processes.  I prefer lean 'n' light.

On with the task. If you want to change or delete Main Menu items as root, 'cd' to /usr/share/applications and do an 'ls'. You will find each Main Menu item as a single entry ending in .desktop. Do a 'cat' on one of the files to see its contents.

# cat lxterminal.desktop
[Desktop Entry]
Encoding=UTF-8
Name=LXTerminal
GenericName=Terminal
Comment=Use the command line
TryExec=lxterminal
Exec=lxterminal
Icon=lxterminal
Type=Application
Categories=GTK;Utility;TerminalEmulator;

Each is a text file containing a description of which commands to execute, type of application, icon and language. (I didn't include language description. Too many entries to list).

To remove a Main Menu entry, delete the file.

# rm lxterminal.desktop

To change the location in the menu system, change 'Categories' to a different type.

Most entries are self-explanatory:

Encoding: The encoding used to display the entry
Name: Name you see in the menu
Comment: Comment you see while mouse hovers on entry
Exec: Command to launch application
Icon: Icon displayed in menu
Type: Application type
Categories: Where its displayed in menu system

LXDE automatically lists entry names alphabetically and updates the menu entries when they change. If LXDE does not update your changes, as 'root' do:

update-menus

 If you need to change icons, they reside in /usr/share/pixmaps. You can dump new icons in the directory or choose others already there.

You can check details with xdg-mime. Take a look at the man page:

man xdg-mime

Done!

Laptop Brightness Control

The Light And The Dark

I posted around a week ago on the brightness adjustment problem I had with my laptop. It seems the acpi controls do not respond to user input via Fn-7 or Fn-8 keys. I googled and discovered some info on the problem and found a temporary workaround.

While surfing the web today, I came across a user with the same problem and simple shell scripts that purport to fix it.

I downloaded the scripts and reading through them I know it won't work without edits as the directory location and hardware on the laptop do not match the script.

Copy the scripts to /etc/acpi/

To increase brightness use Fn+Up arrow

To decrease birghtness use Fn+Dn arrow

I'll post scripts after making necessary changes to directory entries and hardware.

I don't have time right now.

Soon!

MS Word To Text

Text From Words

I don't have OpenOffice or AbiWord installed on my machine, and don't have any plans to install them anytime soon.

Most times I use Emacs or just a plain text editor such as Leafpad. Occasionally I need to open a MS Word document or similar someone sent me.

There are a number of ways to deal with this.

1. Gmail
If you have a gmail account you can open word docs in gmail. Then grab the contents and dump them in a text editor or save as plain text. You can also save in several other formats including html, openoffice, pdf, rtf, text, or word.

Only drawback is privacy. Google gets to see your docs. If you don't mind that, and there is nothing of a confidential nature, its okay.

You can find Gmail at: http://gmail.com

2. Catdoc
Catdoc reads a word doc and displays plain text on standard output. ie a terminal. Catdoc works similar to cat and you can redirect output to save as a file, pipe it to another prog or as input for another tool. Catdoc does not try to preserve word formatting.

You can find Catdoc at: http://directory.fsf.org/project/catdoc/

3. Antiword
Antiword a free Word reader available for Linux, FreeBSD, Mac OSX, and others. Antiword works on all but the most complex Word documents.

You can get Antiword at: http://www.winfield.demon.nl/

4. OpenOffice
If you have OpenOffice installed you can use Writer to open MS Word docs. In the past, I found this to be a trouble free solution. Only problem is you need to install OpenOffice. I rarely use word processors, so I haven't bothered. OpenOffice is a great product if you have the need for a complete Office style package.

You can get it at: http://www.openoffice.org/

5. AbiWord
This works most times, and you don't need to install the full OpenOffice Application. AbiWord has tripped up on me a couple of times in the distant past. I guess it has improved since then. AbiWord is a good lightweight solution if all you need is a Word processor.

You can get it at: http://www.abisource.com/

6. Open In Windows
Ask a friend, neighbor or local librarian, if you can open the file on their machine and save as plain text or similar open format.

You can get it at: Library or Neighbour

7. Wipe Disk. Remove Linux. Install Windows Vista, Word.
Probably the most extreme, but a possibility. (Though a remote one). You'll need to back up all your data, including Linux config files, dot.files, browser bookmarks, email, etc, etc. You'll also need to look at ways to convert Linux Ext3 to NTFS.

I understand NTFS does not tolerate Unix/Linux file systems. Its default behaviour when it detects Ext3, is a low-level-format of the disk. You will also need to buy a copy of Vista. Available cheap on eBay.

Though, I heard Microsoft can't give Vista away and may even pay you to install it. Its their marketing department solution to increasing Vista user install base.

You can get it at: http://www.eBay.co.uk

Well enough for now. You have a few options for dealing with that troublesome Word document your aunt sent you.

Done!

CHM To PDF In Linux

Non to Portable In Easy Steps

If you need to convert CHM files to PDF there's a program for doing the conversion. Actually its a script. You can find it at Google Code.

The script requires chmlib pychm and htmldoc.

I previously posted on converting CHM compiled html format to open html using chmlib. I also posted on converting HTML files to PDF using HtmlDoc. The only newbie is pychm.

Anyhow after downloading the script. Open it up, then as root, run the install script.

Do:

tar xzvf chm2pdf-0.9.1.tar.gz

cd chm2pdf-0.9.1

su 
root-password

python setup.py install

Using chm2pdf

/usr/bin/chm2pdf --book input_file



Other Version

There's an amended version of the same script at:

http://www.karakas-online.de/forum/viewtopic.php?t=10275

Maybe try this version instead.

Thats about it!

HTML To PDF In Linux

You Want Portable Format With That?

If you're running Debian or another flavour of Linux and you need to convert several HTML files to PDF (Portable Document Format), worry no more. The solution is, HtmlDoc.

HtmlDoc is an HTML processor that generates indexed HTML, PS, and PDF files.

HtmlDoc is an open source product available for free download at their website. Along with excellent documentation on installing, running and maintaining the product. You can install it on a server if you so desire.

Using HtmlDoc is easy.

Start HtmlDoc

Click to select files to convert

Select the output type (Indexed HTML, PS, PDF)

Select the output path

And Go!

Couldn't be simpler.

Full documentation available too.

Done!

View CHM Files In Linux

Where Do Ya Wanna Look Today?

To view CHM (compiled HTML) files in Linux, you need a CHM viewer. There are a couple available:

xCHM is available for download at Sourceforge.

There's also a Gnome specific CHM viewer available at AlternativeTo.

Simple lightweight applications for viewing compiled html files.

Go take a look.

Done!

Convert CHM to HTML

Getting Converted

If you have CHM files from your Windows travels and need to convert them to regular HTML format, you can do it in Linux fairly simply.

CHM files are a proprietary format from Microsoft and stands for Compiled HTML. Microsoft uses three letter extension to file names.

Linux has a useful utility for doing the conversion, chmlib.

If you run Debian, search and install with aptitude:

aptitude search libchm
i  libchm-bin  - library for dealing with Microsoft CHM files
p  libchm-dev  - library for dealing with Microsoft CHM files

i A libchm1    - library for dealing with Microsoft CHM files  

Install using aptitude:

aptitude install libchm

If you can't find it on your distro servers, its available for download at this location.

To convert files do:

extract_chmLib  book_name.chm  work_dir

Explanation:

extract_chmLib is name of binary
book_name.chm is chm file to convert
work_dir is directory name for converted files

Done!

Man is Manual

Using The Man

The man page is a great way to get more info or details on a command or function. Some man pages are verrrrrrry long. (Check out man xterm). Scrolling through to find what you need can be time consuming and tedious.

A quicker way to find stuff in a man page is to use forward and backward search.

Open a man page in XTerm and hit the '/' key, then enter a search string:

man wget

/http

Hit '/' key then hit [ enter ].  This will search for the next instance of http. Each instance of http will be highlighted. Hitting 'n' key will move to the next instance of http till you get to the bottom of the man page.

You can backward search using

?mirror

Hitting the 'n' key will continue backward jumping to next instance of http it finds till you get to top of the man page.

You can scroll forward and backwards a page at a time using 'f' and 'b'.

f scroll down a page

b scroll back a page

To exit the man page, hit 'q'.

To get more info on man do:

man man

You'll find some useful stuff in there.

Done!

Adding Users Or Groups

Hanging With The Group

Adding a user to the system is pretty basic stuff. Just run the adduser command as root with the user name.

adduser obama

The user will be added to the system and his home dir created.

To remove a user from the system, run the deluser command as root with the user name.

deluser obama

The user will be removed from the system. To delete his home directory add --remove-home option.

To remove all user files and home dir in one hit, add --remove-all-files option. This will remove all mail files also.

To add a user to a group, run the adduser command with user and group name. Use no options:

adduser obama cdrom

Adds user obama to the group cdrom.

To remove a user from a group run deluser command with no options:

deluser obama cdrom

Removes user obama from the group cdrom.

To add a new group to the system run the addgroup command as root.

addgroup funky

To delete a group from the system run the delgroup command as root.

delgroup funky

There are another set of commands for adding users and groups:

useradd / groupadd

They operate a little different to adduser addgroup.

Check out the man page for more info.

That's about it!

Xresources or Xdefaults

'X' Marks The Spot

Using X Window System clients it's sometimes hard to decide whether to use .Xresources or .Xdefaults to set properties. Some suggest placing colors, fonts, etc in .Xdefaults. Others suggest using .Xresources. Which is right?

The main difference between .Xresources and .Xdefaults is age (and scope). .Xresouces is the modern method of applying resource values to X clients. The trick is to get .Xresources to load automatically at login.

If you use a desktop manager such as Gnome or LXDE, your .Xresources file may not load. The reason? Unless you run startx from the command line, your dot.Xfiles may get bypassed, when logging from GDM or KDM.

Normally its okay, as most people use Gnome Terminal, KDE Konsole or similar. But if you run XTerm you need X to read your .Xresources file. Unless you feel like loading it manually before you start XTerm. To get round the problem, create .xinitrc in your home directory.

First write up your settings and save the file. You can put Emacs settings here if you want.

Here's my .Xresources file:

XTerm*font: -*-lucidatypewriter-medium-*-*-*-12-*-*-*-*-*-*-*
XTerm*background: black
XTerm*foreground: white
XTerm*pointerColor: white
XTerm*pointerColorBackground: black
XTerm*cursorColor: green
XTerm*internalBorder: 2
XTerm*ScrollKey: true
XTerm*SaveLines: 1000
XTerm*multiClickTime: 250
XTerm*VT100.geometry: 80x24
XTerm*title: XTerm
XTerm*ScrollBar: false

Here's my .xmodmap

keycode 66 = Control_L
clear Lock
add Control = Control_L
keycode 117 = Caps_Lock
add Lock = Caps_Lock

When X-Window System starts, the X-Server looks for .xinitrc in the user home directory. If the file exists, it executes the commands. If it doesn't find it, then falls back on simple default settings for X. Commands in .xinitrc are only sourced once at startup.

Edit .xinitrc as a regular user, not root and make it executable. Do this:

chmod +x .xinitrc

Here's a look at my .xinitrc.

xmodmap ~/.xmodmap &
xrdb -load ~/.Xresources &


First line runs xmodmap and checks .xmodmap file in my home directory. This changes the CAPS LOCK key to Ctrl key. I never use caps lock and cannot imagine anyone having a use for it.

Second line runs xrdb and loads .Xresources file in my home dir.

Done!

Computer Use

Your Needs

Thinking about a clean install of the OS on my box and before proceeding, I reflected on what my day-to-day needs were. You know, actual usage as opposed to tons of installed apps and software packages you never use.

If you're going for a minimal install, best to list your requirements.

Here's a list what I use:

Daily Usage

  1. Web browsing -- chrome / firefox
  2. Text editing -- emacs
  3. Email -- chrome / gmail
  4. Terminal -- XTerm / Fortune
  5. Image viewer -- gpicview / gthumb
  6. Movie viewing -- mplayer

Weekly Usage

  7. Content download -- wget
  8. Graphics Editor -- Gimp
  9. Screen capture -- Take Screenshot
10. Pdf viewer -- Evince

Monthly Usage (or less)

11. Music Playback -- Rhythmbox
12. Audio Editor -- Audacity
13. Video Editor -- Open Movie Editor
14. Music Playback -- Rhythmbox
15. Screen ruler -- Screenruler
16. Color Select -- gcolor2
17. Burn CD/DVD -- Brasero / K3B
18. Ripper -- DVD::Rip
19. Word Processor -- OO Write ???

Other

Coding - Emacs
Compiling - gcc
Scripting - Emacs

Can't think of much else. Its pretty much well the lot.

Adobe Flash Plug-In Problem Fix

More Flash Than Before

The workaround for getting your 64-bit browser to run with a 32-bit flash plug-in, is to use nspluginwrapper along with fakeroot, binutils, ia32libs.

For those brave enough to expose their system complete with security vulnerabilities to the vagaries of the Internet, you can find the original 64-bit flash plug-in, which was withdrawn by Adobe. You can also download it at Softpedia.

Caution: Use it at your own risk. (Fools rush in where angels fear to tread).

The Debian forums page explains the process or there's a Debian Flash Wiki with blow-by-blow account. You can also check out the Debian Flash Bug Report.

Essentially you have two options:

1. Use chroot, install and run a 32-bit browser

2. Use a wrapper with 32-bit plug-in and run a 64-bit browser

The second is an easier solution, though it can be buggy and there are some minor issues.

If you decide to go down the chroot road, there's a Debian 32-bit chroot HowTo. As you can see, there's a truck load more work involved than the nspluginwrapper option.

"You pays your money and you takes your choice."

Here's a walk-through for the nspluginwrapper method:

1. Add debian-mulitmedia.org repository to /etc/apt/sources.list

2. Download gpg key for aptitude or apt-get

3. Install the key ring

4. Update aptitude or apt-get

5. Install the 32-bit libs needed for 32-bit plug-in running on a 64-bit system

6. Install flashplayer-mozilla

7. Restart your browser

You must be root. Answer "yes" to the prompts. You can copy each line of text and dump it into an XTerm or other terminal. Save ya having to type it out.

Here's the code:

1. echo "deb http://www.debian-multimedia.org squeeze main non-free" >> /etc/apt/sources.list

2. wget http://www.debian-multimedia.org/pool/main/d/debian-multimedia-keyring/debian-multimedia-keyring_2008.10.16_all.deb

3. dpkg -i debian-multimedia-keyring_2008.10.16_all.deb

4. aptitude update

5. aptitude install ia32-libs ia32-libs-libnss3 ia32-libs-libcurl3 libcurl3 nspluginwrapper

6. aptitude install flashplayer-mozilla

7. Restart Firefox/Iceweasel.

I used this method on my existing 64-bit Firefox/Iceweasel and it works.

As a foot note, I should add I normally run with flashblock to kill flash-ads. Only time I run flash player is when I visit YouTube, and that's rare.

Done!

64-Bit Flash Player Problems

Not So Flash

I posted on the problems with 64-bit Flash Player Plug-in in Chrome and Firefox. I landed at YouTube a few weeks back and got a message informing of the need to upgrade FlashPlayer plug-in. I complied and upgraded, soon to discover that Flash no longer worked in Chrome or Firefox.

I lived without Flash till I got around to digging a little deeper.

I discovered Adobe, released a 64-bit version 10.0.45.2 of their FlashPlayer plug-in, which was an alpha release, back in June this year. The release was promptly withdrawn with statements from Adobe about an imminent release upgrade of the 64-bit plug-in.

I spent best part of this evening trying to figure out why Flash will not work. I downloaded several Flash plug-ins for Firefox and Chrome. Still could not get them working.  I downloaded and installed Opera. Still a no go. Nada.

After much Googling, reading, testing, downloading, installing, uninstalling, I finally discovered the problem. I visited Adobe's website many times during the course of the evening. Each time to download a version of their 64-bit FlashPlayer plug-in. As Chrome, Firefox and Opera wanted. Each visit to YouTube drew a blank. No Flash video.

I read several posts on Adobe's website, and only after much hair pulling I noticed a note suggesting the 64-bit plug-in would not work. More Googling and digging.

Finally I have it. Around June 15 this year, Adobe pulled 64-bit version, release 10.0.45.2 of their FlashPlayer plug-in, due to a sever security vulnerability. The vulnerability was so bad, Adobe closed the Linux 64-bit labs and posted a notice on the door that reads:
"We have temporarily closed the Labs program of Flash Player 10 for 64-bit Linux, as we are making significant architectural changes to the 64-bit Linux Flash Player and additional security enhancements. We are fully committed to bringing native 64-bit Flash Player for the desktop by providing native support for Windows, Macintosh, and Linux 64-bit platforms in an upcoming major release of Flash Player."
That was over two months ago. Still no Flash Video if you run a Linux 64-bit browser. I discovered the security notice on Debian's website. After much digging, I finally found the security notice on Adobe's site which details the security alert. This confirmed the info on posted on Debian's forum.

I have now been without Flash Video for close to a month. Check out the post I wrote at the end of July about Flash problems. At that time, I suggested that running proprietary software was not a good idea, as you're at the mercy of the IP rights holder and their whims.  Closed source software is locked. You cannot see the source code. You cannot make changes or fixes. Its under lock and key. A trade secret. If there is a bug in the software. Tough luck. Nothing you can do about it.

Anyone running a Linux 64-bit browser, effectively has no Flash Video. Adobe doesn't seem to care. It dies not appear to be an important enough issue. They just put a closed sign on the Lab door, and if you don't like it, take a hike. To re-iterate what was in my Java post, recently about proprietary software:

"When the puppet master tugs the string, you dance". 

Roll on HTML 5 with its inbuilt video support. Though it will take many years for widespread adoption, HTML 5 video support will free us from the Adobe flash prison.

You can read a little more on the problem at:

1. CNET Tech News

2. Oreilly Community Blog

3. Linux Journal News

4. Slashdot News 'n' Views

5. Adobe 64-bit Support

6. Adobe Security Bulletin

Fin!

Laptop Dark Screen Problem

Into The Dark

Did a re-install of Debian on my Fuji laptop last night and pulled down XFCE4 for the desktop. I tried LXDE, which I liked but found it a little buggy. As with most Debian installs, apart from bleeding edge stuff, XFCE4 downloaded and installed flawlessly.

Reboot and the machine is up and running. I have not tried XFCE since the early days when it first hit the streets. Back then, I didn't like the feel much, but it has improved immensely. Looks nice and feels nice.

At first looks, everything seems to work fine. Time will tell.

Next day, first problem on reboot was Laptop LCD display is very dark. Try to adjust using Fn F7 to increase brightness. Nothing. Nada.

Google for a solution. It appears acpi is not working properly and the brightness controls are non-existent. I come across a page with instructions to increase the brightness manually. It suggests as root, do:

echo -n 100 > /proc/acpi/video/VGA/LCD/brightness

In theory, this sets the brightness to 100%.

Only problem on my laptop, this location does not exist. I do an ls of /proc/acpi/video to see whats down there. I get:

GFX0

Okay that's the video controller. Again I do an ls at /proc/acpi/video/GFX0/ and get:

DD01 DD02 DD03 DD04 DD05 DOS info POST POST_info ROM

I poke around a little more and find settings under /proc/acpi/video/GFX0/DD02/brightness

brightness:levels: 13 25 38 50 63 75 88 100
current: 13

Guess that explains why the screen is so dark. I try the modified command using the /proc settings:

echo -n 100 > /proc/acpi/video/GFX0/DD02/brightness

Brightness goes off the scale. I need sunglasses to look at the screen. Well thats good news of sorts. I try another setting to turn the brightness down.

echo -n 80 > /proc/acpi/video/VGA/LCD/brightness

But this fails. Guess I have to use the pre-sets. I try:

echo -n 88 > /proc/acpi/video/VGA/LCD/brightness

This works but still too bright. I keep trying and finally settle on 50. Halfway but its bright enough in daylight.

So it seems the LCD brightness controls do not presently work in XFCE4 for laptops.

I'll have to do more digging when I have more time.

Done!

Java Not-Free Software

Wake Up And Smell The Coffee

A few weeks back I wrote a post on Flashplayer 10 and Free Software. At the time I had problems with the Flashplayer 9 plug-in for Firefox. Tonite I read, Oracle is suing Google for breaching its Java licensing terms. How are these two events related.

It seems Google developed a JVM, which does not require users to refer back to Sun or Oracle. Apparently, the Oracle lawyers were observed with wet stains down the front of their shirts, drooling and salivating at prospects of all those federal lawsuits. You could see the dollar signs spinning and the far-away look in their eyes. If your not familiar with the history of Java, here's a quickie.

Java was developed at Sun Microsystems during their heyday, when they believed they ruled the Unix world. Reality has a nasty habit of piercing the delusion balloon. Java was developed by none other than James Gosling. The man who famously contributed code for Emacs, then changed his mind and started a lawsuit against the FSF (Richard Stallman) for using said code in their Emacs software.

Sun developed Java to be platform independent, namely it could run on any machine, irrespective of the hardware or software beneath it. It must be said, Sun contributed a lot of code to the Open Source movement. But no matter how benevolent, Sun were, they would not release Open Source Java, as the suits believed it was their Jewel in the Crown.

The problem for Java was speed, or rather its lack of. When Java first hit the streets it was, how would you say it... slow. Not only was it slow, but it was a resource hog. Given enough time, hardware speeds increased and caught up with the demands of Java and it became a popular prog-lang on which to develop. The great attraction of Java was the promise of "write once, run anywhere".

The big drawback of using Java, was, it's propietary software. Ruled by the benevolent dudes at Sun. All seemed rosy in the garden. Sun built fast powerful machines, on which ran a stable trusted Unix. Solaris Unix. Solaris was dominant in the Unix server market. But Solaris had two problems. Microsoft and Linux. Solaris was fighting a war on two fronts, and it couldn't win either.

Microsoft ruled the desktop with 90% running Windows and with the introduction of NT, it had the server market in its sights. Sun was not going to take desktop share from Microsoft, all it could do was defend its Unix server position.

If Sun didn't have enough problems fighting Microsoft, along came Linux, mostly in the form of Red Hat. Linux was fast, cheap, stable. It was so cheap, it cost almost nothing. Red Hat Linux made money from training and support. Why pay, 100s of thousands of dollars for Solaris Licenses, when you could get Red Hat Linux for peanuts. And the big plus... it was Unix. A flavour of Unix you could trust.

You could run your servers and network on this Linux. It was rock-solid, stable, reliable beyond belief and didn't fall over like the flaky stuff on offer from Microsoft. It was a known fact, NT servers needed a weekly reboot to keep them stable. You would not run a nuclear reactor on NT server software. Ask any NT Sys-Admin about NT reboots.

As Red Hat Linux market share grew, so did the headaches for the head honchos at Sun Microsystems. Year on year Solaris Unix market share fell. As a last ditch attempt to keep the ship from sinking, Sun Open Sourced Solaris, their high-end Unix Server software. It was too little too late. Sun did make some powerful server hardware, but IBM and HP were chasing the top end and many sites were moving to cheap clusters. Almost all Sun had left to offer the world, was Java. Not enough to keep the ship afloat.

Oracle bought Sun Micro at a knock down price and acquired Java as part of the deal. Oracle like Microsoft, has no Open Source aspirations. The only thing Oracle understands is market share, and money. Just like Microsoft. Now they smell money and they let the attack dogs loose. Its a matter of time before others like Google, are in line.

Google invested a lot of time, money and effort in developing its Java code for Android, its mobile phone OS. Now, Google may have to rethink its long term plans for further development.

Undoubtedly there is a place for Proprietary Software, Ultimately, Java's proprietary license does not bode well for developers or end users. Running proprietary software, you give up some freedom. Its a fact. Sometimes that freedom is monetary, sometimes its operational. If you develop industry wide on a proprietary license, you are at the mercy of  the IP rights holder.

"When the puppet master tugs the string, you dance".

Its a lesson that has not been learnt yet.

CSS Terms

This 'n' That

Here are a few CSS technical terms that may help in understanding CSS and hopefully make life easier.

Container Box

A box containing other elements. The elements can be other boxes, images or text. Body tag is a container block. Html tag is a container block. Footer tag is a container block.

Block Level

Elements formatted as a block or box. Text paragraphs are block level elements.

Inline Level

Elements that don't form a new block. The element is contained within a line. Bold text or Italic text are line elements.

Normal Flow

The normal way a document displays if no position or float format is given.

Out Of Normal Flow

A block out-of-normal flow is ignored completely by content.

Static Position

A block in normal flow.

Float Position

A block taken out of normal flow and positioned to left or right of container box. Content flows on side of floated box.

Relative Position

Elements are positioned in normal flow and moved. Elements that follow act as though relative positioned element was still in normal flow.

Absolute Position

Block is moved entirely out of normal flow.

Fixed Position

Elements moved out of normal flow. Elements will not move for page scroll.

Using wget

Get What?

If you have content to pull off a site or an ftp server, and the content runs to more than a few pages, save yourself an afternoon and use wget. Its fast, reliable, and a big time-saver.

Sit 'n' click to pull down page after page is a real pain, watching paint dry is way more fun. That's where wget solves the problem. I pulled down around 90 pages recently,  wget did it in a little over 3 minutes. Can you beat that with the mouse? I don't think so!

If you have never used wget, here's a quick over view.

First check you have wget installed. In an XTerm, do:

which wget

You should get something like:

/usr/bin/wget

It's installed.


If its not, you know the routine.


aptitude install wget

wget has several switches (sometimes also called options), the ones I mostly use are:

wget -r -l2 -k -t5 -p http://www.oddwebsite.com

Translates as:

-r     Turn on recursive retrieves.
-l     Maximum recursion level. Default is 5.
-k     After convert links to allow local viewing.
       Affects visible hyperlinks, or parts linking to
        external content, ie images, style sheets, etc.
-t     Number of retries. Zero for infinite retries.
        Default is 20. Fatal errors are not retried.
        "connection refused'' or "not found'' (404).
-p     Download all files to properly display page.
        Includes images, sounds, stylesheets.

Here's another:

>wget -r -l1 -t1 -nd -N -U mozilla -np -A.mp3 -erobots=off -i mp3_sites.txt

Decoded:

-r     Turn on recursion.
-l1   Go down one level below entry level.
-t1   Number of retries is 1.
-nd   Don't create directory for downloaded files.
-N     Turn on time-stamping.
-U     mozilla. Identify as wget as mozilla to the
        server. Some sites require browser identity.
        If you get that problem, use -U switch.
-np   No parent content. Don't include parent level
       in download.
-A     Get all .mp3 files. Similar to "globbing".
-e     Execute command.
robots=off    
       Ignore robots.txt file.
-i mp3_sites.txt.
        Read URLs from mp3_sites.txt file.
      If '-' used, URLs are read from command line.

wget is such a powerful utility. Mouse and browser are good, but the command line wins again. Check out the man page, for examples and other goodies.

Done!

CSS Float Images

Go Over There

Using CSS to float images is real easy. If you've used it and found the images would not stack, there's a simple solution.

clear: right
or
clear: left

When you float several images its necessary to add clear to the image property or images will not stack, they try to flow as they normal.

To overcome the natural use clear property to make the images behave as you want them to.

Example CSS

.floatLeft { float: left; margin: 5px 5px; clear: left; }

Example HTML

<img class="floatLeft" height="30" src="img.jpg" width="30" />
<img class="floatLeft" height="30" src="img.jpg" width="30" />
<img class="floatLeft" height="30" src="img.jpg" width="30" />
<img class="floatLeft" height="30" src="img.jpg" width="30" />

The code should look something like that.

Done!

The Magic Of Emacs

Ancient Editor

What is Emacs? Its a powerful, extensible, customizable, self-documenting, real-time display, text editor. Emacs is no ordinary text editor. Its an editor on steroids.
Emacs can be used for IRC, reading / writing emails, reading news, prog coding, writing LaTex documents, editing text and much, much more.

Emacs has a long history it first appeared in 1975, starting life as TECO, a very primitive line editor. Richard Stallman added a macro feature to make it more usable. As usage grew around the MIT lab, people contributed their macros, which were incorporated into TECO and slowly the application grew.

The keys and combinations were, disparate and one night a fellow hacker at the same lab, Guy Steele, began work on standardizing the diverse macro commands into a single set. Steele and Stallman worked on it jointly for a time, then Stallman went on to complete the work on his own and Emacs was born.

The name Emacs comes from "E"diting "MAC"ros.  Emacs as we know it did not really come to life till around 1981-3, after Richard Stallman rewrote much of Emacs following a legal dispute about code included in Emacs. The code was originally donated by James Gosling, a few years earlier. Gosling left to start his own business selling an Emacs clone called Gosling Emacs. Gosling  disputed that he gave permission for his code to be used. To resolve the case, Richard Stallman, pulled the code and rewrote those parts himself.

Emacs usage grew on the strength of its easy customization. A programmer could easily change any part he did not like, till it worked the way he wanted.

We are now in the 21st Century and still using this ancient text editor, a throw back to computings dark beginnings. Why would anyone use Emacs? It doesn't even have WYSIWYG display. Its just a plain dumb text editor. It can't do fancy font formats like bold, italic, underline, etc.

The reason Emacs is still so strong after 35 years, lies in its power and simplicity.

Learning Emacs may seem like a daunting task, but once you lay down a foundation of key strokes, as a starting point, you easily build on that to develop your skill and speed. Key combos become second nature and you find yourself using them in other applications and wishing they worked. Emacs usage gets easier with time. Furthermore, once your up to speed, using Emacs, your productivity sky rockets.

Using Emacs, you edit documents in minutes, that take hours with other methods.
  • Emacs has very powerful search and replace functions
  • Emacs has regular expressions.
  • Emacs has color hilighting for coding.
  • Emacs has Multi-screens.
  • Emacs has mouseless control. Yep. Mouseless. No mouse.
Using only the keyboard, (no mouse) is so fast and powerful, you'll kick yourself for not migrating sooner.

Once your used to the key combos and layout, you can type, edit, cut, copy, paste, search, replace, import, export, save, save as, open, close, and much much more with great alacrity. All from the comfort of your keyboard.

Faster still, remap your keys for speed, and keep the most common used within finger reach, on the home-row. This is absolutely brilliant and blindingly fast. Working your fingers from the home row, you'll wish all apps could work the same way.

The Emacs method of typing, searching, editing, moving, undoing, is just so damn fast. You'll look for ways to make Firefox, Chrome, or other appls work like Emacs.

Crazy but true.

It takes a little effort, but the payback is more than tenfold. There is one provisor. You must be able to touch-type. If you can't... learn. It won't take long. I learnt in a couple of months. If you do a lot of computer keyboard work, you need to touch type. Go learn. There are free tutorials on the web. Google them.

Using Emacs you'll have greater control, greater speed, and greater know-how.

I'm no Emacs expert, but if newbies and non-users break into the Emacs way, and learn to use Emacs, they will not regret it.

Its great!

CSS Box Model

Look At That Box!

If you use CSS and your not familiar with "The Box Model", you can end up with some unexpected results and experience frustration trying to figure out why its not working they way you envisaged.

The box model my appear to be intuitive, and it is except for a couple of points. Here's a quick intro and overview.

The Box Model is essentially made up of 4 parts. Starting in the center and working out:

Content -> Padding -> Border -> Margin

Content

Content is... where you put your content. Text, image, title, hyperlink, list, you know the usual kinda stuff.

Padding

Padding is the space or distance between content and the border. Its how far content is moved away from the border.  By default padding is set to zero and there's no distance between content and border.

Border

Border is the outline you can see around your content. It can be visible if its given a width and color. If not, by default its not visible.

Margin

Margin the distance between the outside edge of the border and any other entity.  Margin is transparent.


If you have been working on a layout and the design will not fit, its probably down to the box model. A frequently overlooked fact is that all the width are added together for a total width for your box element.

The same applies to the height of the box.

For example if you have content set to a width of 100px, padding set to 10px, border set to 5px and margin of 10px. The overall width of your box is 150px.

It works like this:

margin + border + padding + content + padding + border + margin = total width

10 + 5 + 10 + 100 + 10 + 5 +10 = 150px total width.

It easy to overlook this when coding your CSS.

Done!

CSS Position

Stay There

CSS has the ability to place an element anywhere in a document or on a page. This which allows for a great deal of flexibility when it comes to page and website design. CSS elements can be placed in locations using the Position property.

The CSS position has several values:

Static. Absolute. Relative. Fixed. Float.

This allows placing an element anywhere in relation to another element or anywhere on the page.

Position: Static

A block in normal flow. Static is the normal value of position, even if none is stated. The element follows normal document flow.

Position: Absolute

A block element is moved entirely out of the normal flow and allows it to be positioned with measurements from top, bottom, right, left.

A box or block element is positioned in relation to its parent container, only if its parent has a default static value or no value set.

If a value is set for the parent div container, the position:absolute is set in relation to the upper most container, HTML.

Position: Fixed

A block element is moved out of the normal document flow and allows it to be positioned with measurements from top, bottom, right, left.

Fixed elements are always positioned in relation to the html element (visible area of the browser) top left hand corner and never in relation to its container box.

Fixed block elements will not move for page scroll.

Position: Float

A box is positioned to left or right of container box and taken out of normal flow. Content flows on side of floated box.

Position: Relative

Relative block elements are positioned in normal flow and moved with the page and text.  The block element is positioned with measurements from top, bottom, right, left in relation to its container or parent div.

Anything following will act as though the relative positioned element was still in normal flow.

CSS Block And Inline Elements

Thinking Inside The Box

Working with CSS, it helps if you think in boxes. Many CSS constructs use the block (also called a box) as a unit of construction. Div's are natural block elements.  Block level elements will span the full width of available space, block elements will break the flow of HTML and start a new line. If I insert a <div> element here on this line, the <div> will start a new line. The flow of the document will break, but it will continue after I close the <div> element. I'll show you. Here I start a <div>

and the <div> creates a box on a new line, breaking the document flow. When I close the <div> 

the document flow jumps outside the block or box and continues after, as though nothing happened.


Block Display Elements

Here is a list of block display elements:

<div>  general purpose box

<h1> .. <h6> headings

<p> paragraph

<ol> <ul> &tl;dl> Lists (ordered, unordered, definition)

<table> tables

<blockquote> quoted text

<pre> preformatted code

<form> form input box


Get Inline

Inline elements don't break the flow of the document, they fit and remain contained in the line, as their name suggests. Here's an example of an Inline Display Element. I can take the following text and highlight a section and change the font to italic. I can also change another section to bold and make the text maroon.

"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

As you can see, it did not break the document flow or the natural flow of text.

Inline Display Elements

Here's a list of inline display elements:

<span> general purpose inline element

<a> anchor creates links or page targets

<strong> bold text

<em> italic text

<img /> image

<br> inline element forces a new line, but text continues on next line.

<input> form input field

<abbr> abbreviation

<acronym> acronym

Chrome Extensions

Slow Slow Quick Slow Slow

I had eight Chrome Extensions installed to aid web usage. After some months my web browser has slowed a lot. I first noticed it a few weeks back, along with a general slowing of my box. I switched desktop environments, which helped, but the browser was still sluggish.

Chrome is one of the faster browsers, if not quite the fastest, and yet here I am waiting for pages to load. Its not that I'm impatient. Its more the machine and software combo is not running at speeds they should.

I checked a few things and deduced the Chrome Extensions were responsible. I was right. Straight away I disabled ALL Chrome Extensions. Voila. Browser speeds are back as they once were.

I browse a few websites and find the browser is invaded with adverts, of all kinds. Flash seems to be the worst. Boxes floating across the screen. Why do people put up with this? I conclude I cannot live without Ad-Block. I enable Ad-Block extension once more.

With Ad-Block back in action, working its magic, the ads are no more browser speed is still fast. No noticeable drop off in response.

Remember. The more Chrome Extensions you have running, the more it will slow down your browser. Disable the Extensions you don't need running 24/7.

Of course you can still activate your Chrome Extensions when you need them and turn them  off for your day to day browsing, and keep your speed.

Done!

Linux Backups

Mirror Mirror

Modern computers are reliable beasts, but even reliable fails from time to time. And when it fails, it fails bad. I have built many computers over the years, in that time, hard disk technology has gone forward in leaps and bounds. Speed, noise, power consumption, density, capacity, price, size, reliability. Some have gone up. Some have gone down.

One thing you can be sure of. Disks fail. When they fail, they take your data with them. Your stuff. You know all your files, your emails, letters, photos, mp3s, videos, text documents, html files, and other personal stuff.

No one can say when a disk will fail. I have had disks two weeks old, give up the ghost. Sure, they're still under warranty and you get a replacement disk. But you don't get a replacement copy of your data files. No way. You just get a replacement blank formatted disk, ready to receive your files.

As an insurance policy, go get an empty disk drive, same size or larger than your present hard drive. Get SATA2 if you can, as there is no point using older technology. You can fit the disk inside your computer case, if you have space. If not, buy an external drive enclosure.

Most Linux distros have some kind of backup software installed. I like Rsync. Its small light and you can run it with cron. If its not installed, install it now. I use debian, so:

# aptitude install rsync

To back up to your new device, do:

# rsync -vaxE --delete --ignore-errors / /Backup/

Run rsync using cron each night. Put the following in a file such as, cron-bakup.txt:

0 5 * * * rsync -vaxE --delete --ignore-errors / /Backup/

Then, do:

crontab -u root cron-bakup.txt

Your personal files are backed up.

That's it!