If nvidia-settings cannot save to xorg.conf, do this

If you’re using ubuntu and having trouble with nvidia-settings saving to the /etc/X11/xorg.conf file, you may find the following tip helpful in relieving that annoyance.
Looking for something interesting when I login to one of my servers, I decided to whip up the following script I appended to my ~/.bashrc file.

close nvidia-settings

in terminal:

sudo mv /etc/X11/xorg.conf /etc/X11/xorg.conf.backup
sudo gedit /etc/X11/xorg.conf

paste the following:

Section "Device"
    Identifier     "Configured Video Device"
    Driver         "nvidia"
EndSection

save and close.

back to terminal:

sudo nvidia-settings

and save the file.

Random cow(ish) animals preaching quotes on Ubuntu 9.10

Looking for something interesting when I login to one of my servers, I decided to whip up the following script I appended to my ~/.bashrc file.

# fortune and cowsay are needed for the snippet to work, I had to install these first
sudo apt-get install fortune cowsay
COWDIR=/usr/share/cowsay/cows/; COWNUM=$(($RANDOM%$(ls $COWDIR | wc -l))); COWFILE=$(ls $COWDIR | sed -n ''$COWNUM'p'); fortune | cowsay -f $COWFILE

UPDATE:

Suggested by MrBougo, a shorter but perhaps more process intensive method:

fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf | head -n1)
random cowsay fortune

random cowsay fortune

Breaking down the script, the first 3 parts create variables and the last command executes the cowsay and quote.

# defines the directory of the cow files
COWDIR=/usr/share/cowsay/cows/;
 
# Get a random number limited to the number of files in the directory, making clever use of % (mod) and adding 1 to make sure it doesn't return 0
COWNUM=$(($RANDOM%$(ls $COWDIR | wc -l))+1);
 
# list the contents of the cow dir again, pipe to sed and use the number as a random line to get the name of a file
COWFILE=$(ls $COWDIR | sed -n ''$COWNUM'p');
 
# use fortune to get a quote, pipe to cowsay and use the file as defined above
fortune | cowsay -f $COWFILE;