10 February, 2007

Dual Boot with Vista

From http://www.cyberciti.biz/tips/howto-fix-dual-boot-windows-vista-linux.html

Step # 1: Boot from Fedora Core Linux 1st CD or DVD

Set BIOS to boot from CD/DVD rom. At boot: prompt type command linux rescue
boot: linux rescue

Just follow on screen instructions, when prompted let installer search Linux installation. If the search operation is successful, your old Linux installation will be available at special directory called /mnt/sysimage.

Step # 2: Prepare system for GRUB reinstallation

Type the following commands at shell prompt:
# chroot /mnt/sysimage
# cd /boot/grub

chroot command allows to run rest of all *COMMAND* with root directory set to NEWROOT called /mnt/sysimage. Without chroot environment you will not able to restore GRUB on Fedora Core 6.

Step # 3: Find out your GRUB bootloader installation location

If you have only one IDE hard disk default should be /dev/hda. You can use any of the following command to determine your device name:
# grep '#boot' grub.confOuput:

#boot=/dev/sda

Above output clearly point out that /dev/sda device where my GRUB bootloader was previously installed.

You can also try out fdisk -l command to list partitions and disk information:
# fdisk -l

Step # 4: Reinstall GRUB

Use grub-install command to install GRUB on your drive /dev/sda
# grub-install /dev/sda

Please note that if above command returned any error return with –recheck option to probe a device map even if it already exists
# grub-install --recheck /dev/sda

Step # 5: Reboot system

Exit from chrooted enviorment and reboot Linux:
# sync;sync;exit;exit
# reboot

04 December, 2006

Linux Hacks

Tike these.
For instance,

Get faster file transfer by using 32-bit transfers on your hard drive
Just add the line:

hdparm -c3 /dev/hdX

to a bootup script.

If you use SuSE or other distros based on SYS V,

/sbin/init.d/boot.local
should work for you.
This enables 32-bit transfer on your hard drive. On some systems it can improve transfer performance by 75%.

To test your performance gain, type:

hdparm -t -T /dev/hdX

CPU Scaling

And more
Thanks to Larry Reeder

When I got my 600m, the CPU speed never went above 600 MHz, as shown by cat /proc/cpuinfo, or Gnome's CPU Frequency Scaling applet. I couldn't set the CPU frequency manually, and it wouldn't go up automatically when I was doing a long build. I was beginning to think that the 600m in "Inspiron 600m" stood for 600 MHz.

I was getting a "No speed steps could be determined" error every time I tried to run /etc/init.d/cpuspeed. After trying many things, I noticed that both scaling_max_freq and scaling_min_freq in /sys/devices/system/cpu/cpu0/cpufreq were set to 600000 (600 MHz).

I did: echo 2100000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq and then /etc/init.d/cpuspeed restart

After that the CPU would throttle up to meet demand, and I could also change the speed manually with the Gnome CPU frequency applet.
If you're trying to set various cpuspeed options, I recommend running the commands in /etc/init.d/cpuspeed manually, instead of using the cpuspeed script, which hides many possible error messages when the script has problems. Once you have the options you need, you can go back to using the cpuspeed script.

03 December, 2006

NVidia and FC6

For some reason Anaconda likes i586 kernels, and installs them by default. This upsets the system, and the NVidia compatibility in particular. I attempted to install a new driver (9629 or 9626) after installing a new kernel (2.6.18-1.2835) . There's a day of my life I want back. 9629 later turned out to have a bug that causes a "segmentation fault" upon any glx-related call. 9626 was reputed as one that should work, but refused to install (i.e. compile the kernel source). This glitch was finally fixed by touching a file called config.h (sought by the NVidia code in the kernel source tree). Namely : /usr/src/kernels/$(uname -r)-i686/include/linux/ .

Suspend to RAM

Apparently this feauture tends to break once new NVidia drivers (for 3-D support, on FC6 in my case) are installed. Here's the workaround.
(Courtesy of Firewing1)
1) Make backups of files we're going to edit and install pm-utils:
Code:

su -
yum install pm-utils
cp /etc/pm/functions-nvidia /etc/pm/functions-nvidia.backup
cp /boot/grub/grub.conf /etc/grub.conf.backup

Now, edit the /etc/pm/functions-nvidia and commend out this line:
Code:

/usr/sbin/vbetool post

in the resume_video() so that the line ends up looking like this:
Code:

### /usr/sbin/vbetool post

NOTE: I don't even own a ATi card so I can't test, but if you're seeing similar black screens on a suspend resume, then try editing all the files in /etc/pm and commenting out that line.

2) Next, we have to remove the built-in AGP support and use Nvidia's AGP driver. So, let's edit the /boot/grub/grub.conf, and add agp=off to the kernel line.
See a line like this:
Code:

kernel /vmlinuz-2.6.16-1.2096_FC5 ro root=LABEL=/ quiet

agp=off should be added to the end to look like:
Code:

kernel /vmlinuz-2.6.16-1.2096_FC5 ro root=LABEL=/ quiet agp=off

Your line may look a little different or the kernel version in the /vmlinuz-... path may not be the same. Please don't change that part, like last time this is just to show where to add the text.
3) Reboot, and you're good to go. Hitting the "suspend" button will put the computer into power-saving mode, and all your previous windows and applications will return to their previous state on resume. I tested with gnome-power-manager:
Code:
yum install gnome-power-manager --enablerepo=development
yum update gnome-power-manager --enablerepo=development

That will install / update it to the version I used successfully.

07 October, 2006

OO Browser in XEmacs

Use OOBR(OO-Browser)

OORB shows class structures etc., when you make a program with the language which has classes like C++.

After you execute M-x oobr, you should answer the following questions. The directory under which source (header) files are, the directory under which library header files are, and the path of files such as OOBR, OOBR-FTR. The emacs window is divided after OOBR file is made. Frankly speaking, I am not familiar with OOBR yet. But I think you can use it with the following commands.

  • v : Show the definition of class.
  • e : Edit class.
  • m : Search class with the regular expression.
  • c : Show the list of child classes.
  • p : Show the list of parent classes.
  • t : Show the list of top classes.

narrowing

  1. Select the function
  2. Do narrowing.(C-x n n)
  3. Return to the top.(C-x C-x)

Then, you can see only this function. By typing C-x n w, you reset the state.

using emacs tags

etags source.cc
  • M-. [symbol-name] : Jump to the definition of the symbol.
  • C-x 4 . [symbol-name] : Show the definition of the symbol on another window.
  • M-, : Show the next matching.
  • M-? [symbol-name] : Show the declaration of the symbol on the mini-buffer.

04 October, 2006

Secondary Mark in Emacs

(global-set-key [(control shift down-mouse-1)] 'mouse-drag-secondary)

01 October, 2006

30 September, 2006

Add extra types to emacs c++ mode (e.g. Root)

(setq c++-font-lock-extra-types
'(
"TFile"
"TProfile" "TH1D" "TH1F"
) )

02 August, 2006

seek and replace

sed -i 's/prima/dopo/g' filewithsomethingtobereplaced

# delete ALL blank lines from a file (same as "grep '.' ")
sed '/^$/d' # method 1
sed '/./!d' # method 2
sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P'

# remove all non-consecutive duplicate lines
awk '!x[$0]++' new > newfile

more here

13 July, 2006

Better Goto-line and Other-Window shortcuts

  • (global-set-key "\M-l" 'goto-line)
  • (global-set-key [(control tab)] 'other-window)

25 May, 2006

Slow Font Change in Emacs

As the title implies my emacs would always take its sweet time changing the font from courier 12 (default) to adobe-courier--...20 *** etc. Apparently, it's much quicker if you keep that option out of .emacs and create an alias with a -font option. E.g.
  • alias emacs='emacs -font -adobe-courier-bold-r-*-*-20-*-*-*-*-*-*-*'
Graças a Deus!

05 May, 2006

Fixme Comments in emacs

  • C++

(font-lock-add-keywords

'c++-mode
'(("\\<\\(FIXME\\)" 1 font-lock-warning-face t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)

  • Perl
(font-lock-add-keywords
'perl-mode
'(("\\<\\(FIXME\\)" 1 font-lock-warning-face t)))
(modify-face (quote font-lock-warning-face) "Red" "yellow" nil t nil t nil nil)

  • Also the more decorations - the merrier
(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)
(setq font-lock-maximum-size nil)
(setq font-lock-support-mode 'jit-lock-mode)
(setq jit-lock-stealth-time 0)

Skip a word with Ctrl right/left arrow

Brillant!! Finally found out how to make this work in xterm.
Put the following in your .inputrc

## rxvt
"\eOd": backward-word
"\eOc": forward-word

## xterm
"\e[1;5D": backward-word
"\e[1;5C": forward-word

"Less is more" and other useful exports and aliases

alias any='find . -iname *$1*'
alias grep='grep --color'
alias purge='rm *~ ; rm \#*'
alias nemacs='emacs -nw'
alias pico='nano'
alias pss='ps -ef |grep'
alias more='less'
alias bc='bc -ql'
alias lprodd='lpr -o page-set=odd'
alias lpreven='lpr -o page-set=even'

export PS1=" \u \w $ "
export today=$(date +%d%b%y)

22 April, 2006

Mplayer and framedropping

mplayer -framedrop helps when the image falls behind the sound.
I also had to change -vo x11 to -vo xv, in so that the animation would become smoother.

12 April, 2006

Font Server

After an improper restart (x-server hung up) the X-server wouldn't start, saying something about FontPath being specified as user:/ 7100 (which it is, in xorg.conf), and that it can't find font 'fixed'. Turns out it was caused by the xfs server. It hadn't started despite a couple of reboots. Doing
    • /etc/init.d/xfs start
seems to have fixed the problem. Brilliant!

08 April, 2006

Fix the sound problem with the firefox flash plugin

This is something that keeps recurring every other linux upgrade or reinstallation. The solution is to simply change the permissions on the plugins directory:
  • chmod a+rwx /usr/lib/firefox-xxx/plugins