My Technical Thoughts

Anything technically useful that I encounter, especially concerning open-source software.

Tuesday, June 30, 2009

Remove Carriage Returns From Text Files Edited on Windows

Sometimes people change text files - that are supposed to run or get processed on a Unix/Linux system - on Windows text editors such as notepad, this messes up the file as Windows puts a carriage return (read as ^M from within vi) at the end of each line and then you won't be able to execute or process the file correctly, here is the Linux command you can use to remove such invalid characters:

tr -d '\r' "<"httpd.conf ">"httpd_clean.conf (remove the double quotations)

where:

tr -> is the command
-d -> to delete a certain character or pattern of characters
'\r' -> denotes the carriage return (elly heyya el Enter)
httpd.conf is the input file, it has to be preceded by a '<' >httpd_clean.conf -> httpd_clean.conf is the output file, it has to be preceded by a '>'

Saturday, June 6, 2009

Use Your Bluetooth Phone To Access The Internet

This is really cool! I could finally access the internet over a bluetooth personal area network (PAN) on my Ubuntu Hardy, here are the steps:
  1. Install the following packages: bluez-utils, bluetooth, bluez-gnome, bluez-hcidump
  2. you will need to enable the BlueTooth applet in GNOME. Do this by going to "System->Preferences->BlueTooth Preferences". Set the mode of operation on the "Devices" tab to "Other devices can connect". On the "General" tab, set the program to always show the BlueTooth systray applet (personal preference).
  3. Pair your phone and computer
  4. Open a terminal. On the command line, enter the following commands and taking note of the information where asked to.

    Code:
    sudo bash

    hcitool scan #(Make a note of the hardware address of your phone as listed).
    gedit /etc/default/bluetooth #You can use any other text editor of course
    Find the line which has something like:

    Code:
    PAND_ENABLED=0
    and change it to:

    Code:
    PAND_ENABLED=1
    Next, find the line which looks like:

    Code:
    PAND_OPTIONS=""
    and change that to:

    Code:
    PAND_OPTIONS="--listen --role=PANU --devup /etc/bluetooth/pan/dev-up --devdown /etc/bluetooth/pan/dev-down"
    Save the file.

  5. Now, create a directory called "/etc/bluetooth/pan". Use an editor to create a file called "/etc/bluetooth/pan/dev-up" and put the following lines into that file:
    Code:
    #!/bin/bash
    ifup bnep0
    Save that file.
  6. Now, use a text editor to create another file called "/etc/bluetooth/pan/dev-down" and put the following lines into it:

    Code:
    #!/bin/bash
    ifdown bnep0
    Save that file as well.
  7. Add a line to /etc/network/interfaces. Open that file with a text editor (as root) and add the following line to it near the end:

    Code:
    iface bnep0 inet dhcp
  8. Start up the Internet Sharing on your phone and connect from your PC. The Internet Sharing on your phone is going to be different depending on the phone, but on the Linux client, use the following command:

    Code:
    pand --connect  #The address you have got in the "hcitool scan" command
    ifup bnep0
  9. That's it. You should see the bnep0 interface come up and get a DHCP address from your phone. After you have the address, you can freely browse the Internet.

    To disconnect, simply run:

    Code:
    pand -K
    Remember, any time you want to connect or disconnect, you must run the "pand" commands as root. BTW, I'm now using my new HTC Touch 3G to post this :)))). Article Source (with some changes): http://ubuntuforums.org/showthread.php?t=598890

Friday, June 5, 2009

Create Keyboard Shortcut to Kill/Open avant-window-navigator when playing games

I really like compiz and awn (avant window navigator), but awn causes me a problem when playing games; they just keep flickering till I get mad, so everytime I start a game I have to manually close awn and after finishing playing I have to open it again, so I created the following bash script and assigned it to a keyboard shortcut (using Ubuntu Tweak software):

ps -ef | egrep "avant|awn" | awk '{print $2}' | xargs kill -9

You can use the "man command_name" to get the description of each of the above commands. I then assigned another key to open "avant-window-navigator".

This way even if I forget to close it manually, I can just press the keyboard shortcut and it works like a charm!

Sunday, May 17, 2009

Force Empty Trash

Sometimes you might face a problem where you can't delete files in the Trash (due to permission issues), I solved this problem by doing the following:
  1. Go to directory ".local/share/Trash/" by typing "cd .local/share/Trash"
  2. Execute this command: "sudo rm -rf file_name"

Tuesday, May 5, 2009

How to ensure the integrity of your VERY LARGE files on AIX

Something that I've learnt by time is that I must check my files - especially big ones - upon transferring them from one medium to another or through a network or you're really going to face troubles that you'll see everyday in your worst nightmares :(. Anyway, it's very simple and quite fast, there are lots of methods available and here are my favourite two:
  1. "csum -h MD5 file_name" #for small files, it's very fast
  2. If the above doesn't work, use this instead "cksum file_name" #For very large files
Both will produce an output for you that will consist of numbers, characters or both, just do this on the source medium and the destination medium (after file transfer) and if the outputs match, the file is healthy, otherwise you must re-transfer the file and re-calculate the sum, Enjoy!

Saturday, April 18, 2009

Compile and Install VLC 0.9.9a on Ubuntu Hardy

Here is what I did to install VLC 0.9.9a on my Ubuntu Hardy:

sudo apt-get build-dep vlc
sudo apt-get install paranoia*
sudo apt-get install libx264-dev

wget http://www.live555.com/liveMedia/pub...-latest.tar.gz
tar xvfz live555-latest.tar.gz
cd live
sudo ./genMakefiles linux
sudo make
cd ..
sudo cp -r live /usr/lib

wget http://download.videolan.org/pub/vid...0.9.9a.tar.bz2
tar jxvf vlc-0.9.9a.tar.bz2
cd vlc-0.9.9a
sudo ./configure --with-live555-tree=/usr/lib/live --prefix=/usr --disable-zvbi --enable-flac --enable-libass --enable-caca --enable-faad --disable-kate --enable-twolame --enable-realrtsp --enable-cddax --enable-theora --enable-mozilla --with-mozilla-pkg=libxul-plugin --with-x264-tree=/usr/include
sudo make
sudo make install

Enjoy :)

Article Source: http://ubuntuforums.org/showthread.php?t=1115376

Thursday, April 2, 2009

Foxyproxy ROCKS!

I'll explain later :), just know that if you use a lot of proxies in multiple client locations, schools, universities ...etc, then Foxyproxy for Firefox is definitely the solution for you.

Get it here: https://addons.mozilla.org/en-US/firefox/addon/2464