<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>/home/spsneo/blog</title>
	
	<link>http://spsneo.com/blog</link>
	<description>Trying to move every bit to cloud.</description>
	<lastBuildDate>Fri, 19 Aug 2011 16:43:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/spsneo" /><feedburner:info uri="spsneo" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>spsneo</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>A Simple LRU Cache Implementation</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/x8QMTz0v1VY/</link>
		<comments>http://spsneo.com/blog/2011/03/15/a-simple-lru-cache-implementation/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 20:42:23 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[Caching Algorithm]]></category>
		<category><![CDATA[Data Structure]]></category>
		<category><![CDATA[Linked HashMap]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[Cache Algorithm]]></category>
		<category><![CDATA[LRU Cache]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=153</guid>
		<description><![CDATA[LRU Cache is a caching strategy where we use Least Recently Used (LRU) eviction policy when the cache is full and we want to add more new data to the cache. LRU cache is used in many caching applications. For &#8230; <a href="http://spsneo.com/blog/2011/03/15/a-simple-lru-cache-implementation/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>LRU Cache is a caching strategy where we use<a title="LRU Cache" href="http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used"> Least Recently Used</a> (LRU) eviction policy when the cache is full and we want to add more new data to the cache. LRU cache is used in many caching applications. For example <a title="Memcached" href="http://memcached.org/">memcached</a> <a href="http://www.igvita.com/2008/04/22/mysql-conf-memcached-internals/">uses</a> LRU cache.</p>
<p>I have implemented a simple LRU Cache. The code is far from production use. First of all it is not thread safe and I have not used template programming to make it generic. The code is just to illustrate one of the possible ways of implementing an LRU Cache.</p>
<p>The implementation is inspired from Sun Java <a href="http://download.oracle.com/javase/6/docs/api/java/util/LinkedHashMap.html">LinkedHashMap</a> implementation. For serious production use one should use the LinkedHashMap implementation. The code here is just to illustrate the data structure used.</p>
<p>I have used a doubly-linked list and a hashmap. All the key-value pairs are saved in a node of doubly-linked list and these nodes are hashed on the key in the hashmap. This allows for O(1) time access. The node corresponding to the most recently used key-value pair is always at the head of the linked list and the node corresponding to the least recently used key-value pair is always at the tail of the linked list. Time complexity for &#8216;get&#8217; and &#8216;put&#8217; operation is O(1) and the space complexity is O(n), where n is the maximum capacity of cache.</p>
<p>Here goes the code -</p>
<pre class="brush: php">

public class Node {

  public Node prev;
  public Node next;
  public String key;
  public String data;

  public Node()
  {
  }

  public Node(String key, String data)
  {
    this.key = key;
    this.data = data;
  }
}
</pre>
<pre class="brush: php">
import java.util.*;

public class LRUCache {

  private Node head;
  private Node tail;
  private int maxSize;
  private HashMap&amp;lt;String, Node&amp;gt; m = new HashMap&amp;lt;String, Node&amp;gt;();

  // Constructor - maxSize is the maximum capacity of the cache
  public LRUCache(int maxSize)
  {
    this.maxSize = maxSize;
    head = new Node(null, null);
    tail = new Node(null, null);
    head.next = tail;
    tail.prev = head;
  }

  private void addElementToListAtHead(Node node)
  {
    node.next = head.next;
    node.prev = head;
    head.next.prev = node;
    head.next = node;
  }

  private void removeElementFromList(Node node)
  {
    node.prev.next = node.next;
    node.next.prev = node.prev;
  }

  // Function to access data from the cache
  public String get(String key)
  {
    Node node = m.get(key);
    if(node == null)
      return null;

    if(m.size() == 1)
      return node.data;

    removeElementFromList(node);
    addElementToListAtHead(node);
    return node.data;
  }

  // Function to add new data or modify existing data in the cache
  public void put (String key, String data)
  {
    if(maxSize &amp;lt;= 0)
      return;

    Node node = m.get(key);
    if (node != null)
    {
      removeElementFromList(node);
      addElementToListAtHead(node);
      node.data = data;
    } else {
      node = new Node(key, data);
      m.put(key, node);
      addElementToListAtHead(node);
      if(m.size() &amp;gt; maxSize)
      {
        m.remove(tail.prev.key);
        removeElementFromList(tail.prev);
      }
    }
    return;
  }
}
</pre>
<p>Please point out the obvious/non-obvious bugs in the code. And also provide suggestions for better implementation.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2011/03/15/a-simple-lru-cache-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2011/03/15/a-simple-lru-cache-implementation/</feedburner:origLink></item>
		<item>
		<title>Perplexing Probability – Things are not always obvious</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/bazLnahybKg/</link>
		<comments>http://spsneo.com/blog/2011/01/17/perplexing-probability-things-are-not-always-obvious/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 17:17:44 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[Probability]]></category>
		<category><![CDATA[Probabiliy]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=146</guid>
		<description><![CDATA[Note: Below mentioned story is a purely hypothetical one. Think of it as just another probability problem. Don&#8217;t get into the complexities of real world. Everything you need to ponder upon is already mentioned in the story. After the recent &#8230; <a href="http://spsneo.com/blog/2011/01/17/perplexing-probability-things-are-not-always-obvious/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong> Below mentioned story is a purely hypothetical one. Think of it as just another probability problem. Don&#8217;t get into the complexities of real world. Everything you need to ponder upon is already mentioned in the story.</p>
<p>After the recent India-SA test series, the big question is which is the better test team. Obviously, if we go by test rankings India is currently the number 1 test team and the mighty SA the second in the list. But ICC decided to organize a three match series between the two sides to decide the ultimate team. They propose to Indian cricket team &#8211; if they can win at least two consecutive matches they will be declared the number 1 team of all times. The three matches will be played alternatively in India and South Africa. The Indian team can decide the order, either they can choose to play in India-SA-India or SA-India-SA. The ICC also lifted up the 5 day constraint &#8211; which means each match will end up with a result for sure, no draw. For quite obvious reasons the probability of India winning a match in India is more than India winning a match in SA.</p>
<p>Now the question in front of BCCI is to select the order of venues to maximize the probability of India becoming the best test team of all times.</p>
<p>BCCI first came up with the order &#8211; India-SA-India, which also sounds obvious. But, when they later realized that India has to win at least two consecutive matches to prove their supremacy, they changed the order to SA-India-SA which is not so obvious but of course the correct strategy (at least probabilistically).</p>
<p>Do some calculations yourself to appreciate the BCCI&#8217;s final decision.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2011/01/17/perplexing-probability-things-are-not-always-obvious/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2011/01/17/perplexing-probability-things-are-not-always-obvious/</feedburner:origLink></item>
		<item>
		<title>What’s wrong with binary search!</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/ngqM3mEXZNo/</link>
		<comments>http://spsneo.com/blog/2011/01/11/whats-wrong-with-binary-search/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 19:47:19 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[Algorithm]]></category>
		<category><![CDATA[Binary Search]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Google Research]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=138</guid>
		<description><![CDATA[There&#8217;s a bug in the code of &#8220;Binary Search&#8221; as most of us write it. When asked most of us code binary search as - int binary_search(int *a, int len, int key) { int low = 0; int high = &#8230; <a href="http://spsneo.com/blog/2011/01/11/whats-wrong-with-binary-search/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a bug in the code of &#8220;Binary Search&#8221; as most of us write it. When asked most of us code binary search as -</p>
<pre class="brush: c">
int binary_search(int *a, int len, int key)
{
int low = 0;
int high = len-1;

while (low &lt;= high)
{
int mid = (low+high)/2;
int val = a[mid];

if (val &lt; key)
{
low = mid + 1;
} else if (val &gt; key)
{
high = mid - 1;
} else
{
return mid;
}
}
return -1;
}
</pre>
<p>Now, try to find the bug in the above code. The bug surfaces if the array is too large. If the length of the array is too large, line number 8 in the above code would cause the variable &#8220;mid&#8221; to overflow and hence will have a negative number and the code breaks. A very simple solution would be to replace line 8 in the above code with -</p>
<pre class="brush: php">
mid = low + (high-low)/2;
</pre>
<p>So, you see how bugs could creep in your code. To see more detailed discussion on how the bug was discovered and a couple of more elegant, efficient solutions check out this Google Research blog &#8211; <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html">http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2011/01/11/whats-wrong-with-binary-search/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2011/01/11/whats-wrong-with-binary-search/</feedburner:origLink></item>
		<item>
		<title>What’s been keeping me busy these days?</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/uJfQ1Pr_cVw/</link>
		<comments>http://spsneo.com/blog/2011/01/08/whats-been-keeping-me-busy-these-days/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 20:24:33 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Memory Management Algorithms]]></category>
		<category><![CDATA[Nova]]></category>
		<category><![CDATA[OpenStack]]></category>
		<category><![CDATA[Page Replacement Algorithms]]></category>
		<category><![CDATA[Swift]]></category>
		<category><![CDATA[Trading Algorithm]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[life]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[memory management]]></category>
		<category><![CDATA[nova]]></category>
		<category><![CDATA[openstack]]></category>
		<category><![CDATA[page replacement]]></category>
		<category><![CDATA[swift]]></category>
		<category><![CDATA[trading algorithms]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=132</guid>
		<description><![CDATA[Of late, I have not been adding new pages to my blog. A lot has changed since I last blogged. From an undergrad student at IIT Guwahati to a Software Developer at Adobe India now. Transitioning from one role to &#8230; <a href="http://spsneo.com/blog/2011/01/08/whats-been-keeping-me-busy-these-days/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Of late, I have not been adding new pages to my blog. A lot has changed since I last blogged. From an undergrad student at <a href="http://www.iitg.ernet.in">IIT Guwahati</a> to a Software Developer at <a href="http://www.adobeindia.com">Adobe India</a> now. Transitioning from one role to another took a lot of time. Now, when I think, I am probably comfortable in the new role, I have started exploring new stuffs. I will enumerate few of the interesting stuffs I have been looking into since last one month or so.</p>
<ul>
<li><span style="font-weight: bold; text-decoration: underline;">Page Replacement Algorithms</span> &#8211; I have been digging into various page/memory replacement algorithms. For the uninitiated ones here is the wikipedia page which explains various of those algorithms in short &#8211; <a href="http://en.wikipedia.org/wiki/Page_replacement_algorithm">http://en.wikipedia.org/wiki/Page_replacement_algorithm </a> . I explored the <a href="http://memcached.org/">memcached</a> cache replacement policy and its implementation. I will write more about my reading on this subject in my later posts. I will also <strong>try</strong> to attach implementations of few of the algorithms.</li>
<li><span style="font-weight: bold; text-decoration: underline;">OpenStack</span> &#8211; <a href="http://www.openstack.org">Openstack</a> is an <a href="http://csrc.nist.gov/groups/SNS/cloud-computing/">IaaS Cloud Computing</a> open source project started by <a href="http://www.rackspace.com">Rackspace</a> and <a href="http://www.nasa.gov/">NASA</a>. There are basically two sub projects of Openstack &#8211; <a href="http://nova.openstack.org/">Nova</a> and <a href="http://swift.openstack.org/">Swift</a>. I have read the overview of both the sub projects and I am trying to dig more into Nova. I would love to contribute to this awesome project and will start off soon by accomplishing some low hanging fruits of Nova. Will write more about my experience and technical insights I gain in my later posts.</li>
<li><span style="font-weight: bold; text-decoration: underline;">Art of Trading</span> &#8211; I have been looking into various articles related to algorithmic trading. I started off with <em><a href="http://en.wikipedia.org/wiki/Optimal_stopping">Optimal Stopping Theorem</a>. </em>Depth first search of the wikipedia article led me to <a style="font-style: italic;" href="http://en.wikipedia.org/wiki/Search_theory">Search Theory</a>, <a style="font-style: italic;" href="http://en.wikipedia.org/wiki/Odds_algorithm">Odds Algorithm</a>, the interesting <em>&#8220;<a href="http://www.americanscientist.org/issues/feature/2009/2/knowing-when-to-stop/2">The Marriage Problem</a>&#8221; </em>. But things start getting mathematically complex once I start digging into <a style="font-style: italic;" href="http://www.investorgeeks.com/articles/2006/11/29/automated-trading-algorithms/">Automated Trading Algorithms</a>. <a href="http://en.wikipedia.org/wiki/Quantitative_analyst#Algorithmic_Trading_Quant">ATQ</a>s use techniques from signal processing, game theory, gambling Kelly Criterion and time series analysis. Miles to go. Phew!</li>
</ul>
<p>And yeah, I have also been listening to two songs continuously (read frequently) these days &#8211; <em><a href="http://en.wikipedia.org/wiki/Lamhaa#Tracklist">Madno Re</a> </em>from Lamhaa (2010) and <em>Naam Adaa Likhna </em>from <a href="http://en.wikipedia.org/wiki/Yahaan">Yahaan (2005)</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2011/01/08/whats-been-keeping-me-busy-these-days/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2011/01/08/whats-been-keeping-me-busy-these-days/</feedburner:origLink></item>
		<item>
		<title>IITG Webmail Extension – Auto Login Feature</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/M_AoEsL2qn4/</link>
		<comments>http://spsneo.com/blog/2010/03/03/iitg-webmail-extension-auto-login-feature/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 20:03:33 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[IITG]]></category>
		<category><![CDATA[IITG webmail]]></category>
		<category><![CDATA[extension]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=115</guid>
		<description><![CDATA[Note: This post is only for currently enrolled IITG students. Today I added a new feature to the &#8220;IITG webmail chrome extension&#8221; &#8211; Auto Login feature. Now you can save your username and password in the options page of the &#8230; <a href="http://spsneo.com/blog/2010/03/03/iitg-webmail-extension-auto-login-feature/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Note: This post is only for currently enrolled IITG students.</strong></p>
<p>Today I added a new feature to the &#8220;<a href="https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob?hl=en-us">IITG webmail chrome extension</a>&#8221; &#8211; Auto Login feature. Now you can save your username and password in the options page of the extension and enable auto-login. After enabling auto-login feature, whenever you open <a href="http://webmail.iitg.ernet.in">http://webmail.iitg.ernet.in</a>, the extension will automatically redirect you to your inbox.</p>
<p>Check out the screenshots at the extension page: <a href="https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob?hl=en-us">https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob?hl=en-us</a></p>
<p>All those who are already using this extension can update it by clicking &#8220;Update extensions now&#8221; button in chrome://extensions page. New users can directly install the extension at: https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob?hl=en-us</p>
<p>Keep pouring in your feedback by posting comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2010/03/03/iitg-webmail-extension-auto-login-feature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2010/03/03/iitg-webmail-extension-auto-login-feature/</feedburner:origLink></item>
		<item>
		<title>Updated IITG Webmail Extension</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/jsQs6t8Uybs/</link>
		<comments>http://spsneo.com/blog/2010/02/28/updated-iitg-webmail-extension/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 08:39:34 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[IITG]]></category>
		<category><![CDATA[IITG webmail]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[google chrome]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=112</guid>
		<description><![CDATA[Note: This post is for currently enrolled IITG students I wrote about a chrome extension in my yesterday&#8217;s post. 1st and 2nd year students of IITG have different mail servers than Disang. They won&#8217;t be able to use the extension. &#8230; <a href="http://spsneo.com/blog/2010/02/28/updated-iitg-webmail-extension/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><strong>Note: This post is for currently enrolled IITG students</strong></p>
<p>I wrote about a chrome extension in my <a title="IITG Webmail Chrome Extension" href="http://spsneo.com/blog/2010/02/27/google-chrome-extension-for-iitg-webmail/">yesterday&#8217;s post</a>. 1st and 2nd year students of IITG have different mail servers than Disang. They won&#8217;t be able to use the <a href="https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob?hl=en">extension</a>. So, I updated the extension. Now one can set the default mail server and save the option. Now, the extension works for all the mail servers.</p>
<p>Those who have already installed the extension can update it by clicking on the button &#8220;Update Extensions Now&#8221; button in the <a href="chrome://extensions" target="_blank">Chrome Extension page</a>. And those who have not yet installed the extension can install the updated version directly from : <a href="https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob?hl=en">https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob?hl=en</a></p>
<p>Keep pouring in your feedbacks in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2010/02/28/updated-iitg-webmail-extension/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2010/02/28/updated-iitg-webmail-extension/</feedburner:origLink></item>
		<item>
		<title>Google Chrome Extension for IITG Webmail</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/0v2yEuKdn3c/</link>
		<comments>http://spsneo.com/blog/2010/02/27/google-chrome-extension-for-iitg-webmail/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 13:48:12 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[Chrome]]></category>
		<category><![CDATA[IITG]]></category>
		<category><![CDATA[IITG webmail]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[webmail]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=108</guid>
		<description><![CDATA[NOTE: This post is for IITG students. IITG webmail accounts are hosted on different servers for students, staff and faculty. So every time I open the page &#8211; http://webmail.iitg.ernet.in, I have to change the server to Disang. I wrote a &#8230; <a href="http://spsneo.com/blog/2010/02/27/google-chrome-extension-for-iitg-webmail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>NOTE: This post is for IITG students.</p>
<p>IITG webmail accounts are hosted on different servers for students, staff and faculty. So every time I open the page &#8211; http://webmail.iitg.ernet.in, I have to change the server to Disang. I wrote a simple chrome plugin to do this automatically, every time I visit this page.</p>
<p>It is simple to use. You need to have the latest version of Google chrome installed. Once you have it, just click on this link: <a href="https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob">https://chrome.google.com/extensions/detail/ljfkohgffehmmfnmghdlbceidmddgdob</a> and then press &#8220;Install&#8221; button. And you are done. Now open the webmail page &#8211; <a href="http://webmail.iitg.ernet.in">http://webmail.iitg.ernet.in</a> and check out the selected server.</p>
<p>Send me feedback by commenting to this blog or at the plugin page.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2010/02/27/google-chrome-extension-for-iitg-webmail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2010/02/27/google-chrome-extension-for-iitg-webmail/</feedburner:origLink></item>
		<item>
		<title>Post Pidgin and Twitter status from command line</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/ZRleg7L7TSk/</link>
		<comments>http://spsneo.com/blog/2010/01/20/post-pidgin-and-twitter-status-from-command-line/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 11:52:16 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[microblogging]]></category>
		<category><![CDATA[Pidgin]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[status message]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=104</guid>
		<description><![CDATA[I often want to post the same status message in Pidgin and Twitter. I wrote  simple bash script to accomplish this. One can download the script from here: http://www.spsneo.com/scripts/poststatus.tar.gz How to use it - 1) Change the permission of the &#8230; <a href="http://spsneo.com/blog/2010/01/20/post-pidgin-and-twitter-status-from-command-line/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I often want to post the same status message in Pidgin and Twitter. I wrote  simple bash script to accomplish this.</p>
<p>One can download the script from here: <a title="poststatus script" href="http://www.spsneo.com/scripts/poststatus.tar.gz">http://www.spsneo.com/scripts/poststatus.tar.gz</a></p>
<p>How to use it -</p>
<p>1) Change the permission of the file to make it executable: <code> chmod +x poststatus</code></p>
<p>2) Then execute the file with the status message as the argument: <code> ./poststatus "Status Message goes here in quotes"</code></p>
<p>3) The script will first post the status message in your pidgin and will then ask whether you want to post it on twitter.  If you say yes, the script asks you for your twitter username and password.</p>
<p>Start using the script and send me feedback to improve it.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2010/01/20/post-pidgin-and-twitter-status-from-command-line/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2010/01/20/post-pidgin-and-twitter-status-from-command-line/</feedburner:origLink></item>
		<item>
		<title>Bash History Tips and Tricks</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/h6IwlI2q4ak/</link>
		<comments>http://spsneo.com/blog/2009/09/19/bash-history-tips-and-tricks/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 18:48:35 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Man pages]]></category>
		<category><![CDATA[History]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=96</guid>
		<description><![CDATA[Bash supports history expansion feature which can be very useful for powerful command-line users. According to bash manual page - History  expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the &#8230; <a href="http://spsneo.com/blog/2009/09/19/bash-history-tips-and-tricks/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Bash supports history expansion feature which can be very useful for powerful command-line users.</p>
<p>According to bash manual page -</p>
<blockquote><p>History  expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly.</p></blockquote>
<p>History expansion is composed of three parts -</p>
<ul>
<li><strong>Event Designators:</strong> It is a reference to an entry in the history list.</li>
<li><strong>Word Designators:</strong> It is used to select a word from the event.</li>
<li><strong>Modifiers:</strong> Modifies the word selected by the word designator or the action of the command.</li>
</ul>
<p>All the three parts are optional and are separated from each other by a : (colon). There can be multiple modifiers each separated by a : (colon).</p>
<p>Now I will explain each part one by one.</p>
<p><strong>Event Designators:</strong></p>
<ol>
<li><strong>! </strong>Start a history substitution, except when followed by a <strong>blank, </strong>newline, carriage return,  = or (</li>
<li><strong>!n </strong>It refers to n&#8217;th command in the history. So if you just type in<br />
<code>!68</code> at the command prompt, 68th command in your history list will be executed.</li>
<li><strong>!-n</strong> It refers to n&#8217;th command in the history from last. So if you just type in !-1 at the command prompt, last command will be executed.<strong> </strong></li>
<li><strong>!!</strong> is an alias for !-1.  Example:<br />
<code>$apt-get install gnome-ppp    //Permission Denied. You need to be sudo to do this!<br />
$sudo !!                      // This is equivalent to sudo apt-get install gnome-ppp</code><strong> </strong></li>
<li><strong>!<span style="text-decoration: underline;">string</span> </strong>It refers to the most recent command in the history starting with <span style="text-decoration: underline;">string</span>. It is again an useful expansion when you don&#8217;t remember the arguments to a command which you have executed earlier.</li>
<li><strong>!?<span style="text-decoration: underline;">string</span>[?] </strong>It refers to the most recent command containing <span style="text-decoration: underline;">string</span>. The trailing <strong>? </strong>may be omitted if <span style="text-decoration: underline;">string</span> is immediately followed by a newline.</li>
</ol>
<p><strong>Word Designators:</strong></p>
<ol>
<li><strong><span style="text-decoration: underline;">n</span> </strong>The <span style="text-decoration: underline;">n</span>th word, count starting from 0. 0th word normally refers to the command. Example:<br />
<code>$sudo cat /etc/resolv.conf     //Instead you want to edit the resolv.conf file<br />
$sudo vi !!:2                       //This is equivalent to sudo vi /etc/resolv.conf</code><strong> </strong></li>
<li><strong> ^ </strong>This refers to 1st word. This is equivalent to <strong>:1 </strong>as refered above. The only .advantage is that you can omit : (colon) when you use ^. Example:<br />
<code> $cat ~/.bashrc<br />
$vi !!^        //This is equivalent to "vi !!:1" that is vi ~/.bashrc<br />
</code></li>
<li>$ This refers to the last word.</li>
<li><span style="text-decoration: underline;"><strong>x</strong></span><strong>-<span style="text-decoration: underline;">y</span> </strong>This refers to a range of words; &#8216;<strong>-<span style="text-decoration: underline;">y</span></strong>&#8216; is equivalent to &#8217;0-y&#8217;.</li>
<li><strong>* </strong>This refers to all the words except the 0th one. This is helpful when you have to execute a command with all the arguments passed to the last command.</li>
<li><span style="text-decoration: underline;"><strong>x</strong></span><strong>* </strong>This is an alias for <span style="text-decoration: underline;">x</span>-$ .</li>
</ol>
<p>Note: If a word designator is used without an event specification, the last command in the history is used as the event. Example -<br />
<code>$cat ~/.bashrc<br />
$vi !:1</code> // This is equivalent to vi !!:1 or vi ~/.bashrc</p>
<p><strong>Modifiers:</strong></p>
<ol>
<li><strong>h</strong> This removes the trailing file name component, leaving the head. Example:<br />
<code>$cat /home/spsneo/.bashrc<br />
$ls !!:1:h </code>//This expands to <code>ls /home/spsneo</code>Explanation: !! refers to the last command and then :1 refers to the 1st word of the last command and then :h removes the trailing file name component i.e., .bashrc . Hence the expansion.</li>
<li><strong>t</strong> This removes all leading file name components, leaving the tail.</li>
<li><strong>r </strong>This removes the trailing suffix of the form <span style="text-decoration: underline;"><strong>.xxx</strong></span> , leaving the basename.</li>
<li><strong>p </strong>Print the new command but do not execute it.</li>
<li><strong>s/<span style="text-decoration: underline;">old</span>/<span style="text-decoration: underline;">new</span></strong> This substitutes the first occurrence of <span style="text-decoration: underline;">old</span> with <span style="text-decoration: underline;">new</span>. Example:<br />
<code>$cat /etc/resolv.conf<br />
$!!:s/resolv/yum</code> //This expands to <code>cat /etc/yum.conf</code><strong><code><br />
</code></strong></li>
<li><strong>g </strong>This is used in conjunction with &#8220;<strong>:s</strong>&#8221; modifier. This causes changes to be applied over the entire event line rather than just the first occurrence. Example:<br />
<code>$cat test.cpp test.h<br />
$!!:gs/test/source/ </code> //This expands to <code>cat source.cpp source.hh</code></li>
</ol>
<p>This is all I have to share about bash history expansion.</p>
<p>Do post comments if you find any mistake or if you want any further clarifications. One can also go through the bash manual pages for more options.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2009/09/19/bash-history-tips-and-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2009/09/19/bash-history-tips-and-tricks/</feedburner:origLink></item>
		<item>
		<title>Set BING Background as your Desktop Wallpaper in GNOME</title>
		<link>http://feedproxy.google.com/~r/spsneo/~3/AzfJip0vpJc/</link>
		<comments>http://spsneo.com/blog/2009/07/18/set-bing-background-as-your-desktop-wallpaper-in-gnome/#comments</comments>
		<pubDate>Fri, 17 Jul 2009 20:15:01 +0000</pubDate>
		<dc:creator>spsneo</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[BING]]></category>
		<category><![CDATA[GNOME]]></category>
		<category><![CDATA[GRUB]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Wallpaper]]></category>

		<guid isPermaLink="false">http://spsneo.com/blog/?p=86</guid>
		<description><![CDATA[BING comes up with a beautiful background everyday. I thought why not set this background as my desktop wallpaper. But it would be a cumbersome task to set it manually. So I searched (Googled, BINGed) for some script which will &#8230; <a href="http://spsneo.com/blog/2009/07/18/set-bing-background-as-your-desktop-wallpaper-in-gnome/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a title="BING " href="http://www.bing.com" target="_blank">BING</a> comes up with a beautiful background everyday. I thought why not set this background as my desktop wallpaper. But it would be a cumbersome task to set it manually. So I searched (Googled, BINGed) for some script which will do this for me. I found <a title="Bing Downloader" href="http://bing.codeplex.com/" target="_blank">BING Downloader</a> which does this task on Windows. I could not find any such script for GNOME. So, I thought of writing one.</p>
<p>I wrote a script which when executed automatically sets the GNOME wallpaper as BING background of the day. This is a PHP script. To execute this script you need to have php installed on your system. You can install php in Ubuntu as<br />
<code><br />
sudo apt-get install php5 php5-cli</code></p>
<p>Now you are all set to download this script. Download Link: <a title="Set BING background as GNOME Desktop wallpaper" href="http://www.spsneo.com/scripts/bing_wallpaper.tar.gz" target="_self">http://www.spsneo.com/scripts/bing_wallpaper.tar.gz</a></p>
<p>Download this file, extract the script file. Now you can run the script from terminal :<br />
<code> php bing_wallpaper.php </code></p>
<p>And your wallpaper is set. You can run this script daily from your terminal or you can set a cron job for the same or you can set up an icon in your gnome panel for this script.</p>
<p>I will keep updating this script. And I am also planning to write the same script in python. So check back again if you dont want to install php on your system.</p>
<p>Send your feedbacks and suggestions.</p>
<p><strong>Update 1:</strong> I have modified the script to work with http proxy. Just assure that the environment variable http_proxy is properly set.</p>
<p><strong>Update 2:</strong> Modified the script to keep the image centered on the desktop with black background. Try it out.</p>
]]></content:encoded>
			<wfw:commentRss>http://spsneo.com/blog/2009/07/18/set-bing-background-as-your-desktop-wallpaper-in-gnome/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://spsneo.com/blog/2009/07/18/set-bing-background-as-your-desktop-wallpaper-in-gnome/</feedburner:origLink></item>
	</channel>
</rss>

