Monday, August 24, 2009

Know your Battery status the command line way

1 comments

Well no big deal:-). The battery information can be easily got by clicking on the battery icon in your Ubuntu's taskbar. The good thing here is you will know from which file the information of the battery is fetched.
To know the current state of the battery:
pradeep@pradeep-laptop:~$ cat /proc/acpi/battery/BAT0/state
present: yes
capacity state: ok
charging state: charging
present rate: 0 mA
remaining capacity: 3599 mAh
present voltage: 12578 mV

To know all the info regarding your laptop battery:
pradeep@pradeep-laptop:~$ cat /proc/acpi/battery/BAT0/info
present: yes
design capacity: 4400 mAh
last full capacity: 3789 mAh
battery technology: rechargeable
design voltage: 10800 mV
design capacity warning: 185 mAh
design capacity low: 129 mAh
capacity granularity 1: 56 mAh
capacity granularity 2: 3604 mAh
model number: VE06047
serial number: 453
battery type: LION
OEM info: STL-LG22


Ahh, 3789mAh/4400mAh = 87%, Not bad after 1.5 years of torture to my lappy;-). Let me know your' s too.

Read More......

Twittering the command line way

0 comments

As you might have noticed my previous post was browsing the command line. Now lets see how to twitter the command line way:-);-)
At first you need to install cURL.(a client for getting files from servers) to post to Twitter through the Terminal which can be installed using the following command:

pradeep@pradeep-laptop:sudo apt-get install curl

With cURL installed, you can post to Twitter from the terminal window by using the following syntax:


pradeep@pradeep-laptop:curl -u yourusername:yourpassword -d status="Your Message Here" http://twitter.com/statuses/update.xml

You will receive a response containing the XML coding for your post which acts as a confirmation that your post was submitted.

So have fun twittering the command line way:-)

Post in your reviews:-)

Read More......

Wednesday, August 19, 2009

The command line way of browsing

0 comments

One of the best things in Linux I like is the command line way of doing things. Well now I can do almost all my work from the terminal and the latest being browsing and chatting. The only thing I cannot do is viewing images and watching videos which soon might be possible:-).
So how do I browse from my terminal??? I thought was it possible? I have realised lately there's help for everything and anything on Linux. After doing a small research I found out this cute command line app called "Elinks"(command line browser)

Ever wondered how fast the browser Elinks is ??? No pop ups, no images, but absoultely cool plain test views,option to see images using eog(Eye Of Gnome) , tabbed browsing, history, bookmarks, history : everything one might need in a modern day browser. It doesn't crash , doesn't require any extra plugins for working. Actually above anything else its the speed of browsing is what that beats me ! Brilliant! Don know what adjective would describe the power of elinks. Check out the google page opened on elinks.
Accessing my Gmail account is fun in elinks. So damn fast!!
"finch" is a command line chat client which is the same as pigdin.:-)

elinks can be installed on your ubuntu as follows:
#pradeep@pradeep-laptop: sudo apt-get install elinks


PS: I agree that GUI way of doing things is friendly,easy and all. But after a few tries the command liners are easy to use , more productive and damn cool!!!

Always try and do things differently:-);-)

Read More......

Tuesday, August 18, 2009

SMS Typing

0 comments

Of late I have been solving a lot of problems. Here s a problem which you guys can solve.

Cell phones have become an essential part of modern life. In addition to making voice calls, cell phones can be used to send text messages, which are known as SMS for short. Unlike computer keyboards, most cell phones have limited number of keys. To accommodate all alphabets, letters are compacted into single key. Therefore, to type certain characters, a key must be repeatedly pressed until that character is shown on the display panel.

In this problem we are interested in finding out the number of times keys on a cell phone must be pressed to type a particular message.

In this problem we will assume that the key pad of our cell phone is arranged as follows.

---------------------

| | abc | def |

---------------------

| ghi | jkl | mno |

---------------------

| pqrs | tuv | wxyz |

---------------------

| |sp | |

---------------------

In the above grid each cell represents one key. Here SP means a space. In order to type the letter ‘a’, we must press that key once, however to type ‘b’ the same key must be repeatedly pressed twice and for ‘c’ three times. In the same manner, one key press for ‘d’, two for ‘e’ and three for ‘f’. This is also applicable for the remaining keys and letters. Note that it takes a single press to type a space.


Input:
The first line of input will be a positive integer T where T denotes the number of test cases. T lines will then follow each containing only spaces and lower case letters. Each line will contain at least 1 and at most 100 characters.


Output:
For every case of input there will be one line of output. It will first contain the case number followed by the number of key presses required to type the message of that case. Look at the sample output for exact formatting.


Sample Input : Sample Output

welcome to ulab : 29

good luck and have fun : 41


Problemsetter: Shamim Hafiz

Special Thanks: Sohel Hafiz

You can download the solution done by me and my friend amruth at here.
The code was compiled and executed on a gcc compiler

Read More......

Monday, August 17, 2009

Bash SpellChecker

0 comments

Reason for this post is that i tend do a lot of typing mistakes while typing at the terminal:-).
Spell checking in bash can be enabled adding the following line below into your bashrc file

shopt -s cdspell

#pradeep@pradeep-laptop:gedit ~/.bashrc

Add the command mentioned above to the end of the file and save.

That’s all :)

If you want to enable this for all the users, then append this to your /etc/bash.bashrc (in Ubuntu) or /etc/bashrc (in Fedora). Of course, you need the root privilege to edit the files in /etc.

Now try these
cd /hoem
cd /hoe

Ain't it cool.

So by the way what is a bashrc file?
Ok in short it is a script which is run by the bash shell when ever a terminal is invoked once you login.
To know more please see /usr/share/doc/bash/INTRO.gz as in "Ubuntu 9.04". Not sure about other versions. It should be the same according to me.


Read More......

Tuesday, August 11, 2009

Microsoft Visio

1 comments

Ok i don usually like writing about microsoft stuff:-). But saw my friend amarnath installing this software, so writing:-)

Microsoft Visio (pronounced VIZ-ee-oh, not VIZH-ee-oh) is a diagramming program for Microsoft Windows that uses vector graphics to create diagrams. It is currently available in two editions: Standard and Professional.

The Standard and Professional editions both share the same interface, but the latter has additional templates for more advanced diagrams and layouts as well as unique functionality that makes it easy for users to connect their diagrams to a number of data sources and display the information graphically.[1][2]

Microsoft acquired Visio Corporation in 2000. Visio 2007 was released on 30 November 2006. Also released alongside version 2002 were Enterprise Network Tools, an add-on product enabling automated network and directory services diagramming, and the Visio Network Center, a Web site where users could locate the latest network documentation content and exact-replica network equipment shapes from 500 leading manufacturers.[3] The former has been discontinued, while the latter's shape-finding features are now integrated into the program itself.[4]

Microsoft has revealed that the next version of Microsoft Visio will feature the ribbon user interface
Source:Wikipedia



Read More......

Saturday, August 8, 2009

Vim plugin you must install

0 comments

Ok why I am writing this post.Two reasons for it:
1) We have a Web Programming Lab this semester
2) I hardly use windows now:-). Using windows has exponentially decreased:-)

Snipmate.vim is probably the best snippets plugin for vim. A snippet is a piece of often-typed text or programming construct that you can insert into your document by using a trigger followed by a tab. It was written by Michael Sanders.

Here is an example usage of snipmate.vim. If you are a C programmer, then one of the most often used forms of a loop is “for (i=0; condition ; i++) {}”. Without snippets you’d have to type this out every time. Even though it takes just another second, these seconds can add to minutes throughout the day and minutes can add to hours over longer periods of time. Why waste your time this way? With snippets you can type just “for tab” and snipmate will insert this whole construct in your source code automatically! If “i” or “n” weren’t the variable you wanted to use, you can now use tab and shift-tab to jump to next/previous item in the loop and rename them!

Michael also created an introduction video for his plugin where he demonstrates how to use it. Check it out:

snipMate.vim Introductory Screencast from Michael Sanders on Vimeo.



How to install snipmate.vim?

To get the latest version:

1. Download snipmate.zip.
2. Extract snipmate.zip to ~/.vim (on Unix/Linux) or ~/etc/vim (wherever vim is installed)
#pradeep@pradeep-laptop: sudo unzip snipmate.zip -d ~/etc/vim (provided snipmate.zip is in your HOME folder else provide the desired path)
3. Run :helptags ~/.vim/doc or ~/etc/vim/doc
4. Restart Vim.

The plugin comes with predefined snippets for more than a dozen languages (C, C++, HTML, Java, JavaScript, Objective C, Perl, PHP, Python, Ruby, Tcl, Shell, HTML, VimScript). Be sure to check out the snippet files in the “snippets” directory under your ~/.vim or ~\vimfiles directory.

If you need to define your own snippets (which you most likely will need), create a new file named “language-foo.snippets” in the “snippets” directory. For example, to define your own snippets for C language, you’d create a file called “c-foo.snippets” and place snippets in it.

To learn about snipmate snippet syntax, type “:help snipmate” and locate the syntax section in the help file.
Have Fun!

Post in your comments if any queries!

Read More......