Bash made better with shopt
1.Enable automatic typo correction for directory names
shopt -s cdspell
Testing
hemanth@ubuntu:/var/log$ cd /tp /tmp hemanth@ubuntu:/tmp$ hemanth@ubuntu:/$ cd /hom /home hemanth@ubuntu:/home$ hemanth@ubuntu:/home$ cd /mt /mnt hemanth@ubuntu:/mnt$
2.Enable ** to expand files recursively (>=bash-4.0)
shopt -s globstar
3.Avoiding history file to be overwritten
shopt -s histappend
4.Enable cd by variable names
shopt -s cdable_vars</cdoe>
Auto completion in Bash for Maven
Step 1 : Check if bash_completion in enabled in your .bashrc.
Step 2 : Add the file attached to /etc/bash_completion.d/m2.
Step 3 : Enjoy auto-completion for Maven.
The Code Lines :
complete -F _m2_complete -o filenames mvn Indicates to apply _m2_complete for command following mvn
compgenGenerate possible completion matches for word according to the options.
Plotting performance graph of a GNU/Linux box
Easy and fun
Things needed :
dstat
GNUPlot
This post, is not elaborating on dstat or GNUplot but rather focusing directly on how to plotting performance graph of a GNU/Linux box.
I have written a small script to plot the performance of the machine considering CPU,Memory and Network into picture.
<
pre style='color:#000000;background:#ffffff;'>#!/bin/bash
Creating Self-Extracting sources files
The idea is pretty simple : Embed all your tgz's below a place holder and count the lines to get each tgz and pipe tail and tar to extract them to required folder.
Steps
Step I Make a tgz file with all the source you have
Assuming we call the folder to be source, so the compressed file must be source.tgz and the source might contain any extractable files, even simple shell scripts.
Lets assume that our source folder has a build.sh script which takes care of installing each and every source.
Step 2 Make an extractor script as below
Setting up a Secure Subversion Server with Apache in Ubuntu
If you have not read the Apache HTTPS, read it before you go through this post.
"Subversion (SVN) is a version control system initiated in 1999 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly-compatible successor to the widely used Concurrent Versions System (CVS)." -Wikipedia
Steps are pretty easy now:
<i><b>Step 1:</b></i>
How to secure apache with HTTPS
Hypertext Transfer Protocol Secure (HTTPS) = HTTP + SSL/TLS
Check list:
* apache sever
* openssl
Steps:
<b>For Ubuntu 10.04/Apache 2.2.14 changes suggested oregonbob:</b><a href="http://docs.google.com/View?id=dd6rgncr_151cxvhkpc5" target="_blank">here</a> Step 1 : <i> Create a self-signed certificate. </i> This include : Generate a key, Signing and avoid password <b> openssl genrsa -des3 -out my.key 4096 openssl req -new -key my.key -out my.csr openssl x509 -req -days 365 -in my.csr -signkey my.key -out my.crt
Sound card not detected in ubuntu 9.10? Fix it!
Normally the Audio device: ATI Technologies Inc RS780 Azalia controller and RS* series break after an upgrade to karmic
This post is attached with a script, which will help to detect and active your sound card.{Assuming file saved as alsaconf}
<b> sudo chmod a+x alsaconf sudo ./alsaconf</b>
This will list you the sound cards in your machine and you can active them by selecting and hitting a enter, logout and login to not the difference. Note to Unmute from sound properties.
Install FireFox 3.6 Namoroka for Karmic
Namoroka
After Firefox3.5 ("Shiretoko") is released, the next version of Firefox will be developed under the project name "Namoroka". The Firefox version number will be "3.6" and the Gecko Platform version number will be "1.9.2". The release will be shipped as a minor update to users, replacing Firefox 3.5 ("Shiretoko").
Namoroka is to be an incremental release, building upon the success of Firefox 3.5.
How to get it
<b>sudo add-apt-repository ppa:ubuntu-mozilla-daily sudo apt-get update sudo apt-get install firefox-3.6 </b> That's it!
Install Linux from HDD without burning from iso
Had a collection of GNU/Linux distros, had no time or money to buy DVD's :P so came up with this plan :
sudo mkdir /distro sudo chmod `whoami`:`whoami` cp MYLINUX.iso /distro/distro.iso #EXTRACT Linux_kernel & Ram_disk TO /distro# sudo nano /boot/grub/menu.lst #ADD NEW ENTRY# title GNU/Linux root (hdX,X) kernel /distro/Linux_kernel initrd /distro/Ram_disk
After reboot in the menu select GNU/Linux
Distro and {Linux_kernel,Ram_disk} Pairs :
zsync | Update to Upgrade ubuntu
From alpha,beta or RC now you can update the *.iso image to upgrade the OS, instead of downloading the entire iso image
Very useful for people with low bandwidth
Feels very much similar to `wget -c`
zsync is the name, upgrade is the game.
Here is how to do that :
<b> sudo aptitude install zsync mv ubuntu-9.10-rc-desktop-i386.iso ubuntu-9.10-desktop-i386.iso zync <url> </b> Select the URL from the <b>file attached</b>
Unable to login after upgrade to karmic [Solved]
This happens when an upgrade is done without removing the non-free graphical drivers, normally Nvidia or ATI cards.
Actually before installing you should have disable those drivers, so its crashed now.
To fix you have three options :
1. To boot from live cd (karmic), backup what data you want and do a fresh install.
2. Follow this, open your terminal after booting from live cd and then :
type this cat /etc/fstab | grep "/ was on"
the o/p will be like : # / was on /dev/sda1 during installation
'pax' a powerful tool to read and write file archives and copy directory hierarchies
To install pax on ubuntu sudo apt-get install pax
the manual is attached with this article.
"pax will read, write, and list the members of an archive file, and will copy directory hierarchies. pax operation is independent of the specific archive format, and supports a wide variety of different archive formats."
Here are few examples from the manual which exhibits the power of pax:
pax -w -f /dev/rst0 .
Copies the contents of the current directory to the device /dev/rst0
pax -v -f filename
sudo add-apt-repository | Karmic kool
The Changelog of Karmic read so :
software-properties (0.75) karmic; urgency=low
* new helper script "add-apt-repository" that can be used to
enable a repository from the commandline. Useful for e.g.
'add-apt-repository ppa:gnome-desktop'
* fix error in auto-upgrade settings when
dpkg-reconfigure unattended-upgrades was used (LP: #387704)
* po/zh_TW.po:
- updated, thanks to Roy Chan (LP: #365040)
* softwareproperties/kde/SoftwarePropertiesKDE.py:
- do not error on cancel (LP: #364288)
Howto Set up your own Google wave sever on Ubuntu?
PyGoWave Server | Google wave server needs the following :
Python 2.6.1
Django 1.0.2
Orbited 0.7.7
RabbitMQ 1.6.0
Python libraries
lxml 2.2
PIL 1.1.6
carrot 0.5.0
Optional:
django-rosetta 0.4.0
JavaScript libraries:
MooTools 1.2
MochaUI 0.9.5
Get the dependencies :
sudo apt-get install python-mysqldb
sudo easy_install carrot
easy_install --find-links http://www.pythonware.com/products/pil/ Imaging
sudo apt-get install mercurial
Get Python : sudo apt-get install python
Get Django :
install-gnome-shell-ubuntu-kamric-jaunty
1) Get curl
sudo apt-get install curl
2) Build deps :
sudo apt-get install libgnomeui-dev librsvg2-dev libreadline5-dev libwnck-dev python2.5-dev libgstreamer-plugins-base0.10-dev libgl1-mesa-dev libffi-dev xulrunner-1.9-dev mesa-common-dev gtk-doc-tools subversion git-core bison flex
3) Exec the script
bash gnome-shell-build-setup.sh
4) Build the source
~/bin/jhbuild build
Replacing :
1) Go to the folder of the GNOME Shell:
cd ~/gnome-shell/source/gnome-shell/src
2) execute the command sequence to start the GNOME Shell:
./gnome-shell
OOIdenti.ca | Update identi.ca status from OO
After OOTwitter i tired a similar one for indeti.ca, the steps are as before you download the file from the attachment.
OOoTwitter | Open office Twitter
Question : How to twitt from open office?
Download and open this :OOTwitter
Now goto :
Tools -> Macros -> Organize macros -> OpenOffice. Org Basic.
Edit the OOoTwitter "username:yourpassword" to yours
Restart OO and then Tools-> Add-ons -> Post to Twitter
Now Twitt from OO :O)
Understanding the code :
'************************************************************
' POST TO TWITTER
'************************************************************
How to use the real-time Earth wallpaper script for Linux
How to use the real-time Earth wallpaper script for Linux
1.Save code part to a file, say change.sh
while [ 1 ]; do
COUNTER=0
while [ $COUNTER -lt 60 ]; do
wget http://www.opentopia.com/images/cams/world_sunlight_map_rectangular.jpg -O world.jpg
temp=$(stat -c%s world.jpg)
if [[ $temp > 1000 ]]
then rm world_sunlight_Wallpaper.jpg
mv world.jpg world_sunlight_Wallpaper.jpg
break
fi
sleep 5
let COUNTER=COUNTER+1
done
sleep 3600
done
2. Create a new folder in your home partition, say wall.
3. Set permissions and run :
$ cd ~/wall
AMD/ATI | Black Edtion 64bit on ubuntu | Fixing Issues
P.S : The below discussion is considering AMD/ATI into frame.
AMD Phenom has many variates the latest belonging to family(16) model(4) stepping(2) with flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc pni monitor cx16 lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skin.
Resolving application dependencies | apt-cache
Normally while updating an application in GNU/Linux, we download the source and compile and install it. Sometimes we find it hard to install when there are many dependencies.
Consider an example of installing Pidgin and IM, the latest version is 2.6.1, if we start compiling from source we come across few dependencies.
In normal procedure we would have to find the dependencies manually and install them with APT or aptitude.
Pidgin 2.6.1 adds XMPP Voice and Video support (but not on Windows)
Long awaited in the list, voice support for pidgin for GNU/Linux is out, most of them were on Skype all these days for Voice and Video, not any more i feel, with this advancement it's nice to hear and talk also.
Howto install from source:
For Ubuntu user, you may just setup from PPA :
To setup the PPA, copy-and-paste these commands into a terminal:
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com \ 67265eb522bdd6b1c69e66ed7fb8bee0a1f196a8
echo deb http://ppa.launchpad.net/pidgin-developers/ppa/ubuntu \ `lsb_release --short --codename` main | \
Install Eclipse Galileo (3.5) on Ubuntu Karmic (9.10)
Eclipse is not mere an IDE, it's smart!
Open source community and non-profit organization.
"Borland, IBM, MERANT, QNX Software Systems, Rational Software, Red Hat, SuSE, TogetherSoft and Webgain formed the initial eclipse.org Board of Stewards in November 2001".
<
p>As the moon eclipses the sun, your mind would be eclipsed by Eclipse such that you fall in <3 with this smart peace of technology, it has a lavish support on different coding languages and many plug-ins to meet your needs.
All in all it a must try and one of the famous IDE, all most all the coder are aware of.
Installing KDE 4.3 RC 3
Karmic users, can upgrade to the latest packages.
Users of 9.04 :
echo 'deb http://ppa.launchpad.net/kubuntu-ppa/backports/ubuntu jaunty main' >> /etc/apt/source.list
To verify the integrity of these packages by installing the archive's GPG key.Download the attached key and do an import.
gpg --import key
Then do a normal update sudo apt-get update
sudo apt-get upgrade
You might be warned during installation check the packages and say yes to install.
Experiments with Dictionary Server Protocol Linux | RFC 2229
There RFC 2229 defines the The Dictionary Server Protocol (DICT) is a TCP transaction based query/response protocol that allows a client to access dictionary definitions from a set of natural language dictionary databases.
The most common play with the DICT , that most people are aware is :
curl -s dict://dict.org/d:word
Exploring this a more , and using few quick cli utilities i tried the below.
But with the most common method as mentioned above the negative aspect is reflected when we have a huge list of words for which you are in need of it's meanings.
Know your weather from terminal
Here is a small trick i tired to find the weather from the terminal.
The simple code below , gives you the update of current weather in Bangalore.
You may change it to your place by changing the feed as per requirement.
Follow these steps :
$ sudo vi ~/.bashrc Add this at the last : alias tmp="curl -s --connect-timeout 30 "http://newsrss.bbc.co.uk/weather/forecast/1193/ObservationsRSS.xml" | grep "Temperature" | sed -e 's/°/ deg /g' | sed -e 's/%/%/g'| sed 's/<[^>]*>//g'" Save and close the file . Now , source ~/.bashrc Then, $ tmp
xclip - command line interface to X selections (clipboard)
xclip reads from standard in, or from one or more files, and makes the data available as an X selection for pasting into X applications. Prints current X selection to standard out.
To install sudo apt-get install xclip
How to work with xclip , say for example you want an output of a command in your X selection , after running commnad | xclip , you can just middle click your mouse to paste the output or else you may use the -o option xclip -o /path/file-name
.
Say for example :
uptime | xclip
New VLC 1.0 howto get it
Follow these steps :
Ubuntu 8.10 Interpid :
sudo sh -c "echo 'deb http://ppa.launchpad.net/c-korn/vlc/ubuntu intrepid main' >> /etc/apt/sources.list"
Ubuntu 9.04 Jaunty jackalope :
sudo sh -c "echo 'deb http://ppa.launchpad.net/c-korn/vlc/ubuntu jaunty main' >> /etc/apt/sources.list"
Then add the verification key GPG
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7613768D
Now install vlc using the command :
sudo apt-get update && sudo apt-get install vlc vlc-plugin-esd mozilla-plugin-vlc
Recent blog posts
- watir-webdriver web inspector
- gem list to gemfile
- Packing ruby2.0 on debian.
- Made it into The Guinness Book!
- to_h in ruby 2.0
- Filter elements by pattern jQuery.
- Better HTML password fields for mobile ?
- Grayscale image when user offline
- nth-child CSS pseudo-class Christmas colors
- EventEmitter in nodejs