Archive for July, 2011



According to Ubuntu developers, the Ubuntu 12.04 (Long Term Support) has a new release schedule. There will be two Alpha versions, two Beta versions, then there will be a release of the Release Candidate version and finally the complete version will be released. It’s code name is “Precise Pangolin”. The schedule of the release of Ubuntu 12.04 with exact date is as follows.

Alpha 1 release date: December 1st 2011
Alpha 2 release date: February 2nd 2012
Beta 1 release date: March 1st 2012
Beta 2 release date: March 22nd 2012
Release Candidate release date: April 19th 2012
Ubuntu 12.04 Final release date: April 26th 2012

The Ubuntu 12.04 being a LTS release will be expected by many to be a strong OS with remarkable performance and support for features.

Pages : Follow ankurtwi on Twitter      


Khan Academy, a non-profit organization that provides free online  education to anyone, anywhere in the word. Khan academy was started by Salman Khan (No Bollywood Connections), who quits his job to start online teaching. “Its our mission to accelerate  learning for students of all ages.” – thats the slogan of Khan Academy. Khan teaches on an electronic blackboard with his voice in the background explaining all the concepts. He never appears in the videos. Initially he started teaching maths, now his lectures covers Physics, Chemistry, Finance, History, Computer Science and much more. Khan Academy also provides online exercises, to practice what a student has learned. You can login using Google or Facebook , and the website will track your progress. Its really a revolution in the field of education. In, 2010 Google announced that they will be giving Khan Academy $2 million to support creation of more courses and also to enable Khan Academy to translate their courses into most widely spoken languages.

Additional Reading: How Khan Academy Is Changing the Rules of Education (wired.com)

Pages : Follow ankurtwi on Twitter      


Sharing data is a very frequent activity in the computer world. There are many great ways and utilities to share data with other people on  network. Python provides a very quick and simple way to share data with people on the network. To share the data within a directory, go to that directory  (through cd command) and execute command python -­m SimpleHTTPServer <portnumber> .Please note that the above command is very case sensitive . Now the entire content under this directory could be accessed on the network by typing http://<ip address of your machine>:<portnumber>  in a web browser. Once your done with the sharing, cancel the data serving by pressing Ctrl + C key combination\. Python comes pre installed in many of the Linux distributions these days. So Linux users just need to run the command simply. As python is cross platform this will work on other platforms too after the installation.

Example : I want to share my music directory . So I will move to my music directory through cd command and type there python -m SimpleHTTPServer 7000 where 7000 is the port number. Then I will tell the ip of my machine to the person with whom I want to share my data. In the browser he types http://<My Ip Address>:<port number>. Screenshots of the same is shown below :

Turn On The Sharing

 

Shared Directory

 

Pages : Follow ankurtwi on Twitter      


In this previous part of this article we learned about  types of shells . In most of the Linux distributions , bash shell is the default shell. So we are going to discuss the working of bash shell in this article . Fasten your seat belts and get ready for the bash ride :D

Normally we think that when we type a command, shell looks for the command in all the directories defined in the PATH environment variable. But in real it goes through the following sequence to reach the above step.

  1. Redirection
  2. Aliases
  3. Expansion
  4. Shell Function
  5. Shell Builtin
  6. Hash table
  7. PATH variable

Now lets first discuss them one by one:

1. Redirection: Consider the example given in the following snapshot:     

Redirection

Here files file1, file2, file3 exists in the current directory as seen from the output of ls command but when we redirect the output to out.txt file, the out.txt file should contain the output of ls command i.e. file1 file2 file3 but in real it also includes out.txt. This happens because before ls is executed redirection is done and file out.txt is created in current directory (we can’t redirect output to a file that doesn’t exit).

2. Aliases: After redirection shell moves to aliases.

Aliases

Here I have defined alias ls=cat , now when I type ls out.txt , ls is replaced with cat and contents of out.txt file is displayes. To make the shell ignore alias use , precede the command name with backslash (“\”).

3. Expansion: According to bash manpage there are seven kind of expansions : brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, word splitting, and pathname expansion. Discussing all of them is beyond the scope of this article, refer to bash manpage (man bash) for more information. If the command you typed contain any variable name, wildcards (*,? etc) shell expands them. As an example refer to the screenshot below :

Expansion

Here $HOME becomes /home/sumit (my home directory) after expansion and file* is expanded to file1, file2, and file3.

4. Shell Function: Like many programming languages bash allows you to define functions. A function in bash may contain multiple commands. You can execute a function just by typing its name. Example : Look  in the figure below, here I have defined an alias by name “ls” and a function by the same name. Since alias gets priority over function, when I first type ls and press enter /bin/ls is executed. Next I have used backspace to ignore alias. After deleting alias using unalias command, since there is no alias left ls corresponds to function ls. 

Shell Function

5. Shell Builtin : Some commands are a part of bash code itself, they are called Shell builtin commands. They are given priority over hash table and directories in PATH variable. Example : echo is a shell builtin command, you can use type command to determine how a given keyboard will be interpreted. 

Shell Builtin

Here its clear that echo is shell builtin command, echo also exist in /bin/ folder but if you type echo and hit enter , it will be ignored since builtin command are  of more  priority. Notice how the output of “type ls” changes after defining the alias by the same name. Once we delete alias and function ls, bash searched hash table, since ls is not in hash table is look in PATH and its found in /bin/ls. 

6. Hash table: The concept of hash table is similar to cashing in Linux, shell store the full path of all the executed commands to speed things up. Now in the snapshot below I have started a new shell, after that I execute ls command (since there is no alias or function by the same name, it executes /bin/ls because /bin is in PATH). Then after executing echo and firefox, I have used hash command to look at hash table. The first column “hits” display cache hits and “command” column displays full path of the command. Because  echo is internal command its not displayed in hash table. After I execute ls one more time its hit column changes from 1 to 2.

Hash Table

7. PATH variable: Last of all shell searches for a given command in directories listed in PATH environment variable. You can look at the contents of PATH by typing

$echo $PATH

To add any directory to PATH variable use

$export PATH=$PATH:/path/to/dir

where /path/to/dir is the absolute path to the directory you want to add. For more information you can read bash manage ($man bash).     Also to make the changed PATH settings permanent add the line export PATH=$PATH:/path/to/dir to .bashrc file in your home directory.

$echo “PATH=$PATH:/path/to/dir” >> /home/your_user_name/.bashrc

Note: Make sure you use >> instead of >, otherwise .bashrc file will get overwritten instead of appending.

About Author : This post is written by Sumit Rai. He is second in command of this blog. Sumit loves to play with grub and spends most of his time in manipulating the hardware through shell.  He is trying his hands on assembly languages also. You can contact him at sumitrai96@gmail.com .

If you want to distribute your knowledge of open-source or Linux in any form like we are doing , feel free to contact us . We can do this through this ad-free blog. We think this is the only way we can repay a little to the work of GOD RICHARD STALLMAN and LINUS TORVALDS .

Pages : Follow ankurtwi on Twitter      


This is the next  part i.e part-2  of my article which got published in the International Magazine “Linux For You” also popularly know as LFY. The article was published  under the name of “Let’s Play With Emacs  CLI”  in the August 2010 edition. All the work done is under the creative common license as specified in the widgets also :) If you are new to Emacs and want to learn it ,You must visit the Part-1 first.

Modes in Emacs

The vi/vim editor has two modes: command mode and insertion mode, which you have to switch between based on whether you are inputting text or commands to vi. However, in Emacs, this is not the case; you can run commands by typing a key sequence that’s bound to some function, as we saw above—and while not doing that, you can modify the text in the active buffer.

Emacs’ modes are different; they are editing modes, which extend Emacs’ capabilities, or change the way some features work, when they are invoked. There are several modes available already in Emacs, for editing each of a certain type or class of data, such as:

  • Regular (text) documents
  • Source code in a particular computer programming language (C, FORTRAN, Lisp, etc.)
  • Text formatted in a certain way (outlines, e-mail messages, Usenet articles, character-based illustrations, etc.)
  • Text with mark-up (like Hyper-Text Markup Language, HTML, for example).
  • There’s even a mode for editing non-text (binary) data!

Modes are classified as major or minor. A major mode dictates the main editing behaviour, and is applied only to the active buffer in the current editing session. There can only be one major mode active at a time, though you can switch between different major modes. Minor modes offer some capabilities that are not associated with any particular major mode. Multiple minor modes can be active at a time.We’ll get to some of the available major and minor modes soon, but before that:

How do you find out the currently active mode? Well, remember the Emacs mode-line bar we mentioned earlier, which is just below the buffer? This bar displays (among other information) your currently active modes, in parentheses, toward the right side of the mode line. Below is the screenshot of the same

Mode-Line Displaying Fundamental Major Mode

The major mode that’s active by default (as shown in the above screenshot) is Fundamental mode. The simplest of all Emacs modes, it has the fewest special key bindings and settings. Here, the Tab key is not bound to a function, and works as you’d expect it to (inserts a Tab into the buffer content). (To see some of the functions the Tab key invokes in other modes, search the Key-Index page for “TAB: Completion Commands” and view the next few entries.)

As an example of invoking a minor mode: suppose you want to overwrite text that’s already entered in the buffer—then you want to go into the overwrite minor mode). The function to invoke this is “overwrite-mode”; to activate this minor mode, either press the bound key, “Ins” (Insert), or type Alt+x overwrite-mode. The mode-line bar changes to show the new minor mode, as shown in the screenshot below:

Overwrite Minor Mode As Shown On Mode-Line

Note: Not all minor modes display an indicator on the mode-line; some minor modes are self-evident, such as the Tool Bar mode, which displays the graphical tool bar at the top of the Emacs frame. You can get a description of the mode by typing Ctrl-h m. You will get something like: To get rid of the help window, use Ctrl-x 1.

Important major modes

  1. Fundamental mode (function name: fundamental-mode): Emacs’s default mode with minimal settings and bindings, which we’ve already mentioned.
  2. Text mode (function name: text-mode): a basic mode for text editing.
  3. C mode (function name: c-mode): for editing C programs, a favourite of C programmers.
  4. Wordstar mode (function name: wordstar-mode): this special mode provides you the key-bindings of the old but popular WordStar editor.
  5. Paragraph-Indent Text (function name: paragraph-indent-text-mode): This mode is a special variation of the text mode, where the paragraph-movement commands work for paragraphs whose first lines are indented, and not just for paragraphs separated by blank lines.

Besides these, there are also TeX mode, for editing TeX docs, and lisp-interaction mode, for editing and compiling Lisp code. You can activate any major mode by typing Alt+x followed by the mode’s function name.

Fun with minor modes

As mentioned earlier, minor modes are not restricted to a particular major mode, but can be applied to any major mode. Let’s explore minor modes, with some scenarios to make it interesting.

Scenario 1: If you’re a Java programmer, you have to be familiar with the line System.out.println “text” that’s used to print text to standard output. Tired of typing the same line over and over again?

The solution is a minor mode named Abbrev (function name: abbrev-mode). After you invoke this mode, to assign the abbreviation “sop” for the string “System.out.println”, go to the buffer and type “sop”. Next, type Alt+x inverse-add-global-abbrev. Emacs will ask you to define the expansion for “sop” (screenshot below). Type “System.out.println” and hit Enter. The next time you enter sop in the buffer, it will automatically change it to System.out.println. Finally, it will ask you whether or not to save the defined abbreviation for future sessions.To do away with all the defined abbreviations, use the command Alt+x kill-all-abbrevs.

Defining The Expansion For "sop"

Scenario 2: You want spell-check in the editor

Ispell, an interactive UNIX spelling checker, is built into Emacs, and is a powerful and convenient way to check buffers for misspelled words. To spell-check a word at the cursor, use the ispell-word function, or its key binding, M-$). To spell-check a region, use the ispell-region function. To spell-check a whole buffer, use the ispell-buffer function.

ispell-buffer

Flyspell-mode

Note: ispell gives you a word-by-word spell check . To highlight all the spelling mistakes in the buffer at one time, use the flyspell-mode function.

Scenario 3: You want to automate repetitive invocation of an Emacs command. Suppose you have selected a region that you want to move through 10 spaces. To move it a single space, I’d use Ctrl-x Ctrl-i—but I need to do that 10 times. Hard on the hands and patience!

Emacs provides a way to repeat a command n number of times; in this scenario, I use Ctrl-u 10 Ctrl-x Ctrl-i. This results in the move-region binding being invoked 10 times, doing my job. Ctrl-u is a “universal” binding, and can be used with other key combination to repeated it for a given number of times.

Scenario 4: You want to find a string in the buffer.

Use the various search functions/bindings: isearch-forward will incrementally search the buffer forwards from the cursor. isearch-backward will search backward from the cursor. Ctrl-s or Ctrl-r will show all the matching words in the buffer (performs a non-incremental search)

Well that’s it for my basic introduction to Emacs. I hope you liked it, and found it worth giving Emacs a try. Suggestions and questions are always welcome; feel free to contact me!

Pages : Follow ankurtwi on Twitter      

First Views On Google+


Yesterday I got the Invitation of the recently launched social networking site know as “Google+” . Its based on your day to day interaction analysis made by ex-Googler Paul Adams.  People are in high hopes that this will save them from the addiction of Facebook.  As of present it’s access is limited to few people only and it’s in testing phase. Due to excessive demand of invitations, Google has closed down the invitation part for sometime . It’s quite true because all I saw yesterday on Facebook and Twitter is “Please Invite Me to Google+”. Experts says that Google+ will get open for  public in the coming week. It’s available for Gmail users only as of now. Google+ account gets integrated with the other Google products. You can open it from various ways. Either hit the “+ANKUR” on your Google bar or login to the www.plus.google.com .

You can click on Google+ (+ANKUR)

As soon as you login you will see a very simple and attractive UI :) Below is the screenshot of my plus account welcome screen.

Welcome Screen

Let’s talk about some of it features now :

1. You can easily add to contacts to the circles. Then while sharing ,you chooses the circle you want to share with. If you want to share it with all you have the public options for it. You can easily edit your circles.

2. It has got it recently launched “+1″ button on very post and comment. It’s quite similar to the Facebook’s like button.

3. Notifications will appear on the top right side of the screen. You can also see it in the above screenshot.

4. Instead of wall post, you share the “Stream” with your circles.

5. It has got the “Spark” feature . It’s quite similar to the hashtag feature of the social micro blogging site Twitter. This features lacks in the Facebook. You just type your topic and sparks and all the streams related to that will appear on your screen.

6. One more good feature is you can edit your comments. Facebook needs to think about applying this feature as soon as possible :)

Spark Feature

Overall I think Google+ is great in the privacy field. Moreover sharing the post with the people you want to is one of its major strength.  There is also a data liberation option in your Google+  settings through which you can download all of  your  uploaded data.  I am still searching about it’s hangout feature and will try write about it soon :) Feedbacks and Comments are welcome :D Oh!!!! I forgot to tell you one important thing i.e. Google+ is for 18+ only :(

Pages : Follow ankurtwi on Twitter      

Follow

Get every new post delivered to your Inbox.

Join 70 other followers

%d bloggers like this: