Paul - The Programmer

simple & stupid

Convert file format from dos to unix

Convert file format by sed

$cp you-file-name your-file-name.bak
$sed 's/^M//g' your-file-name.bak > your-file-name

Covert file format by Perl

$perl -i.bak -pe 's/^M//g;'  your-file-name

Covert file format by vim

:setlocal ff=unix


Detect file format is dos or unix

Detect file format with grep.

$ grep '^M'  your-file-name

^M is Ctrl-V + Ctrl-M. If the grep returns any line, the file is in DOS format.

Detect file format with vim.

1) Open the file with vim.

2) Use the vim set command to show the file format.

:set ff?

The command returns fileformat=<dos/unix/mac> to indect current file format.



Create Google Analytics profile for this blog

Just creat google analytics for this blog.  Try to get closer to my vistors.

Let's see.

Configure Logitech C160 webcam in Debian wheezy

1. Build the quickcam kernel module -- the easiest way

The module-assitant is a tool for building Debian kernel module from source. With the help of module-assitant, the needed module can be built without building the whole kernel. It fetches module-source package that have been prepared for the Debian via apt and produeces the *.deb package.

1.1 Install module-assitant

# aptitude install module-assistant

1.2 Download needed kernel headers and tools

# m-a prepare

1.3 Check the sources.list if the contrib and non-free repositories are included.

1.4 Build the quickcam kernel module

# m-a a-i qc-usb-source

1.5 Check if the /dev/video0 node is created

2. Install camera software

# aptitude camorama

3. Plug the webcam into usb and startup the camorama. If everything goes well, you should see the picture captured in the application window.

It works like a charm.  ;-)

solve the KMS incompatible issue of ATI card

From Debian Sequeeze on, the KMS is enabled by default. But the ATI card is not compatible with the KMS.

When  the KMS enabled, the score of glxgears is around 40 FPS on my laptop which has a ATI Radeon X300.

The worst thing is the system becomes unstable, the screen could be frozen at anytime.

Disable the KMS by the way of /etc/modprobe.d/radeon-kms.conf.

Update this file with command:

echo 'options radeon modeset=0' > /etc/modprobe.d/radeon-kms.conf

Then reboot the system.

Now the score of glxgears gets back to around 1700 FPS.