Monthly Archives: September 2008

i prefer linux… but have to revert to vista because of a driver… DARN!!!

I mentioned here before that I made a dual-boot out of my rig. What I didn’t mention is here I dumped Vista after a month and I replaced it with Windows XP… and I upgraded Gutsy to Hardy.. and that’s it.

It was perfect!

Hehe… I’ll list what I use in a day-to-day basis so you’ll have an idea why it make sense to use Linux.

All I need are the following:

  • Perl
  • Python
  • C/C++
  • MySQL DB server and client
  • Apache HTTP server
  • subversion
  • an ssh server and client
  • a good terminal/console application
  • a good editor, I use Vim/GVim

As you can see, these tools can be easily found in any Linux distro. It’s in it’s respective repositories…

So why, Why did I leave Linux and changed it to a crappy Vista?… *sigh*

It’s this… I have an Intel(R) PRO/Wireless 3945ABG WiFi and we have a WPA enabled wireless network.

In short, I can’t connect to a WPA network if I’m using Linux. The network manager will try to connect and after a long wait… nothing! A whole lot of nothing!!! It really sucks!!!

I can’t ask our network admin to change the authentication to WEP and I can’t use a wired connection all the time ( no unused port available near my station… ). Crap!

And so… after much thought… I decided to revert back to Vista… just because of a driver! *sigh*

You can find information about this bug on this site.

Now that I’m in Vista, I have to figure out ways on how to install the tools that I mentioned above… Cygwin comes to mind… *sigh*

Advertisements

who needs an IDE? All I need is Vim

I know that IDE’s exist, I’m no hermit. I’ve tried using Eclipse (also Easy) and I was a Kate user also. These editors have nice support for high level languages like Perl and Python… BUT I want my h,j,k,l shortcuts! If these IDEs have Vim key bindings, then maybe I’ll give it a second chance.

Don’t get me wrong, I’m not saying Vim is the “silver bullet” among editors. I’m just saying it’s the best one in my opinion, hehe. Learning it, shortcuts and all, is steep, but once you get the hang of it, I’m pretty sure you’ll understand why I think it’s the best one. Vim is hard to learn, but believe me, you won’t regret learning it.

Anyway, I just want to share my .vimrc (config file of Vim) for my fellow Vim users out there. I got the tips from Vim’s homepage, so they’re the ones who deserve credits.

set nu
set nowrap
set tabstop=4
set shiftwidth=4
set expandtab
set wmw=0
set guioptions=mic
set autoindent
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2
set guifont=Bitstream\ Vera\ Sans\ Mono\ 12
set backupdir=~/.vimbackup,/tmp
syntax enable
colorscheme desert

" move to the righ/left window and maximize
"" nmap <c-h> <c-w>h<c-w><bar>
"" nmap <c-l> <c-w>l<c-w><bar>

nmap <c-h> :tabprev<CR>
nmap <c-l> :tabnext<CR>

" move the current line up or down
nmap <C-Down> :m+<CR>==
nmap <C-Up> :m-2<CR>==
" imap <C-Down> <C-O>:m+<CR><C-O>==
" imap <C-Up> <C-O>:m-2<CR><C-O>==

" move the current line left or right
" nmap <c-left> <<
" nmap <c-right> >>
" imap <c-left> <c-o><<
" imap <c-right> <c-o>>>

" move the selected block up or down
vmap <C-Down> :m'>+<CR>gv=gv
vmap <C-Up> :m'<-2<CR>gv=gv

" move the selected block left or right
vmap <C-Right> >gv
vmap <C-Left> <gv
vmap <Tab> >gv
vmap <S-Tab> <gv

If you want to use it, just copy and save it in a file named .vimrc inside your home directory if you’re using Linux. I forgot the exact location in Windows, hehe.

And here’s a link for a good cheat sheet and tutorial.

take a leak… and you’ll regret it!

For me, taking a piss in public places is a misconduct. Apparently, someone has a stronger opinion…

This is the sign that we saw when we made a stop-over in Kabankalan’s Bus Terminal last January 2, 2008.

It says, “Ang mangihi diri, dimalason“. It’s in hiligaynon so allow me to translate, “Ang umihi dito, mamalasin!” (in tagalog) or “Piss here and you’ll be cursed (with misfortune)!”.

If you can’t hold it, take a leak. Just don’t say I didn’t warn you…

bash: tips and how-tos (1 of n)

Bash, which stands for Bourne-again shell, is a free Unix shell which is used also as a default command line for most Linux distribution. If you’re a Linux/Unix administrator or a Linux enthusiast, I’m pretty sure you’ve met the bash shell before.

These are some tricks in bash shell that I really find useful.

1. Don’t use backticks, use $( command ) instead.

I admit, this is one of the first tricks that I learned also. It’s quite adequate if you’re running just one command:

date_today=`date`

but if you’re planning to nest multiple commands:

current_pid=`cat $HOME/pid/my_pid.\`date +%y%m%d\`.pid`

Yes, you have to escape the backticks. Now, imagine if you have to nest 3 commands… What do you think it will look like?

We can write the two examples in $( command ) form,

date_today=$( date )
current_pid=$( cat $HOME/pid/my_pid.$( date +%y%m%d ).pid )

You can easily nest multiple commands and no “escapes” required. Your script will look tidier too.

2. Same command, different parameter… use {arg1,arg2,…,argN} trick:

If you find yourself running the same command with a different argument most of the time, you can find this trick useful.

user@localhost~$ wget http://file.example.com/file01.log
user@localhost~$ wget http://file.example.com/file06.log
user@localhost~$ wget http://file.example.com/file18.log

You can run this using {arg1,arg2,…,argN}:

user@localhost~$ wget http://file.example.com/file{01,06,18}.log

You can even combine multiple values:

user@localhost~$ wget http://file.example.{com,net,org}/file{01,06,18}.log

Please note that this doesn’t work with some commands, like echo, so test your script first.

3. Same set of commands, different parameter… create a function.

Yes, bash supports functions. If you’re running a set commands and you want to reuse it, this is the way to go.

To declare a function:

function my_function () {
first_parameter=$1
second_parameter=$2 # so on and so forth…

# things to do…
}

Here’s a simple script that I wrote to back up necessary configuration files in my work station.

#!/bin/bash

BACKUP_DIR=$HOME/config.backup

function backup() {
local file # don’t make this variable global

file=$1 # assign first parameter to file

if [ “x$file” != “x” ] # if $file is empty, don’t process
then
mkdir -p $BACKUP_DIR
# create the destination directory
cp $file $BACKUP_DIR
# copy the file
fi
}

backup /etc/apt/sources.list
backup /etc/samba/smb.conf
backup /etc/X11/xorg.conf

That’s it for now. I hope you find these tips useful. Thanks for dropping by.