<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Gubatron.com &#187; Code</title>
	<atom:link href="http://www.gubatron.com/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gubatron.com/blog</link>
	<description>Another Venezuelan Geek in New York</description>
	<lastBuildDate>Mon, 06 Feb 2012 17:26:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>5 Object Oriented Programming Principles learned during the last 15 years</title>
		<link>http://www.gubatron.com/blog/2012/02/01/5-object-oriented-programming-principles-learned-during-the-last-15-years/</link>
		<comments>http://www.gubatron.com/blog/2012/02/01/5-object-oriented-programming-principles-learned-during-the-last-15-years/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 04:45:10 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[best practices]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[oo]]></category>
		<category><![CDATA[principles]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2660</guid>
		<description><![CDATA[It was about 15 years ago when I first created my first class. I went from thinking of Object Oriented programming as this awesome paradigm I should know about, I remember having all these mental models of what objects where and learning all this new vocabulary that I really didn&#8217;t fully grasp until years later [...]]]></description>
			<content:encoded><![CDATA[<p>It was about 15 years ago when I first created my first class.</p>
<p>I went from thinking of Object Oriented programming as this awesome paradigm I should know about, I remember having all these mental models of what objects where and learning all this new vocabulary that I really didn&#8217;t fully grasp until years later when I was designing and implementing bigger more complex systems.</p>
<p>At first I remember looking at objects as a collection of functions that kept a common reference to keep internal states and missing out on all the great features of inheritance and abstract classes. Looking at &#8220;interfaces&#8221; and using them like a recipe without really knowing their true power, I look at the past and I was so limited, hopefully I&#8217;ll look at this post 15 years from now and think the same.</p>
<p>There&#8217;s lots of books out there on best programming practices you should follow, on this short post I&#8217;ll share with you 6 principles that I follow that I promise you will make your code behave really well, less bug prone, simple and elegant when it comes to Object Oriented design. This advice will probably apply better if you code in a language like Java or C#, I&#8217;m not sure if you can say these principles will apply 100% to other OO languages (for instance those that allow multiple inheritance)</p>
<p><strong>1. DRY principle.</strong><br />
This is one of the most preached ones, and I will also preach it. DO NOT REPEAT YOURSELF. Really, don&#8217;t. It ALWAYS comes to bite you in the ass if you have repeated code. Only repeat yourself if it&#8217;s too hard to not do so or if you&#8217;re absolutely sure that you won&#8217;t repeat yourself a third time, but I promise you that third time will come if it&#8217;s not for you for the next guy maintaining that code.</p>
<p>The obvious benefit of not repeating yourself is that you get to maintain code only in one place, the added benefit will be that your code will almost start being written by itself like a perfect equation as it grows. DRY code will be reusable, maintainable and the other principles I&#8217;ll talk about are related to the DRY principle in one way or another.</p>
<p><strong>2. Keep the scope at the minimum, be as private as possible.</strong></p>
<p>Keep your variables as close to your local scope as possible. This will save you many headaches, will protect you from bugs in logic because you did something to a variable in place where it shouldn&#8217;t have been in the first place, and it will keep things simpler.</p>
<p>This also tells you that your classes should expose as little as possible. Keep your variables local, if they can&#8217;t be local, try to keep them as private members, if they have to be used by extending classes keep them private, only use public when you really know it&#8217;s ok to make something public and that nobody is going to break the behavior of your object if they play with things at any point in time.</p>
<p>Keeping scope at a minimum can also prevent issues on longer lived objects like singletons that might be accessed by different objects. If you abuse the use of object properties you could have one object changing the internal state of the object while another tries to do something and you&#8217;ll get unexpected behavior, this tends to happen a lot in multithreaded environments where programmers are not careful and forget objects might be accessed by different threads/clients at the same time, tight scopes will protect you.</p>
<p><strong>3. Be functional</strong><br />
Sometimes you&#8217;ll be tempted to be lazy and not pass parameters on a method and think that you&#8217;re so clever by changing an internal property of an object so that another function in the object will then get it. Big mistake buddy. This can be equivalent to that advice from functional programming languages where you&#8217;re told that using global variables are a bad idea.<br />
Yes, we have object properties for several reasons, but if the logic of a method depends on the state of a variable, you might as well be explicit and pass it in the method.</p>
<p>This is in a way related to keeping scope at the minimum, and to some extend related to the advice some give of keeping your objects as immutable as possible.</p>
<p><strong>4. Only abstract classes are worth extending.</strong><br />
If you have control over the class you are about to extend (if it&#8217;s in your codebase) before you extend that class take a look and make sure that it&#8217;s an abstract class. Abstract classes are MEANT to be extended, so you can be safe that you&#8217;re doing the right thing here.</p>
<p>If you&#8217;re extending a non abstract class, you should probably be composing it instead. If you don&#8217;t have access to the code of the class you are extending, things could not behave as expected when you extend, not all programmers are as thoughtful as you are.</p>
<p><strong>5. Keep Object lifetime as short as possible.</strong><br />
This goes back to keeping scopes tight and trying to avoid singletons as much as possible (as convenient as they might be), in the case of java the JRE has a better time collecting garbage and will save you from memory leak headaches. Put those factories to work.</p>
<p>Feel free to disent and share your favorite principles, If you&#8217;ve coded long enough I&#8217;m sure you tend to think about these things too and I&#8217;d love to learn from your experiences.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F&amp;title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F&amp;title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F&amp;title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F&amp;headline=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F&amp;title=5+Object+Oriented+Programming+Principles+learned+during+the+last+15+years&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F02%2F01%2F5-object-oriented-programming-principles-learned-during-the-last-15-years%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2012/02/01/5-object-oriented-programming-principles-learned-during-the-last-15-years/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Javascript: Capitalize Text Like In This Title</title>
		<link>http://www.gubatron.com/blog/2012/01/05/javascript-capitalize-text-like-in-this-title/</link>
		<comments>http://www.gubatron.com/blog/2012/01/05/javascript-capitalize-text-like-in-this-title/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 02:43:07 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2637</guid>
		<description><![CDATA[On this one, we&#8217;ll show of the dynamic nature of javascript and we&#8217;re going to make all strings have a new method called &#8220;capitalize()&#8221;. So you can do stuff like this: Here&#8217;s the magic code you&#8217;ll need to add somewhere on your javascript files and all strings will have a new capitalize() method.]]></description>
			<content:encoded><![CDATA[<p>On this one, we&#8217;ll show of the dynamic nature of javascript and we&#8217;re going to make all strings have a new method called &#8220;capitalize()&#8221;.</p>
<p>So you can do stuff like this:</p>
<pre class="brush: jscript; title: ; notranslate">
console.log(&quot;this text should look nicer now&quot;.capitalize());
&gt;&gt; This Text Should Look Nicer Now
</pre>
<p>Here&#8217;s the magic code you&#8217;ll need to add somewhere on your javascript files and all strings will have a new capitalize() method.</p>
<pre class="brush: jscript; title: ; notranslate">
String.prototype.capitalize = function(){
	   return this.replace( /(^|\s)([a-z])/g , function(m,p1,p2){ return p1+p2.toUpperCase(); } );
};
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F&amp;title=Javascript%3A+Capitalize+Text+Like+In+This+Title" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F&amp;title=Javascript%3A+Capitalize+Text+Like+In+This+Title" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F&amp;title=Javascript%3A+Capitalize+Text+Like+In+This+Title" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F&amp;headline=Javascript%3A+Capitalize+Text+Like+In+This+Title" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Javascript%3A+Capitalize+Text+Like+In+This+Title&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Javascript%3A+Capitalize+Text+Like+In+This+Title&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Javascript%3A+Capitalize+Text+Like+In+This+Title&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Javascript%3A+Capitalize+Text+Like+In+This+Title&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Javascript%3A+Capitalize+Text+Like+In+This+Title&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F&amp;title=Javascript%3A+Capitalize+Text+Like+In+This+Title&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-capitalize-text-like-in-this-title%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2012/01/05/javascript-capitalize-text-like-in-this-title/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript: Format a number to display thousands US style (#,###,###,###)</title>
		<link>http://www.gubatron.com/blog/2012/01/05/javascript-format-a-number-to-display-thousands-us-style/</link>
		<comments>http://www.gubatron.com/blog/2012/01/05/javascript-format-a-number-to-display-thousands-us-style/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 02:40:04 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2634</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
/**
 * Format a number to display thousands like in the US -&gt; 1000000 =&gt; 1,000,000
 * @param number
 * @returns
 */
function formatThousands(number) {
	return Math.max(0, number).toFixed(0).replace(/(?=(?:\d{3})+$)(?!^)/g, ',');
}
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F&amp;title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F&amp;title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F&amp;title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F&amp;headline=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F&amp;title=javascript%3A+Format+a+number+to+display+thousands+US+style+%28%23%2C%23%23%23%2C%23%23%23%2C%23%23%23%29&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-format-a-number-to-display-thousands-us-style%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2012/01/05/javascript-format-a-number-to-display-thousands-us-style/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>javascript: Get N random elements from a List</title>
		<link>http://www.gubatron.com/blog/2012/01/05/javascript-get-n-random-elements-from-a-list/</link>
		<comments>http://www.gubatron.com/blog/2012/01/05/javascript-get-n-random-elements-from-a-list/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 02:38:33 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2632</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<pre class="brush: jscript; title: ; notranslate">
/**
 * Walks linearly through the list to find an element.
 * returns true if it's found.
 */
function elementIn(collection, element) {
	for (var i=0; i &lt; collection.length; i++) {
		if (collection[i]==element) {
			return true;
		}
	}
	return false;
}

/**
 * Returns a new list of n random elements taken out of myList.
 */
function getNElementsAtRandom(myList, n) {
	var toGo = n;
	var result = [];
	var indexesUsed = [];

	while (toGo &gt; 0) {
		index=-1;

		do {
			index = Math.floor(Math.random()*(myList.length));
			console.log(index);
		} while (elementIn(indexesUsed, index));

		indexesUsed.push(index);
		result.push(myList[index]);
		toGo--;
	}

	return result;
}
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F&amp;title=javascript%3A+Get+N+random+elements+from+a+List" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F&amp;title=javascript%3A+Get+N+random+elements+from+a+List" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F&amp;title=javascript%3A+Get+N+random+elements+from+a+List" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F&amp;headline=javascript%3A+Get+N+random+elements+from+a+List" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=javascript%3A+Get+N+random+elements+from+a+List&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=javascript%3A+Get+N+random+elements+from+a+List&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=javascript%3A+Get+N+random+elements+from+a+List&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=javascript%3A+Get+N+random+elements+from+a+List&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=javascript%3A+Get+N+random+elements+from+a+List&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F&amp;title=javascript%3A+Get+N+random+elements+from+a+List&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2012%2F01%2F05%2Fjavascript-get-n-random-elements-from-a-list%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2012/01/05/javascript-get-n-random-elements-from-a-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BFS vs DFS Graph Search Algorithms in Python</title>
		<link>http://www.gubatron.com/blog/2011/11/15/bfs-vs-dfs-graph-search-algorithms-in-python/</link>
		<comments>http://www.gubatron.com/blog/2011/11/15/bfs-vs-dfs-graph-search-algorithms-in-python/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 04:36:35 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2568</guid>
		<description><![CDATA[Here are implementations of iterative BFS and DFS search algorithms in Python. These are just to illustrate the slight difference in implementation of these algorithms. Basically, if you want to go deep, with DFS, you can use a queue on which you&#8217;ll be adding the next elements to explore as you traverse the graph. If [...]]]></description>
			<content:encoded><![CDATA[<p>Here are implementations of iterative BFS and DFS search algorithms in Python.</p>
<p>These are just to illustrate the slight difference in implementation of these algorithms.</p>
<p>Basically, if you want to go deep, with DFS, you can use a queue on which you&#8217;ll be adding the next elements to explore as you traverse the graph.<br />
If you want to scan around the current node, you can use a stack so that you keep looking at the closest elements before you move forward.</p>
<p>These functions use and return a list of visited nodes. If you want to make this a little more efficient, you can mark nodes as visited using a dictionary, or if the nodes themselves can have a property added to them, you can use that instead so you don&#8217;t have to do a linear search every time you want to know if a node was visited or not. I left it like that again, to just focus on the algorithm itself and not in the performance optimizations.</p>
<p><strong>Source</strong></p>
<pre class="brush: python; title: ; notranslate">
GRAPH = {1 : [2,3], 2:[4,5], 3:[6], 4:None, 5:[7,8], 6:None, 7:None, 8:None}

def BFS(start, target, GRAPH):
  'Use a QUEUE to search.'
  print &quot;Source:&quot;,source,&quot;Target:&quot;,target
  queue = [start]
  visited = []

  while len(queue) &gt; 0:
    x = queue.pop(0)

    if x == target:
      visited.append(x)
      return visited
    elif x not in visited:
      visited = visited+[x]
      if GRAPH[x] is not None:
         'add nodes at the END of the queue'
         queue = queue + GRAPH[x]

  return visited

def DFS(start, target, GRAPH):
  'Use a STACK to search.'
  print &quot;Source:&quot;,source,&quot;Target:&quot;,target
  stack = [start]
  visited = []

  while len(stack) &gt; 0:
    x = stack.pop(0)

    if x == target:
      visited.append(x)
      return visited
    elif x not in visited:
      visited = visited+[x]
      if GRAPH[x] is not None:
         'add nodes at the top of the stack'
         stack = GRAPH[x] + stack

  return visited

print &quot;BFS Path&quot;,BFS(1,7,GRAPH)
print &quot;DFS Path&quot;,DFS(1,7,GRAPH)
print &quot;=&quot;*80
print &quot;BFS Path&quot;,BFS(1,3,GRAPH)
print &quot;DFS Path&quot;,DFS(1,3,GRAPH)
</pre>
<p><strong>Output</strong></p>
<pre class="brush: bash; title: ; notranslate">
$ python graph.py
BFS Path Source: 1 Target: 7
[1, 2, 3, 4, 5, 6, 7]
DFS Path Source: 1 Target: 7
[1, 2, 4, 5, 7]
================================================================================
BFS Path Source: 1 Target: 3
[1, 2, 3]
DFS Path Source: 1 Target: 3
[1, 2, 4, 5, 7, 8, 3]
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F&amp;title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F&amp;title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F&amp;title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F&amp;headline=BFS+vs+DFS+Graph+Search+Algorithms+in+Python" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=BFS+vs+DFS+Graph+Search+Algorithms+in+Python&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F&amp;title=BFS+vs+DFS+Graph+Search+Algorithms+in+Python&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F11%2F15%2Fbfs-vs-dfs-graph-search-algorithms-in-python%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/11/15/bfs-vs-dfs-graph-search-algorithms-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NSIS: StrContains function &#8211; Find the index of a sub string.</title>
		<link>http://www.gubatron.com/blog/2011/08/31/nsis-strcontains-function-find-the-index-of-a-sub-string/</link>
		<comments>http://www.gubatron.com/blog/2011/08/31/nsis-strcontains-function-find-the-index-of-a-sub-string/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 01:01:53 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2267</guid>
		<description><![CDATA[Recently I was out of internet and I needed to implement a function that would search if a String was part of another String for an NSIS installer. Here&#8217;s my rendition of such a function. Once I came back online I found out about StrStr, but here&#8217;s another option that gives you as output the [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was out of internet and I needed to implement a function that would search if a String was part of another String for an NSIS installer.<br />
Here&#8217;s my rendition of such a function. Once I came back online I found out about <a href="http://nsis.sourceforge.net/StrStr">StrStr</a>, but here&#8217;s another option that gives you as output the starting index on the bigger string (aka Haystack) if the smaller string (aka Needle) is found. Otherwise, it returns -1.</p>
<pre class="brush: plain; title: ; notranslate">
; ------------------------------------------------
; StrContains
; Returns starting index of where a string is contained inside another string (case sensitive)
; Usage: !insertmacro StrContains ${HayStack} ${Needle} ${Output}
;
; Parameters:
;   HayStack - The string that could contain the substring you're looking for
;   Needle   - The string you are looking for
;   Output   - -1 if the needle is not in the haystack, or the offset where it exists.

Var HaystackOffset ;current offset on haystack to copy NeedleLength characters into HayStackBuffer
Var HaystackLength ;size of the big string
Var MaxHaystackOffset ;maximum offset we can reach
Var NeedleLength ;length of string we're looking for
Var HaystackBuffer ;substring we get on each iteration

!macro StrContains Haystack Needle Output
  ;we'll be repeating this operation until we've reached
  ;HayStackLength - NeedleLength

  ;Get the lengths of the strings.
  StrLen $HaystackLength ${Haystack}
  StrLen $NeedleLength ${Needle}
  StrCpy $HaystackOffset 0

  ;Determine what's the maximum offset we can use to search for the substring
  IntOp $MaxHaystackOffset $HaystackLength - $NeedleLength
  IntOp $MaxHaystackOffset $MaxHaystackOffset - 1

  ;Make sure needle is not bigger than haystack
  IntCmp $NeedleLength $HaystackLength LoopStart LoopStart DidNotFindIt

  DidNotFindIt:
  StrCpy $HaystackOffset -1
  Goto Finish

  ;Start of substring comparison loop
  LoopStart:
  ;copy the substring to a buffer
  StrCpy $HaystackBuffer ${Haystack} $NeedleLength $HaystackOffset

  ;It's pretty cool if you uncomment this.
  ;MessageBox MB_ICONINFORMATION|MB_OK &quot;[Loop] Buffer: [$HaystackBuffer] Offset: [$HaystackOffset]&quot;

  ;If we're done, we return the current haystackoffset
  StrCmpS $HaystackBuffer ${Needle} Finish FigureOutNextStep

  ;Did we reach the end, or can we move a bit more
  FigureOutNextStep:

  ;Move offset 1 character to the right and see if we can keep going
  IntOp $HaystackOffset $HaystackOffset + 1
  IntCmp $HaystackOffset $MaxHaystackOffset LoopStart LoopStart DidNotFindIt 

  Finish:
  StrCpy ${Output} $HaystackOffset
!macroend
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F&amp;title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F&amp;title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F&amp;title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F&amp;headline=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string.&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F&amp;title=NSIS%3A+StrContains+function+-+Find+the+index+of+a+sub+string.&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F31%2Fnsis-strcontains-function-find-the-index-of-a-sub-string%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/08/31/nsis-strcontains-function-find-the-index-of-a-sub-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>twitterAutoLinks: jQuery extension to replace twitter @names for links to their respective pages.</title>
		<link>http://www.gubatron.com/blog/2011/08/02/twitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages/</link>
		<comments>http://www.gubatron.com/blog/2011/08/02/twitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 00:47:19 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2233</guid>
		<description><![CDATA[Save the following on a .js file, preferably named jquery.twitterAutoLinks.js Usage After importing the jquery.twitterAutoLinks.js file (make sure it&#8217;s after you&#8217;ve imported jquery itself), you&#8217;ll use the extension as follows.]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm7.static.flickr.com/6022/5896418528_f8183111dd.jpg" width="100%"/></p>
<p>Save the following on a .js file, preferably named <strong>jquery.twitterAutoLinks.js</strong></p>
<pre class="brush: jscript; title: ; notranslate">
/** Auto replace all Twitter nicknames for links */
$.fn.twitterAutoLinks = function() {
  return this.each(function() {
    var html = $(this).html();
    $(this).html(html.replace(/\B@([\w-]+)/gm, '&lt;a href=&quot;http://twitter.com/$1&quot; target=&quot;_blank&quot;&gt;@$1&lt;/a&gt;'));
  });
};
</pre>
<p><strong>Usage</strong></p>
<p>After importing the jquery.twitterAutoLinks.js file (make sure it&#8217;s after you&#8217;ve imported jquery itself), you&#8217;ll use the extension as follows.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;script type=&quot;text/javascript&quot; language=&quot;Javascript&quot;&gt;

    $(document).ready(function() {
      //say you're running a wordpress blog and you want to do this for your posts
      $(&quot;div.entry&quot;).twitterAutoLinks();
    });

&lt;/script&gt;
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F&amp;title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F&amp;title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F&amp;title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F&amp;headline=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages.&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F&amp;title=twitterAutoLinks%3A+jQuery+extension+to+replace+twitter+%40names+for+links+to+their+respective+pages.&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F08%2F02%2Ftwitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/08/02/twitterautolinks-jquery-extension-to-replace-twitter-names-for-links-to-their-respective-pages/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Have the latest HAProxy as a Ubuntu Service</title>
		<link>http://www.gubatron.com/blog/2011/04/06/have-the-latest-haproxy-as-a-ubuntu-service/</link>
		<comments>http://www.gubatron.com/blog/2011/04/06/have-the-latest-haproxy-as-a-ubuntu-service/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 15:12:43 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2202</guid>
		<description><![CDATA[So you need to use HAProxy and you love the convenience of binary packages on repos, but when you install the version HAProxy available in the repos you realize that it is way too old for what you need. Then you download the latest HAProxy, compile it, configure it, but it&#8217;s a bit of a [...]]]></description>
			<content:encoded><![CDATA[<p>So you need to use HAProxy and you love the convenience of binary packages on repos, but when you install the version HAProxy available in the repos you realize that it is way too old for what you need.</p>
<p>Then you download the latest HAProxy, compile it, configure it, but it&#8217;s a bit of a pain in the ass to not have the convenience of having haproxy be automatically restarted as a service like those available on /etc/init.d</p>
<p><strong>This post teaches you how to have haproxy as a Ubuntu/Debian service.</strong></p>
<p>First copy or symlink this script to your /etc/init.d/ folder (you&#8217;ll need root permissions to do this)</p>
<pre class="brush: bash; title: ; notranslate">
#!/usr/bin/env bash
# haproxyd
# Script to start|stop|restart haproxy from /etc/init.d/
# By Gubatron.

HAPROXY_PATH=/path/to/haproxy-X.Y.Z
HAPROXY_DAEMON=$HAPROXY_PATH/haproxy

test -x $HAPROXY_DAEMON || exit 0

set -e

function getHaproxyPID() {
  PID=`ps aux | grep 'haproxy -f' | grep -v &quot;grep&quot; | awk '{ print $2 }'`
}

case $1 in
  start)
        echo &quot;Starting haproxy...&quot;
        $HAPROXY_DAEMON -f $HAPROXY_PATH/haproxy.cfg
        ;;
  restart)
        echo &quot;Hot restart of haproxy&quot;
        getHaproxyPID
        COMMAND=&quot;$HAPROXY_DAEMON -f $HAPROXY_PATH/haproxy.cfg -sf $PID&quot;
        echo $COMMAND
        `$COMMAND`
        ;;
  stop)
        echo &quot;Stopping haproxy&quot;
        getHaproxyPID
        COMMAND=&quot;kill -9 $PID&quot;
        echo $COMMAND
        `$COMMAND`
        ;;
  *)
        echo &quot;Usage: haproxyd {start|restart|stop}&quot; &gt;&amp;2
        exit 1
        ;;
esac

exit 0
</pre>
<p>This script, on it&#8217;s own can be used as</p>
<pre class="brush: bash; title: ; notranslate">
./haproxyd start
./haproxyd restart
./haproxyd stop
</pre>
<p>But you want this script registered on all the right runlevels of the operating system.</p>
<p>With Ubuntu/Debian there&#8217;s a utility called <a href="http://manpages.ubuntu.com/manpages/hardy/man8/update-rc.d.8.html" target="_blank">update-rc.d</a> to register /etc/init.d/ scripts very easily.</p>
<p>Once the script above is available on /etc/init.d do the following</p>
<pre class="brush: bash; title: ; notranslate">
cd /etc/init.d
sudo update-rc.d haproxyd defaults
</pre>
<p>The script should now be registered on all the right runlevels and you should be able to invoke it as a service like</p>
<pre class="brush: bash; title: ; notranslate">
sudo service haproxyd &lt;command&gt;
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F&amp;title=Have+the+latest+HAProxy+as+a+Ubuntu+Service" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F&amp;title=Have+the+latest+HAProxy+as+a+Ubuntu+Service" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F&amp;title=Have+the+latest+HAProxy+as+a+Ubuntu+Service" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F&amp;headline=Have+the+latest+HAProxy+as+a+Ubuntu+Service" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Have+the+latest+HAProxy+as+a+Ubuntu+Service&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Have+the+latest+HAProxy+as+a+Ubuntu+Service&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Have+the+latest+HAProxy+as+a+Ubuntu+Service&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Have+the+latest+HAProxy+as+a+Ubuntu+Service&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Have+the+latest+HAProxy+as+a+Ubuntu+Service&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F&amp;title=Have+the+latest+HAProxy+as+a+Ubuntu+Service&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F04%2F06%2Fhave-the-latest-haproxy-as-a-ubuntu-service%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/04/06/have-the-latest-haproxy-as-a-ubuntu-service/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NSIS CharAt Macro</title>
		<link>http://www.gubatron.com/blog/2011/03/21/nsis-charat-function-macro/</link>
		<comments>http://www.gubatron.com/blog/2011/03/21/nsis-charat-function-macro/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 18:36:30 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[charat]]></category>
		<category><![CDATA[NSIS]]></category>
		<category><![CDATA[String manipulation]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2197</guid>
		<description><![CDATA[Lord knows why the NSIS folks didn&#8217;t add a CharAt function to their API. In case you need it to parse a string, here&#8217;s a Macro that makes StrCpy work like a CharAt function To use the CharAt &#8220;function&#8221; (macro in this case), do as follows:]]></description>
			<content:encoded><![CDATA[<p>Lord knows why the NSIS folks didn&#8217;t add a CharAt function to their API.<br />
In case you need it to parse a string, here&#8217;s a Macro that makes StrCpy work like a CharAt function</p>
<pre class="brush: bash; title: ; notranslate">
;Get a character inside a string given an index.
;Usage: CharAt String Index Output
!macro CharAt InputString Index Output
 StrCpy ${Output} ${InputString} 1 ${Index}
!macroend
</pre>
<p>To use the CharAt &#8220;function&#8221; (macro in this case), do as follows:</p>
<pre class="brush: bash; title: ; notranslate">
!insertmacro CharAt &quot;Hello World!&quot; 1 $0
;$0 will have the letter 'e' inside.
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F&amp;title=NSIS+CharAt+Macro" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F&amp;title=NSIS+CharAt+Macro" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F&amp;title=NSIS+CharAt+Macro" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F&amp;headline=NSIS+CharAt+Macro" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=NSIS+CharAt+Macro&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=NSIS+CharAt+Macro&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=NSIS+CharAt+Macro&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=NSIS+CharAt+Macro&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=NSIS+CharAt+Macro&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F&amp;title=NSIS+CharAt+Macro&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F21%2Fnsis-charat-function-macro%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/03/21/nsis-charat-function-macro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get a randomly weighted key in a Map/Dictionary/Associative Array</title>
		<link>http://www.gubatron.com/blog/2011/03/15/get-a-randomly-weighted-key-in-a-mapdictionaryassociative-array/</link>
		<comments>http://www.gubatron.com/blog/2011/03/15/get-a-randomly-weighted-key-in-a-mapdictionaryassociative-array/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 23:10:46 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2193</guid>
		<description><![CDATA[Here&#8217;s a very useful function to retrieve a randomly weighted key from an associative array in PHP. Sometimes you need to fetch random elements from a collection but you need some elements to have a little more chance than others to be fetched (business rules or whatever&#8230;) It should be trivial porting this code to [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a very useful function to retrieve a randomly weighted key from an associative array in PHP.</p>
<p>Sometimes you need to fetch random elements from a collection but you need some elements to have a little more chance than others to be fetched (business rules or whatever&#8230;)</p>
<pre class="brush: php; title: ; notranslate">
srand(time()); //dont call this inside the function or you'll get same result always
function getRandomWeightedKey($weighted_elements, $default_key) {
  $weighted_ranges = array();
  $weight_offset = 0;

  //if you know weights are not gonna change you could
  //move this part of the code to another place and cache it
  //for better performance. Specially if you have a lot of weighted elements
  foreach ($weighted_elements as $key =&gt; $weight) {
    $weighted_ranges[]=array('key'=&gt;$key,
                             'range'=&gt;array(intval($weight_offset),intval($weight_offset+$weight)));
    $weight_offset += $weight;
  }

  //get a random number between the 0 and the maximum
  $r = rand(0,$weight_offset);

  foreach ($weighted_ranges as $range) {
    if ($r &gt;= $range['range'][0] &amp;&amp; $r &lt; $range['range'][1]) {
      return $range['key'];
    }
  }

  //this shouldn't happen but Mr. Justin Case.
  return $default_key;
}

//how to use it. (weights don't necessarily need to add to 100,
//but it helps me to visualize things basing weights on 100
$weights = array(&quot;a&quot; =&gt; 25, &quot;b&quot; =&gt; 25, &quot;c&quot; =&gt; 50);

$randomKey = getRandomWeightedKey($weights, &quot;c&quot;);
</pre>
<p>It should be trivial porting this code to the language of your choice. Enjoy.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F&amp;title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F&amp;title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F&amp;title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F&amp;headline=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F&amp;title=Get+a+randomly+weighted+key+in+a+Map%2FDictionary%2FAssociative+Array&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F15%2Fget-a-randomly-weighted-key-in-a-mapdictionaryassociative-array%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/03/15/get-a-randomly-weighted-key-in-a-mapdictionaryassociative-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>eclipse.ini gone after Helios update? No worries</title>
		<link>http://www.gubatron.com/blog/2011/03/05/eclipse-ini-gone-after-helios-update-no-worries/</link>
		<comments>http://www.gubatron.com/blog/2011/03/05/eclipse-ini-gone-after-helios-update-no-worries/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 09:16:32 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Gear Grinders]]></category>
		<category><![CDATA[Geeklife]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2188</guid>
		<description><![CDATA[So you had a pimped out eclipse.ini file and for some odd reason in the world, eclipse.ini is missing in action after one of the numerous updates, you try to put it where it was, but none of the options you pass it seem to have an effect. Here&#8217;s what I did After I gave [...]]]></description>
			<content:encoded><![CDATA[<p>So you had a pimped out eclipse.ini file and for some odd reason in the world, eclipse.ini is missing in action after one of the numerous updates, you try to put it where it was, but none of the options you pass it seem to have an effect.</p>
<p><strong>Here&#8217;s what I did</strong></p>
<p>After I gave up on reading the documentation on what the hell happened to eclipse.ini and why it&#8217;s not having any effect on my eclipse, I just created my own eclipse launcher.</p>
<p>Here&#8217;s what it has inside:</p>
<pre class="brush: bash; title: ; notranslate">#!/bin/bash
./eclipse -vmargs -XX:MaxPermSize=512M-Xms512m -Xmx1024m -XX:+UseParallelGC -XX:PermSize=256M
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F&amp;title=eclipse.ini+gone+after+Helios+update%3F+No+worries" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F&amp;title=eclipse.ini+gone+after+Helios+update%3F+No+worries" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F&amp;title=eclipse.ini+gone+after+Helios+update%3F+No+worries" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F&amp;headline=eclipse.ini+gone+after+Helios+update%3F+No+worries" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=eclipse.ini+gone+after+Helios+update%3F+No+worries&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=eclipse.ini+gone+after+Helios+update%3F+No+worries&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=eclipse.ini+gone+after+Helios+update%3F+No+worries&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=eclipse.ini+gone+after+Helios+update%3F+No+worries&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=eclipse.ini+gone+after+Helios+update%3F+No+worries&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F&amp;title=eclipse.ini+gone+after+Helios+update%3F+No+worries&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Feclipse-ini-gone-after-helios-update-no-worries%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/03/05/eclipse-ini-gone-after-helios-update-no-worries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Location of src.jar for JDK 1.6.0_24 on Mac OS X</title>
		<link>http://www.gubatron.com/blog/2011/03/05/new-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x/</link>
		<comments>http://www.gubatron.com/blog/2011/03/05/new-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 09:13:03 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2186</guid>
		<description><![CDATA[These Apple devs&#8230; why do you keep moving src.jar? Here&#8217;s the new location: Not there! If you don&#8217;t see src.jar there, and you&#8217;re running Mac OSX 10.6, and you did download the Java system update, you will have to go to developer.apple.com and download the &#8220;Java for Mac OS X 10.6 (10M3321) (Disk Image)&#8221; (or [...]]]></description>
			<content:encoded><![CDATA[<p>These Apple devs&#8230; why do you keep moving src.jar?</p>
<p>Here&#8217;s the new location:</p>
<pre class="brush: bash; title: ; notranslate">/Library/Java/JavaVirtualMachines/1.6.0_24-b07-330.jdk/Contents/Home/src.jar</pre>
<p><strong>Not there!</strong><br />
If you don&#8217;t see src.jar there, and you&#8217;re running Mac OSX 10.6, and you did download the Java system update, you will have to go to <a href="http://developer.apple.com">developer.apple.com</a> and download the &#8220;Java for Mac OS X 10.6 (10M3321) (Disk Image)&#8221; (or whatever is current and makes sense for your Mac OSX version)</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F&amp;title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F&amp;title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F&amp;title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F&amp;headline=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F&amp;title=New+Location+of+src.jar+for+JDK+1.6.0_24+on+Mac+OS+X&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2011%2F03%2F05%2Fnew-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2011/03/05/new-location-of-src-jar-for-jdk-1-6-0_24-on-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to convert Android GPS coordinates into X,Y coordinates.</title>
		<link>http://www.gubatron.com/blog/2010/12/30/how-to-convert-android-gps-coordinates-into-xy-coordinates/</link>
		<comments>http://www.gubatron.com/blog/2010/12/30/how-to-convert-android-gps-coordinates-into-xy-coordinates/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 19:28:22 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2142</guid>
		<description><![CDATA[Without further math bullshit about all the conversion systems, when you have a bunch of Android GPS coordinates (which are compatible with Google Earth and Google Maps), and you want to draw them on a finite 2D plane, here&#8217;s what worked for me.]]></description>
			<content:encoded><![CDATA[<p>Without further math bullshit about all the conversion systems, when you have a bunch of Android GPS coordinates (which are compatible with Google Earth and Google Maps), and you want to draw them on a finite 2D plane, here&#8217;s what worked for me.</p>
<pre class="brush: java; title: ; notranslate">
int x =  (int) ((PLANE_WIDTH/360.0) * (180 + lon));
int y =  (int) ((PLANE_HEIGHT/180.0) * (90 - lat));
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F&amp;title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F&amp;title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F&amp;title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F&amp;headline=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates.&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F&amp;title=How+to+convert+Android+GPS+coordinates+into+X%2CY+coordinates.&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F30%2Fhow-to-convert-android-gps-coordinates-into-xy-coordinates%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/12/30/how-to-convert-android-gps-coordinates-into-xy-coordinates/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Animating a game-like sky with HTML5 Canvas</title>
		<link>http://www.gubatron.com/blog/2010/12/28/animating-a-game-like-sky-with-html5-canvas/</link>
		<comments>http://www.gubatron.com/blog/2010/12/28/animating-a-game-like-sky-with-html5-canvas/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 00:01:22 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2126</guid>
		<description><![CDATA[Try it &#124; View Source Again playing a little more with HTML5 and Canvas animation. This time around the result is a little more pleasing to the eye, based on some ideas I have for a little arcade game I want to make I&#8217;ve created a gradient blue sky and clouds that move either to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gubatron.com/html5/sky.html"><img src="http://www.gubatron.com/blog/wp-content/uploads/2010/12/Screen-shot-2010-12-28-at-6.56.18-PM.png" alt="" title="Screen shot 2010-12-28 at 6.56.18 PM" width="100%"/></a><br />
<a target="_blank" href="http://www.gubatron.com/html5/sky.html">Try it</a> | <a target="_blank" href="view-source:http://www.gubatron.com/html5/sky.html">View Source</a></p>
<p>Again playing a little more with HTML5 and Canvas animation.</p>
<p>This time around the result is a little more pleasing to the eye, based on some ideas I have for a little arcade game I want to make I&#8217;ve created a gradient blue sky and clouds that move either to the left or right at different speeds.</p>
<p>If I&#8217;m correct, I don&#8217;t think there is a way to move something that&#8217;s already been painted in the canvas, therefore I made the Clouds a &#8220;Cloud&#8221; object (I used to think I could paint a vector based graphic and then manipulate it in the canvas, but I think now the HTML Canvas is more of a place where you paint and you can&#8217;t really manipulate what&#8217;s already been painted). Each cloud is nothing but an array of white circles. The program initializes several clouds randomly and then with an interval call it repaints the gradient sky, and each one of the clouds, then moves them, to repeat the cycle over and over.</p>
<p>I&#8217;m not sure if game devs out there are doing this or if there is a way to have the canvas move vector objects in a more efficient way than repainting the whole thing from scratch on every frame. At this point the animation looks very smooth but nothing except clouds moving is happening.</p>
<p>I hope in your comments I&#8217;ll find some answers as if this is the way to animate your game, meaning, keeping object representations of everything that&#8217;s been painted in memory, and repainting the canvas on every frame of the game cycle.</p>
<p>My goal (which I don&#8217;t know if is correct) is to do everything within a single CANVAS object. I&#8217;ve seen though how some people still like to play around with the DOM Tree, I&#8217;m not sure if adding and manipulating the DOM Tree is the correct way to procede here, I think it&#8217;d also be a nightmare to handle things when it comes to focus, or converting coordinates from one canvas to another and have everything make sense.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F&amp;title=Animating+a+game-like+sky+with+HTML5+Canvas" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F&amp;title=Animating+a+game-like+sky+with+HTML5+Canvas" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F&amp;title=Animating+a+game-like+sky+with+HTML5+Canvas" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F&amp;headline=Animating+a+game-like+sky+with+HTML5+Canvas" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Animating+a+game-like+sky+with+HTML5+Canvas&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Animating+a+game-like+sky+with+HTML5+Canvas&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Animating+a+game-like+sky+with+HTML5+Canvas&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Animating+a+game-like+sky+with+HTML5+Canvas&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Animating+a+game-like+sky+with+HTML5+Canvas&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F&amp;title=Animating+a+game-like+sky+with+HTML5+Canvas&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F12%2F28%2Fanimating-a-game-like-sky-with-html5-canvas%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/12/28/animating-a-game-like-sky-with-html5-canvas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jconsole: &#8220;Connection Failed: Retry?&#8221; #SOLVED #java #jmx</title>
		<link>http://www.gubatron.com/blog/2010/11/21/jconsole-connection-failed-retry-solved-java-jmx/</link>
		<comments>http://www.gubatron.com/blog/2010/11/21/jconsole-connection-failed-retry-solved-java-jmx/#comments</comments>
		<pubDate>Sun, 21 Nov 2010 18:24:58 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2105</guid>
		<description><![CDATA[So you wrote a piece of server software and you found out about JMX and the jconsole tool to remotely monitor all sorts of interesting metrics remotely, all without adding a single line of code to your project. Say you want to run it the simplest way possible with no authentication, the tutorial says that [...]]]></description>
			<content:encoded><![CDATA[<p>So you wrote a piece of server software and you found out about JMX and the jconsole tool to remotely monitor all sorts of interesting metrics remotely, all without adding a single line of code to your project.</p>
<p>Say you want to run it the simplest way possible with no authentication, the <a href="http://download.oracle.com/javase/1.5.0/docs/guide/management/jconsole.html">tutorial</a> says that<strong> these are the options you need to pass to the remote virtual machine to enable JMX remote monitoring on some port</strong> (let&#8217;s put 9595 for illustrative purposes).</p>
<pre class="brush: bash; title: ; notranslate">
-Dcom.sun.management.jmxremote.port=9595',
-Dcom.sun.management.jmxremote.ssl=false',
-Dcom.sun.management.jmxremote.authenticate=false
</pre>
<p>right?</p>
<p>But when you open your jconsole on your local computer to connect to the remote server&#8230;</p>
<pre class="brush: bash; title: ; notranslate">
jconsole myserver.com:9696
</pre>
<p>You get this fucking error no matter what you do.<br />
<img src="http://www.gubatron.com/blog/wp-content/uploads/2010/11/jconsole_connection_failed.png" alt="" title="jconsole_connection_failed" width="409" height="158" class="alignnone size-full wp-image-2106" /></p>
<p>You&#8217;re <strong>just missing one more option</strong> they must have forgotten to mention in the retard <a href="http://download.oracle.com/javase/1.5.0/docs/guide/management/jconsole.html">tutorial</a> at oracle.com</p>
<p>(let&#8217;s use IP address 72.14.204.147 as the remote server IP)</p>
<pre class="brush: bash; title: ; notranslate">
-Dcom.sun.management.jmxremote.port=9595',
-Dcom.sun.management.jmxremote.ssl=false',
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=72.14.204.147 #ip of the remote machine, yes the ip, not the name
</pre>
<p><strong>Voilà</strong></p>
<p><a href="http://www.gubatron.com/blog/wp-content/uploads/2010/11/jconsole_working.png"><img src="http://www.gubatron.com/blog/wp-content/uploads/2010/11/jconsole_working.png" alt="" title="jconsole_working" width="100%" class="alignnone size-full wp-image-2107" /></a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F&amp;title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F&amp;title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F&amp;title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F&amp;headline=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F&amp;title=jconsole%3A+%22Connection+Failed%3A+Retry%3F%22+%23SOLVED+%23java+%23jmx&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F21%2Fjconsole-connection-failed-retry-solved-java-jmx%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/11/21/jconsole-connection-failed-retry-solved-java-jmx/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Mercurial for Subversion Expats: Merging remote changes. &#8220;abort: push creates new remote heads!&#8221;</title>
		<link>http://www.gubatron.com/blog/2010/11/14/mercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads/</link>
		<comments>http://www.gubatron.com/blog/2010/11/14/mercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 09:54:23 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2087</guid>
		<description><![CDATA[Commit anywhere/anytime with Mercurial So you have been using subversion for the past few years and now your team has decided to move on to Mercurial for all the benefits. Two or more people are working on the same branch and they&#8217;re pushing code to the main copy of the repository before you&#8217;re done with [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm5.static.flickr.com/4090/5172698880_71f475cda8.jpg"/><br />
Commit anywhere/anytime with Mercurial</p>
<p>So you have been using subversion for the past few years and now your team has decided to move on to Mercurial for all the benefits. Two or more people are working on the same branch and they&#8217;re pushing code to the main copy of the repository before you&#8217;re done with your changes.</p>
<p>In the Subversion world, if you tried to commit in this same situation you&#8217;d get an error saying that your repository checkout is not up to date, so you&#8217;d fix this by doing:</p>
<pre class="brush: bash; title: ; notranslate">
$ svn up #gets the latest changes from the repo and it tries to merge all remote changes
$ # ... solve any conflicts if they arise.
$ svn ci -m &quot;my commit message&quot; #push your latest changes to the main repo.
</pre>
<p>In Mercurial it&#8217;s a little bit longer</p>
<pre class="brush: bash; title: ; notranslate">
$ hg ci -m &quot;my local changes&quot;
$ hg pull #this brings the latest version of the repo, but doesn't change the state of your files.
$ hg merge #when you're ready, you merge the changes
</pre>
<p><strong>If at this point you try to push</strong>, you will get the following error</p>
<pre class="brush: bash; title: ; notranslate">
$ hg push
pushing to https://user@server.com/company/project
searching for changes
abort: push creates new remote heads!
(did you forget to merge? use push -f to force)
</pre>
<p>first, ignore the &#8220;push -f to force&#8221;, they should remove that message and put something like</p>
<pre class="brush: bash; title: ; notranslate">
(did you forget to merge and commit?)
</pre>
<p>After a lot of thinking I was doing something wrong with the merge, I realized that before pushing you have to commit your merge locally as well, makes sense, so the whole sequence should be like this instead:</p>
<pre class="brush: bash; title: ; notranslate">
$ hg ci -m &quot;my local changes&quot; #same as 'hg commit'
$ hg pull #this brings the latest version of the repo, but doesn't change the state of your files.
$ hg merge #when you're ready, you merge the changes
$ hg ci -m &quot;merging latest changes from repository&quot;
$ hg push
pushing to https://user@server.com/company/project
searching for changes
http authorization required
realm: Bitbucket.org HTTP
user: gubatron
password:
adding changesets
adding manifests
adding file changes
added 2 changesets with 1 changes to 1 files
bb/acl: gubatron is allowed. accepted payload.
</pre>
<p>So, yes, its a little more work to merge and commit, but remember that you&#8217;re working now on a distributed fashion and you have to think a little bit differently, you gotta merge locally, fix any conflicts if they arise, commit the changes and push them. In exchange you don&#8217;t get to deal with lots of .svn folders, no single point of failure (one remote repo that could go down and leave all developers without version control until it&#8217;s back up), and super easy branching on a single folder, no need to checkout branches and be writing down revision numbers.</p>
<p>Just remember that pulls don&#8217;t change your local changes unless you explicitly ask to do so by invoking <strong>hg merge; hg commit</strong>, which would be the equivalent (at least I see it like this) to <strong>svn up</strong></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F&amp;title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F&amp;title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F&amp;title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F&amp;headline=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F&amp;title=Mercurial+for+Subversion+Expats%3A+Merging+remote+changes.+%22abort%3A+push+creates+new+remote+heads%21%22&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F11%2F14%2Fmercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/11/14/mercurial-for-subversion-expats-merging-remote-changes-abort-push-creates-new-remote-heads/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Android: How to obtain the WiFi&#8217;s corresponding NetworkInterface</title>
		<link>http://www.gubatron.com/blog/2010/09/19/android-programming-how-to-obtain-the-wifis-corresponding-networkinterface/</link>
		<comments>http://www.gubatron.com/blog/2010/09/19/android-programming-how-to-obtain-the-wifis-corresponding-networkinterface/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 16:33:16 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[coding]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2063</guid>
		<description><![CDATA[Let&#8217;s say for some odd reason in the world you do need to get the corresponding NetworkInterface object of the Wifi on your android, in my case I needed to have my WiFi device send multicast packets, and I wanted my MulticastSocket to only send packets through the WiFi device (not 3g, or maybe even [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s say for some odd reason in the world you do need to get the corresponding NetworkInterface object of the Wifi on your android, in my case I needed to have my WiFi device send multicast packets, and I wanted my MulticastSocket to only send packets through the WiFi device (not 3g, or maybe even ethernet). The android API does not provide functionality to know what &#8220;NetworkInterface&#8221; your WiFi is using.</p>
<p>Here&#8217;s a solution proven in tens of different android phones, seems to work 100%.</p>
<pre class="brush: java; title: ; notranslate">
public static NetworkInterface getWifiNetworkInterface(WifiManager manager) {

    Enumeration&lt;NetworkInterface&gt; interfaces = null;
    try {
        //the WiFi network interface will be one of these.
        interfaces = NetworkInterface.getNetworkInterfaces();
    } catch (SocketException e) {
        return null;
    }

    //We'll use the WiFiManager's ConnectionInfo IP address and compare it with
    //the ips of the enumerated NetworkInterfaces to find the WiFi NetworkInterface.

    //Wifi manager gets a ConnectionInfo object that has the ipAdress as an int
    //It's endianness could be different as the one on java.net.InetAddress
    //maybe this varies from device to device, the android API has no documentation on this method.
    int wifiIP = manager.getConnectionInfo().getIpAddress();

    //so I keep the same IP number with the reverse endianness
    int reverseWifiIP = Integer.reverseBytes(wifiIP); 		

    while (interfaces.hasMoreElements()) {

        NetworkInterface iface = interfaces.nextElement();

        //since each interface could have many InetAddresses...
        Enumeration&lt;InetAddress&gt; inetAddresses = iface.getInetAddresses();
        while (inetAddresses.hasMoreElements()) {
            InetAddress nextElement = inetAddresses.nextElement();
            int byteArrayToInt = byteArrayToInt(nextElement.getAddress(),0);

            //grab that IP in byte[] form and convert it to int, then compare it
            //to the IP given by the WifiManager's ConnectionInfo. We compare
            //in both endianness to make sure we get it.
            if (byteArrayToInt == wifiIP || byteArrayToInt == reverseWifiIP) {
                return iface;
            }
        }
    }

    return null;
}

public static final int byteArrayToInt(byte[] arr, int offset) {
    if (arr == null || arr.length - offset &lt; 4)
        return -1;

    int r0 = (arr[offset] &amp; 0xFF) &lt;&lt; 24;
    int r1 = (arr[offset + 1] &amp; 0xFF) &lt;&lt; 16;
    int r2 = (arr[offset + 2] &amp; 0xFF) &lt;&lt; 8;
    int r3 = arr[offset + 3] &amp; 0xFF;
    return r0 + r1 + r2 + r3;
}
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F&amp;title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F&amp;title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F&amp;title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F&amp;headline=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F&amp;title=Android%3A+How+to+obtain+the+WiFi%27s+corresponding+NetworkInterface&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F09%2F19%2Fandroid-programming-how-to-obtain-the-wifis-corresponding-networkinterface%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/09/19/android-programming-how-to-obtain-the-wifis-corresponding-networkinterface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Map function in Java</title>
		<link>http://www.gubatron.com/blog/2010/08/31/map-function-in-java/</link>
		<comments>http://www.gubatron.com/blog/2010/08/31/map-function-in-java/#comments</comments>
		<pubDate>Tue, 31 Aug 2010 06:46:54 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2047</guid>
		<description><![CDATA[I read on some email signature something along the lines of: &#8220;If I had a dollar for every for(int i=0; i < size; i++) { ... } I've written I'd be rich" After coding on Android and learning about some of the tips for performance, like "With an ArrayList, a hand-written counted loop is about [...]]]></description>
			<content:encoded><![CDATA[<p>I read on some email signature something along the lines of:<br />
&#8220;If I had a dollar for every for(int i=0; i < size; i++) { ... } I've written I'd be rich"</p>
<p>After coding on Android and learning about some of the tips for performance, like<br />
"With an ArrayList, a hand-written counted loop is about 3x faster"</p>
<p><strong>If you do use ArrayLists a lot you</strong> then have that tip in the back of your head and you end up with a lot of code like the following:</p>
<pre class="brush: java; title: ; notranslate">
List&lt;T&gt; myList = ... ;
int size = myList.size();
for (int i=0; i &lt; size; i++) {
  T elem = myList.get(i);
  //do something with elem
}
</pre>
<p>Eventually there was a moment when I said, I need a freaking map function, I&#8217;m sick of this little pattern, surprisingly I couldn&#8217;t find a map() function anywhere on the java collection framework. So I went and did this.</p>
<p><strong>Warning</strong>: These mapping utilities are meant only for Lists with RandomAccess capabilities (.get(i) happens in constant time). Do not use with LinkedList or other lists that don&#8217;t implement RandomAccess, otherwise you&#8217;ll end up with up to O(n^2) times. Thanks to Roger Kapsi for noticing this issue. [you can now tell how much we like to use ArrayList]</p>
<pre class="brush: java; title: ; notranslate">
//what I think would be the equivalent of a lambda or closure in Python...
public interface MapFunction&lt;T&gt; {
   public void map(T t);
}
</pre>
<p>And then on one of my utils classes I added a static method map that looks like this:</p>
<pre class="brush: java; title: ; notranslate">
public static &lt;T&gt; void map(List&lt;T&gt; list, MapFunction&lt;T&gt; mapFunction) {
int size=list.size();
   for (int i=0; i &lt; size; i++) {
      mapFunction.map(list.get(i));
   }
}
</pre>
<p>So now, everytime I need to iterate over a whole list and do something to each element it&#8217;s a lot cleaner</p>
<pre class="brush: java; title: ; notranslate">
//let's serialize all the messages...
List&lt;Message&gt; messages = ...;
Utils.map(messages, new MapFunction&lt;Message&gt; {
   public void map(Message message) {
      Engine.INSTANCE.SERIALIZER.save(message);
   }
});
</pre>
<p>done deal.</p>
<p><strong>Update</strong></p>
<p>Here&#8217;s another Map utility that let&#8217;s your map() function know about the index of your current element. You may have to treat certain elements differently based on their position in the list.<br />
This time your function takes a &#8220;IndexMapFunction<T>&#8221; implementation.</p>
<pre class="brush: java; title: ; notranslate">
public static &lt;T&gt; void map(List&lt;T&gt; list, IndexedMapFunction&lt;T&gt; mapFunction) {
		int size = list.size();
		for (int i = 0; i &lt; size; i++) {
			mapFunction.map(i, list.get(i));
		}
}
</pre>
<p>The interface for IndexedMapFunction looks like this</p>
<pre class="brush: java; title: ; notranslate">
public interface IndexedMapFunction&lt;T&gt; {
	public void map(int i, T obj);
}
</pre>
<p>In your implementation of &#8220;map(int i, T obj)&#8221;, &#8220;i&#8221; represents the position of the element being treated. You could do different things depending on what position of the List you are. For example, you could know if you&#8217;re at the beggining or end of the list, or maybe you could other data structure telling you things about some positions in the list in question.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F&amp;title=Map+function+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F&amp;title=Map+function+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F&amp;title=Map+function+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F&amp;headline=Map+function+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Map+function+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Map+function+in+Java&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Map+function+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Map+function+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Map+function+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F&amp;title=Map+function+in+Java&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F08%2F31%2Fmap-function-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/08/31/map-function-in-java/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Reference: Passing functions as parameters in C</title>
		<link>http://www.gubatron.com/blog/2010/07/18/reference-passing-functions-as-parameters-in-c/</link>
		<comments>http://www.gubatron.com/blog/2010/07/18/reference-passing-functions-as-parameters-in-c/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 17:42:18 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2029</guid>
		<description><![CDATA[This worked fine on my gcc compiler (MacOSX 10.5), no need to even use * or &#038; operators when defining the parameters or when passing the functions as parameters.]]></description>
			<content:encoded><![CDATA[<pre class="brush: cpp; title: ; notranslate">
#include &lt;stdio.h&gt;
//Example to show how to pass
//functions as parameters in C.                                               

//simple function that returns the sum of two ints
int sum(int i, int j) {
  return i+j;
}

//simple function that prints a char*
void printSomething(char* something) {
  printf(&quot;%s\n&quot;,something);
}

//function that takes
// 2 ints
// 1 char*
// one function that returns an int and takes two ints
// one function that takes a char* returns nothing
void functionThatTakesOtherFunctions(int a,
                int b,
                char* name,
                int (functionA) (int,int),
                void (functionB) (char*)) {
  printf(&quot;Function A: %d\n&quot;,functionA(a,b));
  functionB(name);
}

int main(void) {
  //we pass the first two functions as parameters
  functionThatTakesOtherFunctions(3,4,
                                  &quot;John Doe&quot;,
                                  sum,
                                  printSomething);
  return 0;
}
</pre>
<p>This worked fine on my gcc compiler (MacOSX 10.5), no need to even use * or &#038; operators when defining the parameters or when passing the functions as parameters.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F&amp;title=Reference%3A+Passing+functions+as+parameters+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F&amp;title=Reference%3A+Passing+functions+as+parameters+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F&amp;title=Reference%3A+Passing+functions+as+parameters+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F&amp;headline=Reference%3A+Passing+functions+as+parameters+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Reference%3A+Passing+functions+as+parameters+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Reference%3A+Passing+functions+as+parameters+in+C&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Reference%3A+Passing+functions+as+parameters+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Reference%3A+Passing+functions+as+parameters+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Reference%3A+Passing+functions+as+parameters+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F&amp;title=Reference%3A+Passing+functions+as+parameters+in+C&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F07%2F18%2Freference-passing-functions-as-parameters-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/07/18/reference-passing-functions-as-parameters-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>startKeychain &#8211; bash utility to start ssh-agent</title>
		<link>http://www.gubatron.com/blog/2010/06/03/startkeychain-bash-utility-to-start-ssh-agent/</link>
		<comments>http://www.gubatron.com/blog/2010/06/03/startkeychain-bash-utility-to-start-ssh-agent/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 14:36:31 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[keys]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[ssh-agent]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1998</guid>
		<description><![CDATA[For my (and your) future reference, here&#8217;s a function to put on your .bashrc or .bash_profile, you can invoke it later at any time to start/re-start your ssh-agent. Then at any time, the &#8220;command&#8221; startKeychain will be available on your command line. Output should look something like this: Comments are welcome to improve it, I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.gubatron.com/blog/wp-content/uploads/2010/06/ssh-agent.jpg" class="alignleft"/>For my (and your) future reference, here&#8217;s a function to put on your .bashrc or .bash_profile, you can invoke it later at any time to start/re-start your ssh-agent.<br />
<br clear="all"/></p>
<pre class="brush: bash; title: ; notranslate">
function startKeychain {
    killall ssh-agent
    rm ~/.keychain/*
    keychain id_rsa
    HOSTNAME=`hostname`
    source ~/.keychain/${HOSTNAME}-sh
}
</pre>
<p>Then at any time, the &#8220;command&#8221; <strong>startKeychain</strong> will be available on your command line.</p>
<p>Output should look something like this:</p>
<pre class="brush: bash; title: ; notranslate">

gubatron@gubatron-desktop:~$ startKeychain 

KeyChain 2.6.8; http://www.gentoo.org/proj/en/keychain/
Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL

 * Initializing /home/gubatron/.keychain/gubatron-desktop-sh file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-csh file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-fish file...
 * Starting ssh-agent
 * Initializing /home/gubatron/.keychain/gubatron-desktop-sh-gpg file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-csh-gpg file...
 * Initializing /home/gubatron/.keychain/gubatron-desktop-fish-gpg file...
 * Starting gpg-agent
 * Adding 1 ssh key(s)...
Identity added: /home/gubatron/.ssh/id_rsa (/home/gubatron/.ssh/id_rsa)
</pre>
<p>Comments are welcome to improve it, I&#8217;m not an ssh-agent expert, but this seems to do the work.</p>
<p>[SOLVED] Issue with KDE 4.4.2 and Dolphin always asking my ssh passwords whenever I browsed folder I checked out from a remote subversion repository.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F&amp;title=startKeychain+-+bash+utility+to+start+ssh-agent" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F&amp;title=startKeychain+-+bash+utility+to+start+ssh-agent" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F&amp;title=startKeychain+-+bash+utility+to+start+ssh-agent" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F&amp;headline=startKeychain+-+bash+utility+to+start+ssh-agent" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=startKeychain+-+bash+utility+to+start+ssh-agent&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=startKeychain+-+bash+utility+to+start+ssh-agent&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=startKeychain+-+bash+utility+to+start+ssh-agent&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=startKeychain+-+bash+utility+to+start+ssh-agent&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=startKeychain+-+bash+utility+to+start+ssh-agent&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F&amp;title=startKeychain+-+bash+utility+to+start+ssh-agent&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F06%2F03%2Fstartkeychain-bash-utility-to-start-ssh-agent%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/06/03/startkeychain-bash-utility-to-start-ssh-agent/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>[SOLVED] Eclipse can&#8217;t see my Android Device on Ubuntu</title>
		<link>http://www.gubatron.com/blog/2010/05/28/solved-eclipse-cant-see-my-android-device-on-ubuntu/</link>
		<comments>http://www.gubatron.com/blog/2010/05/28/solved-eclipse-cant-see-my-android-device-on-ubuntu/#comments</comments>
		<pubDate>Fri, 28 May 2010 05:29:34 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[eclipse]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1939</guid>
		<description><![CDATA[Are you seeing this on eclipse when you plug your Android device to your Ubuntu box? Serial Number: ?????????? AVD Name: N/A Target: unknown State: ?? Here&#8217;s the solution: 1. Create a script to fix this next time it happens, let&#8217;s call it &#8220;android_device_reset&#8221; and save it on a folder contained on your $PATH environment [...]]]></description>
			<content:encoded><![CDATA[<p>Are you seeing this on eclipse when you plug your Android device to your Ubuntu box?</p>
<p>Serial Number: ??????????<br />
AVD Name: N/A<br />
Target: unknown<br />
State: ??</p>
<p><img src="http://farm4.static.flickr.com/3400/4618529545_4d922897b4_o.png" width="100%"/></p>
<p>Here&#8217;s the solution:</p>
<p>1. Create a script to fix this next time it happens, let&#8217;s call it &#8220;android_device_reset&#8221; and save it on a folder contained on your $PATH environment variable.</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
# android_device_reset script
sudo adb kill-server
sudo service udev stop
sudo adb start-server
sudo adb devices
</pre>
<p>Save it and make it executable</p>
<pre class="brush: bash; title: ; notranslate">chmod +x android_device_reset</pre>
<p>2. Open this file <strong>/etc/udev/rules.d/51-android.rules</strong></p>
<p>Make sure it looks something like this</p>
<pre class="brush: bash; title: ; notranslate">
SUBSYSTEMS==&quot;usb&quot;, SYSFS{idVendor}==&quot;0bb4&quot;, MODE==&quot;0666&quot;
SUBSYSTEMS==&quot;usb&quot;, SYSFS{idVendor}==&quot;22b8&quot;, MODE==&quot;0666&quot;
</pre>
<p>Each line represents a different android device. If you have just one, the file should be one line long.</p>
<p>On that example I&#8217;ve configured the rules for a Motorola Droid and a Nexus One.<br />
If you need to know the idVendor numbers for your Android device go here<br />
<a href="http://developer.android.com/guide/developing/device.html#VendorIds" rel="nofollow">developer.android.com/guide/developing/device.html#VendorIds</a></p>
<p>3. Whenever the problem happens, just open a terminal and type</p>
<pre class="brush: bash; title: ; notranslate">android_device_reset</pre>
<p>It&#8217;ll ask you for your password, only administrative users will be able to execute the script.</p>
<p>Hope this helps.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F&amp;title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F&amp;title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F&amp;title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F&amp;headline=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F&amp;title=%5BSOLVED%5D+Eclipse+can%27t+see+my+Android+Device+on+Ubuntu&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F28%2Fsolved-eclipse-cant-see-my-android-device-on-ubuntu%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/05/28/solved-eclipse-cant-see-my-android-device-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>How many lines of code does it take to create the Android OS?</title>
		<link>http://www.gubatron.com/blog/2010/05/23/how-many-lines-of-code-does-it-take-to-create-the-android-os/</link>
		<comments>http://www.gubatron.com/blog/2010/05/23/how-many-lines-of-code-does-it-take-to-create-the-android-os/#comments</comments>
		<pubDate>Sun, 23 May 2010 22:06:17 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[lines of code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1978</guid>
		<description><![CDATA[This is a report done on all the projects that make up for the android project, my copy of it is synced as of May 23rd 2010, 6pm Update It seems like this post got some attention on Reddit, YCombinator news and other sites on monday. I hadn&#8217;t noticed until today, so here are some [...]]]></description>
			<content:encoded><![CDATA[<p>This is a report done on all the projects that make up for the android project, my copy of it is synced as of May 23rd 2010, 6pm<br />
<span id="more-1978"></span></p>
<pre class="brush: bash; title: ; notranslate">
--------------------------------------------------------------------------------
Language                      files          blank        comment           code
--------------------------------------------------------------------------------
XML                            4130          26919          62996        3044624
C                              7191         494387         685731        2826741
Java                          16473         423278         986294        2084883
C++                            5623         349754         385625        1754053
C/C++ Header                  12278         300773         653608        1153456
HTML                           2325          13539          14681         348935
Bourne Shell                    501          45684          46947         317410
Javascript                     1717          41901          76306         208012
Assembly                       1704          18732          51392          96700
D                              2181          16936             24          59142
m4                              116           6026           1813          49502
Perl                            221           8189           8246          40058
Python                          236           9805          14225          38852
make                            381           6844           3837          37059
IDL                             421           3128              0          24181
Objective C                      93           2804           3371          10032
yacc                             15           1300            742           9660
CSS                              42           1760            617           8566
Teamcenter def                   41            631             95           5430
C#                               93            863            537           5283
Bourne Again Shell               99            569           1643           3784
lex                              21            776            754           3492
Expect                           20            105            168           2170
Ada                              10            599            560           1681
Ruby                             14            393            228           1433
XSLT                              8            105            110           1328
XSD                               7            182            359           1048
Pascal                            4            218            200            985
DOS Batch                        34            252            399            911
awk                              14             92            198            899
DTD                               9             66             42            289
sed                               9             32            143            277
Korn Shell                        1             39             46            223
Lisp                              2             32              5            144
MSBuild scripts                   1              1              0            140
NAnt scripts                      2             10              0             89
ASP.Net                           3              5              0             76
YAML                              6             27             42             66
SQL                               1              5              0             21
PHP                               1              0              0              3
--------------------------------------------------------------------------------
SUM:                          56048        1776761        3001984       12141638
--------------------------------------------------------------------------------
</pre>
<p><strong>Update</strong></p>
<p>It seems like this post got some attention on Reddit, YCombinator news and other sites on monday. I hadn&#8217;t noticed until today, so here are some answers to many of the FAQs about the post.</p>
<p>Yes it was done using <strong><a href="http://cloc.sourceforge.net/">cloc</a></strong>. Don&#8217;t shoot me I&#8217;m just the messenger.</p>
<p>It was run at the base folder of the entire Android OS source checkout, so yes it will include sample and tests I suppose.</p>
<p>C#, Ada, Objective-C? I also thought the same&#8230; It&#8217;s probably worth the try doing a few finds and greps to see if this is true, again I just posted the output of cloc, I didn&#8217;t intend to make this a scientific paper, just a fun and curious post to get a rough number on the lines of code, that breakdown was just icing on the cake for me (as inaccurate as it maybe)</p>
<p><strong>Update</strong><br />
This post is now being referenced in Wikipedia! on the &#8220;<a href="http://en.wikipedia.org/wiki/Android_(operating_system)#cite_note-14">Android (operating system)</a>&#8221; article.</p>
<p><strong>About Gubatron &#038; Android</strong><br />
Ever since the iPhone OS handicapped millions of smartphone devices with its draconian laws, I started looking more and more seriously at Android as THE platform for every non-iPhone device coming to the mobile and TV space. Now I&#8217;m part of the developer team of <a href="http://frostwire.com/android" target="_blank">FrostWire for Android</a>, an application that exploits all the power of the device and the freedoms of the platform to allow people to connect and share.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F&amp;title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F&amp;title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F&amp;title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F&amp;headline=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F&amp;title=How+many+lines+of+code+does+it+take+to+create+the+Android+OS%3F&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F23%2Fhow-many-lines-of-code-does-it-take-to-create-the-android-os%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/05/23/how-many-lines-of-code-does-it-take-to-create-the-android-os/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Droid vs Nexus 1: Who can calculate MD5 faster?</title>
		<link>http://www.gubatron.com/blog/2010/05/21/droid-vs-nexus-1-who-can-calculate-md5-faster/</link>
		<comments>http://www.gubatron.com/blog/2010/05/21/droid-vs-nexus-1-who-can-calculate-md5-faster/#comments</comments>
		<pubDate>Fri, 21 May 2010 05:25:18 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[benchmark]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1928</guid>
		<description><![CDATA[Nexus 1 indeed. 17 files get their MD5 calculated on the Droid and 17 files get their MD5 hash calculated on the Nexus 1 Nexus 1 pwns. Here&#8217;s the code in case you&#8217;re curious. And here&#8217;s how we do the MD5]]></description>
			<content:encoded><![CDATA[<p>Nexus 1 indeed.</p>
<p><img src="http://farm4.static.flickr.com/3399/4619137368_6ddd6c29cc_o.png" width="100%"/><br />
17 files get their MD5 calculated on the Droid</p>
<p><img src="http://farm5.static.flickr.com/4068/4619137390_359c4da1e5_o.png" width="100%"/><br />
and 17 files get their MD5 hash calculated on the Nexus 1</p>
<p>Nexus 1 pwns.</p>
<p>Here&#8217;s the code in case you&#8217;re curious.</p>
<pre class="brush: java; title: ; notranslate">
	public void onClick(View v) {
                                _logTextView.setText(&quot;MD5 Benchmark on &quot; + Build.DEVICE + &quot;\n\n&quot;);
				if (GlobalVariables.APP_CONTEXT == null)
					GlobalVariables.APP_CONTEXT = getApplicationContext();

				List&lt;FileDescriptor&gt; sharedAudioFiles = Engine.INSTANCE.LIBRARIAN.getSharedAudioFiles(0, 17);
				for (FileDescriptor fs: sharedAudioFiles) {
					long start = 0;
					String md5 = null;
					long length = 0;
					try {
						start = System.currentTimeMillis();
						File f = new File(fs.path);
						length = f.length();
						md5 = FrostWireUtils.getMD5(f);

					} catch (Exception e) { }
					long time = System.currentTimeMillis() - start;
					_logTextView.append(FrostWireUtils.getBytesInHuman(length) + &quot; in &quot; + time + &quot; ms @ &quot; + (length/(double) time)*1000 + &quot; b/s\n&quot;);
				}
			}
</pre>
<p>And here&#8217;s how we do the MD5 </p>
<pre class="brush: java; title: ; notranslate">
	public final static String getMD5(File f) throws Exception {
		MessageDigest m = MessageDigest.getInstance(&quot;MD5&quot;);

		byte[] buf = new byte[65536];
		int num_read;

		InputStream in = new BufferedInputStream(new FileInputStream(f));

		while ((num_read = in.read(buf)) != -1) {
			m.update(buf, 0, num_read);
		}

		String result = new BigInteger(1, m.digest()).toString(16);

		// pad with zeros if until it's 32 chars long.
		if (result.length() &lt; 32) {
			StringBuffer padding = new StringBuffer();
			int paddingSize = 32 - result.length();
			for (int i = 0; i &lt; paddingSize; i++)
				padding.append(&quot;0&quot;);

			result = padding.toString() + result;
		}

		return result;
	}
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F&amp;title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F&amp;title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F&amp;title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F&amp;headline=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F&amp;title=Droid+vs+Nexus+1%3A+Who+can+calculate+MD5+faster%3F&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F21%2Fdroid-vs-nexus-1-who-can-calculate-md5-faster%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/05/21/droid-vs-nexus-1-who-can-calculate-md5-faster/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Think you&#8217;re in a big project?</title>
		<link>http://www.gubatron.com/blog/2010/05/18/think-youre-in-a-big-project/</link>
		<comments>http://www.gubatron.com/blog/2010/05/18/think-youre-in-a-big-project/#comments</comments>
		<pubDate>Tue, 18 May 2010 06:25:50 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1922</guid>
		<description><![CDATA[Recently I became curious on how many lines of code a huge open source project I contribute to has on what languages. I found a tool called &#8220;cloc&#8221; on sourceforge, check out the results and I dare you to think again if you think you&#8217;re in a big project. If you want to count lines [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I became curious on how many lines of code a huge open source project I contribute to has on what languages. I found a tool called &#8220;cloc&#8221; on sourceforge, check out the results and I dare you to think again if you think you&#8217;re in a big project.<br />
<span id="more-1922"></span></p>
<pre class="brush: bash; title: ; notranslate">
$ cloc .
   11642 text files.
   11383 unique files.
   42549 files ignored.

http://cloc.sourceforge.net v 1.51  T=193.0 s (56.3 files/s, 11577.2 lines/s)
--------------------------------------------------------------------------------
Language                      files          blank        comment           code
--------------------------------------------------------------------------------
Java                           9259         309032         469814        1123643
HTML                           1079          24512          16894         196291
XML                             205           3152           4552          34709
C++                              62           2923           3738          16397
C/C++ Header                    103           1874           4249           6685
C                                17            842            729           2498
XSD                              15            132            124           1358
Perl                              6            301            752           1323
Objective C                      10            249            237            798
DOS Batch                        19            118             65            704
CSS                              15            184            171            675
make                             14            206            355            623
Bourne Shell                     23            154            172            601
XSLT                              4            134            298            553
Bourne Again Shell               12             69            141            426
Python                            9            126             79            416
Javascript                        7             42             21            188
IDL                               1             14              0             52
Teamcenter def                    1              0              0              9
--------------------------------------------------------------------------------
SUM:                          10861         344064         502391        1387949
--------------------------------------------------------------------------------
</pre>
<p>If you want to count lines of code for your projects give <a href="http://cloc.sourceforge.net">cloc a try</a>.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F&amp;title=Think+you%27re+in+a+big+project%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F&amp;title=Think+you%27re+in+a+big+project%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F&amp;title=Think+you%27re+in+a+big+project%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F&amp;headline=Think+you%27re+in+a+big+project%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Think+you%27re+in+a+big+project%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Think+you%27re+in+a+big+project%3F&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Think+you%27re+in+a+big+project%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Think+you%27re+in+a+big+project%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Think+you%27re+in+a+big+project%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F&amp;title=Think+you%27re+in+a+big+project%3F&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F18%2Fthink-youre-in-a-big-project%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/05/18/think-youre-in-a-big-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[SCREENCAST] How to do Unit Testing on Android with Eclipse</title>
		<link>http://www.gubatron.com/blog/2010/05/02/how-to-do-unit-testing-on-android-with-eclipse/</link>
		<comments>http://www.gubatron.com/blog/2010/05/02/how-to-do-unit-testing-on-android-with-eclipse/#comments</comments>
		<pubDate>Sun, 02 May 2010 07:58:38 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Screencasts]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1913</guid>
		<description><![CDATA[I was going to make a tutorial, but then I figured that making a video would be a much better way to show this. As for the code that you could grab from a tutorial, there&#8217;s a link at the end of the post with all the code shown in the video demo. The video [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gubatron.com/blog/2010/05/02/how-to-do-unit-testing-on-android-with-eclipse/#more-1913"><img src="http://androinica.com/wp-content/uploads/2008/10/android_logo.png" width="150" height="150" class="alignleft"></a>I was going to make a tutorial, but then I figured that making a video would be a much better way to show this.<br />
As for the code that you could grab from a tutorial, there&#8217;s a link at the end of the post with all the code shown in the video demo.</p>
<p>The video demo covers how to create and run Unit Test classes for regular Java classes on Android, and also how to create and run Unit Test classes that test classes that depend on Android &#8220;Context&#8221; or &#8220;Activity&#8221; objects.</p>
<p>If your Android unit tests are not running because of frustrating error messages, the time spent watching this video will save you a lot of reading and headaches.</p>
<p>Check the screencast <a href="http://www.gubatron.com/blog/2010/05/02/how-to-do-unit-testing-on-android-with-eclipse/#more-1913">after the break</a></p>
<p><span id="more-1913"></span><br />
<object width="560" height="367"><param name="movie" value="http://www.dailymotion.com/swf/video/xd5ki4?width=560&#038;theme=none&#038;foreground=%23F7FFFD&#038;highlight=%23FFC300&#038;background=%23171D1B&#038;start=&#038;additionalInfos=0&#038;autoPlay=0&#038;hideInfos=0&#038;colors=background%3A171D1B%3Bforeground%3AF7FFFD%3Bspecial%3AFFC300%3B"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xd5ki4?width=560&#038;theme=none&#038;foreground=%23F7FFFD&#038;highlight=%23FFC300&#038;background=%23171D1B&#038;start=&#038;additionalInfos=0&#038;autoPlay=0&#038;hideInfos=0&#038;colors=background%3A171D1B%3Bforeground%3AF7FFFD%3Bspecial%3AFFC300%3B" width="560" height="367" allowfullscreen="true" allowscriptaccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/xd5ki4_how-to-unit-test-on-android-screenc_tech">How to Unit Test on Android [SCREENCAST]</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/wedoit4you">wedoit4you</a>. &#8211; <a href="http://www.dailymotion.com/us/channel/tech">Explore more science and tech videos.</a></i></p>
<p><a href="http://www.gubatron.com/blog/wp-content/uploads/2010/05/UnitTestDemoProject.tar.gz">Download the Eclipse Project sources</a></p>
<p><br/></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F&amp;title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F&amp;title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F&amp;title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F&amp;headline=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F&amp;title=%5BSCREENCAST%5D+How+to+do+Unit+Testing+on+Android+with+Eclipse&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F05%2F02%2Fhow-to-do-unit-testing-on-android-with-eclipse%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/05/02/how-to-do-unit-testing-on-android-with-eclipse/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Programming Languages Popularity by the number of Tagged Questions at StackOverflow.com</title>
		<link>http://www.gubatron.com/blog/2010/04/12/programming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com/</link>
		<comments>http://www.gubatron.com/blog/2010/04/12/programming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 22:11:19 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[languages]]></category>
		<category><![CDATA[popularity]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1862</guid>
		<description><![CDATA[1. C# 73,833 2. Java 43,006 3. PHP 35,371 4. Javascript 31,244 5. C++ 27,340 6. Python 22,070 7. Objective-C 10,350 8. Ruby 8,773 9. VB.net 7,778 10. ActionScript (Flash) 5,230 11. Perl 4,496 What do these numbers mean to you? Languages on the rise of popularity among programmers, or lack of good documentation? [buzz [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm3.static.flickr.com/2283/4508598238_12d458ae4d_b.jpg" width="100%" alt="Caught a Bug - by Gubatron"/></p>
<p>1. C# 73,833<br />
2. Java 43,006<br />
3. PHP 35,371<br />
4. Javascript 31,244<br />
5. C++ 27,340<br />
6. Python 22,070<br />
7. Objective-C 10,350<br />
8. Ruby 8,773<br />
9. VB.net 7,778<br />
10. ActionScript (Flash) 5,230<br />
11. Perl 4,496</p>
<p>What do these numbers mean to you? Languages on the rise of popularity among programmers, or lack of good documentation?</p>
<p>[buzz href="http://www.google.com/buzz/gubatron2/UJr3LGeN53k/Programming-Languages-Popularity-by-the-number-of" liked="14"]</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F&amp;title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F&amp;title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F&amp;title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F&amp;headline=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F&amp;title=Programming+Languages+Popularity+by+the+number+of+Tagged+Questions+at+StackOverflow.com&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F04%2F12%2Fprogramming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/04/12/programming-languages-popularity-by-the-number-of-tagged-questions-at-stackoverflow-com/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java: How to create dynamic PNGs, JPGs, GIFs.</title>
		<link>http://www.gubatron.com/blog/2010/02/14/java-how-to-create-dynamic-pngs-jpgs-gifs/</link>
		<comments>http://www.gubatron.com/blog/2010/02/14/java-how-to-create-dynamic-pngs-jpgs-gifs/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 23:44:20 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=2138</guid>
		<description><![CDATA[Sometimes you need to create graphics, or compose images and have them saved as regular PNGs, JPEGs or GIFs. Here&#8217;s a quick and dirty reference of how to do it with BufferedImages, Graphics2D and javax.imageio.*. Very straightforward.]]></description>
			<content:encoded><![CDATA[<p>Sometimes you need to create graphics, or compose images and have them saved as regular PNGs, JPEGs or GIFs.</p>
<p>Here&#8217;s a quick and dirty reference of how to do it with BufferedImages, Graphics2D and javax.imageio.*.<br />
Very straightforward.</p>
<pre class="brush: java; title: ; notranslate">
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
...

//1. Create a BufferedImage, in this case a simple 1024x768 using only RGB colors (you could use alpha for example)
BufferedImage bufferedImage = new BufferedImage(1024, 768, BufferedImage.TYPE_INT_RGB);

//2. Get a hold of a Graphics2D object to do all the painting and compositing on the BufferedImage
Graphics2D graphics = bufferedImage.createGraphics();

//3. Do the painting... in this case, I just filled with yellow
graphics.setColor(new Color(255,255,0));
graphics.fillRect(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight());

//4. Write the image
try {
    ImageIO.write(bufferedImage, &quot;png&quot;,new File(&quot;test.png&quot;));
} catch (IOException e) {
   e.printStackTrace();
}
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F&amp;title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F&amp;title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F&amp;title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F&amp;headline=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs.&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F&amp;title=Java%3A+How+to+create+dynamic+PNGs%2C+JPGs%2C+GIFs.&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2010%2F02%2F14%2Fjava-how-to-create-dynamic-pngs-jpgs-gifs%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2010/02/14/java-how-to-create-dynamic-pngs-jpgs-gifs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick N Dirty way to Map Commands to remote servers via ssh</title>
		<link>http://www.gubatron.com/blog/2009/10/10/map-commands-to-servers-via-ssh/</link>
		<comments>http://www.gubatron.com/blog/2009/10/10/map-commands-to-servers-via-ssh/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 18:19:15 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[convenience]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tricks]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1457</guid>
		<description><![CDATA[You may be running several independent but similar servers at the same time and wasting time by executing commands in all of them one by one. Wouldn&#8217;t it be nice to send a command to all of them at once? or to monitor all of them at once. The following script can be used as [...]]]></description>
			<content:encoded><![CDATA[<p>You may be running several independent but similar servers at the same time and wasting time by executing commands in all of them one by one.</p>
<p>Wouldn&#8217;t it be nice to send a command to all of them at once? or to monitor all of them at once.</p>
<p>The following script can be used as a building block to more complex automation tasks for a small size set of servers. (If you&#8217;re managing over 50 servers, I&#8217;d probably consider looking a different way to arrange servers (map/reduce cluster), but if you&#8217;re doing something below that number this might suffice)</p>
<pre class="brush: python; title: ; notranslate">
#!/usr/bin/python                                                                                                                                                                                                                                                      

#########################################################
# Author: Angel Leon (gubatron@gmail.com) - October 2009
#
# Invokes a command locally and invokes the same command
# in all machines under the specified username, servers
#
# Requirement: Have a public ssh_key for that user on all
# the other machines so you don't have to authenticate
# on all the other machines.
#########################################################
import sys
import os

# set the username that has access to all the machines here
user='safeuser'

# add all your server names here
servers=['server1.mydomain.com','server2.mydomain.com','server3.mydomain.com']

if __name__ == &quot;__main__&quot;:
  if len(sys.argv) &lt; 2:
    print &quot;Usage: ssh_map_command &lt;cmd&gt;&quot;
    sys.exit(0)

  cmd= ' '.join(sys.argv[1:])

  #Execute locally first
  print cmd
  os.system(cmd)

  #Execute for all the servers in the list
  for server in servers:
    remote_cmd=&quot;ssh %s@%s %s&quot; % (user,server,cmd)
    print remote_cmd
    os.system(remote_cmd)
    print
</pre>
<p>Save as ssh_map_command and chmod +x it. </p>
<p><strong>Sample uses</strong><br />
Check the average load of all machines at once (then use output to mitigate high load issues)</p>
<pre class="brush: bash; title: ; notranslate">$ ssh_map_command uptime</pre>
<p>Send HUP signal to all your web servers (put it in an alias or other script&#8230; and that&#8217;s how you start building more complex scripts)</p>
<pre class="brush: bash; title: ; notranslate">$ ssh_map_command ps aux | grep [l]ighttpd | kill -HUP `awk {'print $2'}`</pre>
<p>Check if processes are alive, check memory usage on processes across different machines, <a href="http://en.wikipedia.org/wiki/Grep" target="_blank" rel="nofollow">grep</a> remote all logs at once, <a href="http://subversion.tigris.org/" target="_blank" rel="nofollow">svn up</a> on all machines, <a href="http://samba.anu.edu.au/rsync/" target="_blank" rel="nofollow">rsync</a> from one to many, hey, you can even <a href="http://en.wikipedia.org/wiki/Tail_%28Unix%29" target="_blank" rel="nofollow">tail -f</a> and grep all the logs at once, you can go nuts with this thing. Depends on what you need to do.</p>
<p><strong>Requirements</strong></p>
<ul>
<li>For convenience you should probably <a href="http://linuxproblem.org/art_9.html" target="_blank" rel="nofollow">set up ssh public/private keys between the main machine and the other machines</a> (or they can all trust each other and you can execute on any) so that you can execute commands on all the machines without having to enter passwords.</li>
<li>Put the script on your $PATH.</li>
<li><a href="http://python.org/" target="_blank" rel="nofollow">python</a></li>
</ul>
<p><strong>Security Advisory</strong><br />
Make sure only the desired user has read/write/execute access to it and keep your private ssh keys safe (preferably only read and execute for the owner, and no permissions whatsoever to anybody else <strong>chmod 500 ssh_mod_map</strong>), if possible change them as often as possible, for it may become a big security whole if an attacker can manage to write code on this script, specially if you have <strong>cronjobs</strong> invoking it. Your attacker would only need to change code here to mess up all of your machines.</p>
<p><strong>Disclaimer and Call for Knowledge</strong><br />
<img src="http://farm4.static.flickr.com/3607/3677330708_6d68fc4ce0_m.jpg" class="alignleft"/>Please, if someone knows of a standard way to map commands to multiple servers, please let me know in the comment section, in my case I needed a solution and I wrote a quick and dirty python script and tried to secure it as best as I could, by no means I&#8217;m saying that this is the best solution to mapping commands, in fact I believe it might be the least efficient way, however it works good enough for my personal needs.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F&amp;title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F&amp;title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F&amp;title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F&amp;headline=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F&amp;title=Quick+N+Dirty+way+to+Map+Commands+to+remote+servers+via+ssh&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fmap-commands-to-servers-via-ssh%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/10/10/map-commands-to-servers-via-ssh/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ubuntu/Debian Quick Reference: How To Change Your Server&#8217;s UTC Timezone on the command line</title>
		<link>http://www.gubatron.com/blog/2009/10/10/ubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line/</link>
		<comments>http://www.gubatron.com/blog/2009/10/10/ubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 16:27:00 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[time]]></category>
		<category><![CDATA[time zone]]></category>
		<category><![CDATA[time zones]]></category>
		<category><![CDATA[timezone]]></category>
		<category><![CDATA[timezones]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[utc]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1447</guid>
		<description><![CDATA[Just Type&#8230; sudo dpkg-reconfigure tzdata &#8230;and follow the instructions on screen. The process should look something like the following: Select your Region Select a city on your time zone You&#8217;re done. Tip You can always check the status of your configuration using sudo debconf-show tzdata You could for example map that command via ssh to [...]]]></description>
			<content:encoded><![CDATA[<p>Just Type&#8230;<br />
<strong><code>sudo dpkg-reconfigure tzdata</code><br />
</strong></p>
<p>&#8230;and follow the instructions on screen.</p>
<p>The process should look something like the following:</p>
<p><img src="http://www.gubatron.com/blog/wp-content/uploads/2009/10/tzdata_sshot_01.png"/></p>
<p><img src="http://www.gubatron.com/blog/wp-content/uploads/2009/10/tzdata_sshot_02.png"/><br />
Select your Region</p>
<p><img src="http://www.gubatron.com/blog/wp-content/uploads/2009/10/tzdata_sshot_03.png"/><br />
Select a city on your time zone</p>
<p><img src="http://www.gubatron.com/blog/wp-content/uploads/2009/10/tzdata_sshot_04.png"/><br />
You&#8217;re done.</p>
<p><strong>Tip</strong><br />
You can always check the status of your configuration using<br />
<code>sudo debconf-show tzdata</code></p>
<p>You could for example map that command via ssh to several machines and grep for &#8220;*&#8221;, that way you could easily spot servers with wrong timezones very quickly.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F&amp;title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F&amp;title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F&amp;title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F&amp;headline=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F&amp;title=Ubuntu%2FDebian+Quick+Reference%3A+How+To+Change+Your+Server%27s+UTC+Timezone+on+the+command+line&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F10%2F10%2Fubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/10/10/ubuntudebian-quick-reference-how-to-change-your-servers-utc-timezone-on-the-command-line/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Check the Top 10 Linux Commands you can&#8217;t live without</title>
		<link>http://www.gubatron.com/blog/2009/09/28/check-the-top-10-linux-commands-you-cant-live-without/</link>
		<comments>http://www.gubatron.com/blog/2009/09/28/check-the-top-10-linux-commands-you-cant-live-without/#comments</comments>
		<pubDate>Tue, 29 Sep 2009 02:36:13 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[commands]]></category>
		<category><![CDATA[favorite]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1419</guid>
		<description><![CDATA[Type the following on your cmd line (or make into an alias) cat ~/.bash_history &#124; sort &#124; uniq -c &#124; sort -r &#124; head In my case they are (for this week) ls fg svnSync (script I created) stats_fetch; stats_display (other scripts) cd crontab -e ps aux &#124; grep ssh_map_command (another script) python emacs -nw]]></description>
			<content:encoded><![CDATA[<p>Type the following on your cmd line (or make into an alias)</p>
<pre>
cat ~/.bash_history | sort | uniq -c | sort -r | head
</pre>
<p>In my case they are (for this week)</p>
<pre>ls
fg
svnSync (script I created)
stats_fetch; stats_display (other scripts)
cd
crontab -e
ps aux | grep
ssh_map_command (another script)
python
emacs -nw
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F&amp;title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F&amp;title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F&amp;title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F&amp;headline=Check+the+Top+10+Linux+Commands+you+can%27t+live+without" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Check+the+Top+10+Linux+Commands+you+can%27t+live+without&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F&amp;title=Check+the+Top+10+Linux+Commands+you+can%27t+live+without&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F09%2F28%2Fcheck-the-top-10-linux-commands-you-cant-live-without%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/09/28/check-the-top-10-linux-commands-you-cant-live-without/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>HTML 5 is out and about</title>
		<link>http://www.gubatron.com/blog/2009/07/11/html-5-is-out-and-about/</link>
		<comments>http://www.gubatron.com/blog/2009/07/11/html-5-is-out-and-about/#comments</comments>
		<pubDate>Sat, 11 Jul 2009 11:59:03 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[HTML5]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1324</guid>
		<description><![CDATA[I believe that the &#60;canvas>, &#60;audio>and &#60;video> tags will make the web a pretty exciting place. A lot of Flash components will be rewritten or converted into Javascript+HTML5 Object components making available more reusable elements for a graphical and interactive web, all being open sourced (javascript) and with no extra plugins needed. Some places where [...]]]></description>
			<content:encoded><![CDATA[<p>I believe that the &lt;canvas>, &lt;audio>and &lt;video> tags will make the web a pretty exciting place. A lot of Flash components will be rewritten or <a href="http://www.jangaroo.net/home/">converted</a> into <a href="http://www.blarnee.com/projects/cflow/" target="_blank">Javascript+HTML5 Object components</a> making available more reusable elements for a graphical and interactive web, all being open sourced (javascript) and with no extra plugins needed.</p>
<p>Some places where we can already see (or will) the use of HTML 5 tags and javascript on those elements are:</p>
<ul>
<li>GMail Mobile for iPhone and Android</li>
<li><a href="http://pipes.yahoo.com">Yahoo! Pipes</a></li>
<li><a href="http://vimeo.com/3195079">Bespin, a code editor created by Mozilla lab</a>, they basically rewrote the text editing component using the canvas tag so that its a high performance text editing component, with a nice look, selection highlighting, new scrollbars, command support, it can be extended with your own commands (reminds me of emacs)</li>
<li>Google Waves</li>
<li>Some blogs that are already using the &lt;article>, &lt;nav>, &lt;footer> and other new HTML 5 tags</li>
<li><a href="http://www.youtube.com/html5">YouTube</a> is getting ready for the video tag</li>
</ul>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F&amp;title=HTML+5+is+out+and+about" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F&amp;title=HTML+5+is+out+and+about" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F&amp;title=HTML+5+is+out+and+about" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F&amp;headline=HTML+5+is+out+and+about" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=HTML+5+is+out+and+about&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=HTML+5+is+out+and+about&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=HTML+5+is+out+and+about&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=HTML+5+is+out+and+about&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=HTML+5+is+out+and+about&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F&amp;title=HTML+5+is+out+and+about&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F07%2F11%2Fhtml-5-is-out-and-about%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/07/11/html-5-is-out-and-about/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to make a Quick &amp; Dirty HexViewer &#8211; Updated</title>
		<link>http://www.gubatron.com/blog/2009/04/20/how-to-make-a-quick-dirty-hexviewer-updated/</link>
		<comments>http://www.gubatron.com/blog/2009/04/20/how-to-make-a-quick-dirty-hexviewer-updated/#comments</comments>
		<pubDate>Mon, 20 Apr 2009 12:13:55 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[java hex hexviewer programming]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1269</guid>
		<description><![CDATA[After I received comments from ispak on Flickr I made a few fixes. ispak pointed out that it was a bad idea reading one byte at the time, also I had a gay ass try/catch that didn&#8217;t catch any exception :p So now I read 16 byte chunks, and I also take care of the [...]]]></description>
			<content:encoded><![CDATA[<p>After I received comments from <a rel="nofollow" href="http://www.flickr.com/photos/gubatron/3452721506/">ispak on Flickr</a> I made a few fixes.</p>
<p>ispak pointed out that it was a bad idea reading one byte at the time, also I had a gay ass try/catch that didn&#8217;t catch any exception :p</p>
<p>So now I read 16 byte chunks, and I also take care of the file ending. The previous version used to print the file ending with a bunch of null bytes. Now it stops reading at the end, and formats the output accordingly.</p>
<p>Here&#8217;s the new source:</p>
<pre class="brush: java; title: ; notranslate">
//HexViewer.java
import java.io.*;

public final class HexViewer {
    public final static void printFile(String filePath) {
        try {
            File f = new File(filePath);
            BufferedInputStream bis =
                new BufferedInputStream(new FileInputStream(f));

            byte[] chunk = null;
            int readStatus = 0;
            while (true) {
                chunk = new byte[16];
                readStatus = bis.read(chunk, 0, 16);
                char[] line = new char[16];

                if (readStatus == -1)
                    break;

                for (byte i=0; i &lt; readStatus; i++) {
                    int readByte = (chunk[i] &lt; 0) ? (-1 * (int) chunk[i]) : chunk[i];
                    String paddingZero = (readByte &lt; 16) ? &quot;0&quot; : &quot;&quot;;
                    System.out.print(paddingZero + Integer.toHexString(readByte).toUpperCase() + &quot; &quot;);
                    line[i] = (readByte &gt;= 33 &amp;&amp; readByte &lt;= 126) ? (char) readByte : '.';
                }

                //We add some padding to print the text line right below the one above.
                String padding = new String();
                if (readStatus &lt; 16) {
                    for (byte i=0; i &lt; 16-readStatus; i++) {
                        padding += &quot;   &quot;;
                    }
                }

                System.out.println(padding + new String(line));
            }
        } catch (Exception e1) { e1.printStackTrace(); }
    }

    public final static void main(String[] args) {
        if (args.length == 0)
            return;

        printFile(args[0]);
    }
}
</pre>
<p><a href="http://www.flickr.com/photos/gubatron/3458529439/" title="HexViewer - r2 by Gubatron, on Flickr"><img src="http://farm4.static.flickr.com/3486/3458529439_31357e0afe_o.png" width="570" height="641" alt="HexViewer - r2" /></a></p>
<p>And see how it now handles file endings when the file size is not a multiple of 16 :p</p>
<p><a href="http://www.flickr.com/photos/gubatron/3459348222/" title="Picture 2 by Gubatron, on Flickr"><img src="http://farm4.static.flickr.com/3578/3459348222_ee4b427d5e_o.png" width="464" height="91" alt="Picture 2" /></a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F&amp;title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F&amp;title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F&amp;title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F&amp;headline=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F&amp;title=How+to+make+a+Quick+%26+Dirty+HexViewer+-+Updated&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F20%2Fhow-to-make-a-quick-dirty-hexviewer-updated%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/04/20/how-to-make-a-quick-dirty-hexviewer-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to make your own Quick &amp; Dirty Hex File Viewer in Java</title>
		<link>http://www.gubatron.com/blog/2009/04/18/how-to-make-your-own-quick-dirty-hex-file-viewer-in-java/</link>
		<comments>http://www.gubatron.com/blog/2009/04/18/how-to-make-your-own-quick-dirty-hex-file-viewer-in-java/#comments</comments>
		<pubDate>Sat, 18 Apr 2009 13:04:33 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Random Stuff]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[hex editor]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1252</guid>
		<description><![CDATA[Update: You might want to read this new version of the code instead. Thanks ispak I was playing with a hex editor recently and then I thought it would be pretty easy to make a program to output what you see on a text editor. Here&#8217;s a quick &#038; dirty Hex Visor I wrote in [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> You might want to read this <a href="http://www.gubatron.com/blog/2009/04/20/how-to-make-a-quick-dirty-hexviewer-updated/">new version of the code </a> instead. Thanks ispak</p>
<p>I was playing with a hex editor recently and then I thought it would be pretty easy to make a program to output what you see on a text editor. Here&#8217;s a quick &#038; dirty Hex Visor I wrote in like 5 minutes with Java. It shows 15 bytes per line, and on the right side it prints all the visible characters of the ascii table, the non-visible ones are replaced with &#8220;.&#8221;</p>
<p>Enjoy:</p>
<pre class="brush: java; title: ; notranslate">
//HexViewer.java
import java.io.*;

public final class HexViewer {
    public final static void printFile(String filePath) {
        File f;
        try {
            f = new File(filePath);
        } catch (Exception e) {
            return;
        }

        try {

            FileInputStream fis = new FileInputStream(f);
            while (fis.available() &gt; 0) {
                char[] line = new char[16];
                for (int i=0; i &lt; 16; i++) {
                    int readByte = fis.read();
                    String paddingZero = (readByte &lt; 16) ? &quot;0&quot; : &quot;&quot;;
                    System.out.print(paddingZero + Integer.toHexString(readByte) + &quot; &quot;);
                    line[i] = (readByte &gt;= 33 &amp;&amp; readByte &lt;= 126) ? (char) readByte : '.';
                }
                System.out.println(new String(line));
            }
        } catch (Exception e1) { e1.printStackTrace(); }
    }

    public final static void main(String[] args) {
        if (args.length == 0)
            return;

        printFile(args[0]);
    }
}
</pre>
<p>Usage:</p>
<pre class="brush: bash; title: ; notranslate">java HexViewer &amp;lt;path to file&gt; | less</pre>
<pre class="brush: bash; title: ; notranslate">java HexViewer Desktop/Puppet.wmv | less

30 26 b2 75 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c 0&amp;.u.f.......b.l
74 14 00 00 00 00 00 00 07 00 00 00 01 02 a1 dc t...............
ab 8c 47 a9 cf 11 8e e4 00 c0 0c 20 53 65 68 00 ..G.........Seh.
00 00 00 00 00 00 f4 10 68 f9 49 76 2e 43 b5 9f ........h.Iv.C..
09 0a 2d 19 45 7c 32 3a 24 00 00 00 00 00 70 ee ..-.E|2:$.....p.
14 06 fb da c7 01 28 01 00 00 00 00 00 00 00 8c ......(.........
bb 53 00 00 00 00 10 88 dd 52 00 00 00 00 b8 0b .S.......R......
00 00 00 00 00 00 02 00 00 00 40 1f 00 00 40 1f ..........@...@.
00 00 90 50 02 00 b5 03 bf 5f 2e a9 cf 11 8e e3 ...P....._......
00 c0 0c 20 53 65 61 10 00 00 00 00 00 00 11 d2 ....Sea.........
d3 ab ba a9 cf 11 8e e6 00 c0 0c 20 53 65 06 00 ............Se..
33 10 00 00 a9 46 43 7c e0 ef fc 4b b2 29 39 3e 3....FC|...K.)9&gt;
de 41 5c 85 27 00 00 00 00 00 00 00 01 00 0c 65 .A\.'..........e
00 6e 00 2d 00 61 00 75 00 00 00 5d 8b f1 26 84 .n.-.a.u...]..&amp;.
45 ec 47 9f 5f 0e 65 1f 04 52 c9 1a 00 00 00 00 E.G._.e..R......
00 00 00 02 01 ea cb f8 c5 af 5b 77 48 84 67 aa ..........[wH.g.
8c 44 fa 4c ca 62 01 00 00 00 00 00 00 06 00 00 .D.L.b..........
00 01 00 0c 00 02 00 02 00 00 00 49 00 73 00 56 ...........I.s.V
00 42 00 52 00 00 00 00 00 00 00 01 00 34 00 00 .B.R.........4..
00 06 00 00 00 44 00 65 00 76 00 69 00 63 00 65 .....D.e.v.i.c.e
00 43 00 6f 00 6e 00 66 00 6f 00 72 00 6d 00 61 .C.o.n.f.o.r.m.a
00 6e 00 63 00 65 00 54 00 65 00 6d 00 70 00 6c .n.c.e.T.e.m.p.l
00 61 00 74 00 65 00 00 00 4c 00 31 00 00 00 00 .a.t.e...L.1....
00 02 00 0c 00 02 00 02 00 00 00 49 00 73 00 56 ...........I.s.V
00 42 00 52 00 00 00 01 00 00 00 02 00 34 00 00 .B.R.........4..
00 0c 00 00 00 44 00 65 00 76 00 69 00 63 00 65 .....D.e.v.i.c.e
00 43 00 6f 00 6e 00 66 00 6f 00 72 00 6d 00 61 .C.o.n.f.o.r.m.a
00 6e 00 63 00 65 00 54 00 65 00 6d 00 70 00 6c .n.c.e.T.e.m.p.l
00 61 00 74 00 65 00 00 00 4d 00 50 00 40 00 4d .a.t.e...M.P.@.M
00 4c 00 00 00 00 00 01 00 2e 00 03 00 04 00 00 .L..............
00 57 00 4d 00 2f 00 57 00 4d 00 41 00 44 00 52 .W.M./.W.M.A.D.R
00 43 00 50 00 65 00 61 00 6b 00 52 00 65 00 66 .C.P.e.a.k.R.e.f
00 65 00 72 00 65 00 6e 00 63 00 65 00 00 00 a7 .e.r.e.n.c.e....
3f 00 00 00 00 01 00 34 00 03 00 04 00 00 00 57 ?......4.......W
00 4d 00 2f 00 57 00 4d 00 41 00 44 00 52 00 43 .M./.W.M.A.D.R.C
00 41 00 76 00 65 00 72 00 61 00 67 00 65 00 52 .A.v.e.r.a.g.e.R
00 65 00 66 00 65 00 72 00 65 00 6e 00 63 00 65 .e.f.e.r.e.n.c.e
00 00 00 b0 06 00 00 74 d4 06 18 df ca 09 45 a4 .......t......E.
ba 9a ab cb 96 aa e8 a4 0d 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
</pre>
<p>This how it looks on a full blown hex editor like HexEdit:<br />
<a href="http://www.flickr.com/photos/gubatron/3452718760/" title="Same file on HexEdit by Gubatron, on Flickr"><img src="http://farm4.static.flickr.com/3634/3452718760_995edb5218_o.png" width="558" height="569" alt="Same file on HexEdit" /></a></p>
<p>The Code of HexViewer.java on emacs:<br />
<a href="http://www.flickr.com/photos/gubatron/3452721506/" title="HexViewer.java on emacs by Gubatron, on Flickr"><img src="http://farm4.static.flickr.com/3379/3452721506_abbcfd5dbf_o.png" width="580" height="665" alt="HexViewer.java on emacs" /></a></p>
<p>Screenshot of the output:<br />
<a href="http://www.flickr.com/photos/gubatron/3452720154/" title="HexViewer in action by Gubatron, on Flickr"><img src="http://farm4.static.flickr.com/3582/3452720154_6153a04a63_o.png" width="450" height="721" alt="HexViewer in action" /></a></p>
<p><strong>Homework</strong><br />
Hack the code so that it ouputs the first column shown on the HexEdit screenshot. That column represents the byte position of each row. It&#8217;s basically a counter incremented 16 units at the time, and shown in Hex.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F&amp;title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F&amp;title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F&amp;title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F&amp;headline=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F&amp;title=How+to+make+your+own+Quick+%26+Dirty+Hex+File+Viewer+in+Java&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F04%2F18%2Fhow-to-make-your-own-quick-dirty-hex-file-viewer-in-java%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/04/18/how-to-make-your-own-quick-dirty-hex-file-viewer-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OnLive could change the video game industry</title>
		<link>http://www.gubatron.com/blog/2009/03/25/onlive-could-change-the-video-game-industry/</link>
		<comments>http://www.gubatron.com/blog/2009/03/25/onlive-could-change-the-video-game-industry/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 04:23:39 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Opinions]]></category>
		<category><![CDATA[Video Games]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[cloud gaming]]></category>
		<category><![CDATA[cloud rendering]]></category>
		<category><![CDATA[onlive]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1188</guid>
		<description><![CDATA[I feel it&#8217;s my geek given duty to make a post about this presentation. I was lucky to finally have the time to watch their hour long presentation and Q&#038;A session at the Game Developer Conference 2009 (which ends a couple of days from today). They could have not picked a better place to finally [...]]]></description>
			<content:encoded><![CDATA[<p><embed id="mymovie" width="432" height="362" flashvars="playerMode=embedded&#038;movieAspect=4.3&#038;flavor=EmbeddedPlayerVersion&#038;skin=http://image.com.com/gamespot/images/cne_flash/production/media_player/proteus/one/skins/gamespot.png&#038;paramsURI=http%3A%2F%2Fwww.gamespot.com%2Fpages%2Fvideo_player%2Fxml.php%3Fid%3D6206692%26mode%3Dembedded%26width%3D432%26height%3D362" wmode="transparent" allowscriptaccess="always" quality="high" name="mymovie" style="" src="http://image.com.com/gamespot/images/cne_flash/production/media_player/proteus/one/proteus2.swf" type="application/x-shockwave-flash"/></p>
<p>I feel it&#8217;s my geek given duty to make a post about this presentation. I was lucky to finally have the time to watch their hour long presentation and Q&#038;A session at the Game Developer Conference 2009 (which ends a couple of days from today). They could have not picked a better place to finally demo their technology.</p>
<p>In short, they&#8217;ve introduced a huge new concept to the video game industry, I&#8217;d call it &#8220;Cloud Gaming&#8221; to not only host the games, but also host the processing juice. You won&#8217;t need a console anymore, they keep the hardware to execute and stream the game to your screen. They support TV (with a miniconsole), PC and Mac.</p>
<p>So bear with me, they say they have solved the issue that you&#8217;re thinking about now, Lag. The people behind this worked on apple to create Quicktime, and they identified differences between what it takes to compress linear (regular) video, vs Interactive Video. They say their compression algorithm doesn&#8217;t take seconds of lag (like when you stream over a webcam), but miliseconds. They have custom chips to process the graphics, and I bet they might even built their own network protocol right on top of IP.</p>
<p>So what are some of the implications of this:</p>
<ul>
<li>We&#8217;ll all be able to finally play Crysis and even more demanding games on low end PCs</li>
<li>No more buying more hardware, no more upgrading your PC to be able to run games, no more buying consoles</li>
<li>All your games live on the platform, so you can play from any computer, and you&#8217;ll keep the state of your game until the last time you hit the Pause button</li>
<li>Your friends can see you play, live. I bet we&#8217;ll be able to see live tournaments,  we&#8217;ll start seeing a new breed of famous people get more attention, the Elite gamers. Imagine seeing the best Call of Duty player in the world playing live</li>
<li>New Genres of video games will emerge on this platform, maybe even new genres of entertainment, think new Live Broadcast shows where participants use an avatar to either act or compete (game show)</li>
<li>Game Developers not need to think of the rendering limitations that they might have nowadays, and will be able to design games that could only be imagined in the past. Render quality only thought for movies will now exist for video games, think of virtual reality now</li>
<li>There&#8217;s about 100 million PCs/Macs/Laptops out there that are not ready today to play high end games, now they&#8217;ll have the possibility of playing virtually any game by installing a 1Mb plugin from OnLive.com</li>
<li>Takes Piracy out of the Business Equation</li>
<li>A bigger gaming audience makes an even better case for companies placing advertisement in video games, maybe there will be a lot more high end free games with bigger audiences, think the next Grand Theft Auto coming out for free with <a href="http://www.mova.com/gallery.php">superb real life like graphics rendering</a>, all ad sponsored and free to the consumer. The amount of people that you could have playing a great game for free would make other developers think twice about charging for their games and having their virtual worlds ad sponsored.</li>
<li>No more installs</li>
<li>Now multiplayer will have almost no latency since all players live inside their datacenter, you only get the latency of your ISP if there&#8217;s any</li>
<li>Nintendo, Sony and Microsoft must be shitting their pants</li>
<li>Services that sell used games are going to be selling vintage and their business will be reduced</li>
</ul>
<p>However I think there will always be room for the old consoles. This is the biggest entertainment industry in the world, we have grown up with consoles for almost 30 years and there&#8217;s a lot of changes to push into people&#8217;s minds:</p>
<ul>
<li>How do you convince me, that finally made up my  mind after years and dropped $500 on a PS3 to play with my friends in latin america online to switch to this, if my friends will probably have no way to even have access to the system in years to come?</li>
<li>How do you convince PC gamers that rather pay for the hardware and pirate the games? (There&#8217;s plenty of those, probably the majority of the PC gaming population outside the US never plays for a PC game, and doesn&#8217;t get into consoles because they pirate the games) into renting or buying games on the cloud?</li>
<li>How do you convince all the people that they should switch when their gaming experience depends entirely on being connected to the internet. So If the ISP is having issues I can&#8217;t play? isn&#8217;t my console awesome?</li>
</ul>
<p>It seems that many of these complains are similar to all the complains brought upon business models that didn&#8217;t exist online and that are now thriving. This presentation left me with my mouth wide open, and I highly recommend you watch it. You&#8217;ll be blown away by the power of the UI, and how as you Browse for games, you can even see how other people are playing live, it&#8217;s like streaming video is nothing for OnLive. Really sick technology.</p>
<p>In the case that they succeed, I just can&#8217;t wait for them to have competition by the existing big brands, it&#8217;s going to get so interesting once cloud gaming becomes the defacto platform, maybe we as consumers will end up playing games for free, all sponsored with in game ads.</p>
<p>Just by listening to the guy if you&#8217;re a techie, your mind will start to fly to barely start to imagine the awesomeness of the technology that should be behind this. I can imagine anything from custom virtualization technology, to custom GPUs, custom network cards, custom network protocols on top of IP, deals with major internet backbone networks, ISPs, deals with game publishers, sick level API development, incomprehensible comprehension technology for my retard brain&#8230; when I see shit like this, I always think&#8230; how the hell is there people that still believe in god? Mankind is the closest thing there is to something like that! I&#8217;m thankful for people in this world that can think so big.</p>
<p>The service is supposed to launch next Winter 2009, but you can <a rel="nofollow" href="http://www.onlive.com/beta_program.html">sign up to be a beta tester</a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F&amp;title=OnLive+could+change+the+video+game+industry" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F&amp;title=OnLive+could+change+the+video+game+industry" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F&amp;title=OnLive+could+change+the+video+game+industry" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F&amp;headline=OnLive+could+change+the+video+game+industry" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=OnLive+could+change+the+video+game+industry&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=OnLive+could+change+the+video+game+industry&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=OnLive+could+change+the+video+game+industry&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=OnLive+could+change+the+video+game+industry&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=OnLive+could+change+the+video+game+industry&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F&amp;title=OnLive+could+change+the+video+game+industry&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F03%2F25%2Fonlive-could-change-the-video-game-industry%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/03/25/onlive-could-change-the-video-game-industry/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Delete All Direct Messages of your Twitter Account at once (or at least try!)</title>
		<link>http://www.gubatron.com/blog/2009/02/13/delete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try/</link>
		<comments>http://www.gubatron.com/blog/2009/02/13/delete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try/#comments</comments>
		<pubDate>Sat, 14 Feb 2009 04:39:27 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Application programming interface]]></category>
		<category><![CDATA[Delete]]></category>
		<category><![CDATA[On the Web]]></category>
		<category><![CDATA[Online Communities]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Social Networking]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1118</guid>
		<description><![CDATA[Since Twitter doesn&#8217;t provide with a &#8220;Delete All Direct Messages&#8221; functionality, Here&#8217;s a Python script that attempts to delete all the direct messages stored on your Twitter account. Limitations The only problem with it is that given the limitations of the Twitter REST API, I was forced to send a request per message to be [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3421/3278210662_801cd1a20e_o.png" class="alignleft">Since Twitter doesn&#8217;t provide with a &#8220;Delete All Direct Messages&#8221; functionality, <a href="http://www.gubatron.com/blog/wp-content/uploads/2009/02/twitter_delete_direct_messages.txt">Here&#8217;s a Python script</a> that attempts to delete all the direct messages stored on your Twitter account.</p>
<p><strong>Limitations</strong><br />
The only problem with it is that given the limitations of the <a href="http://apiwiki.twitter.com/REST+API+Documentation">Twitter REST API</a>, I was forced to send a request per message to be deleted, and it seems that Twitter will only allow 100 requests per hour (per client).</p>
<p>So in theory you will be able to delete 100 an hour, although I have seen it delete over 400 messages Twitter gets all grumpy on me.</p>
<p><strong>Usage</strong><br />
Just save the script as <strong>twitter_delete_direct_messages.py</strong>, open a terminal and run it:</p>
<pre class="brush: bash; title: ; notranslate">python twitter_delete_direct_messages.py</pre>
<p>After that just follow the instructions on screen and enjoy as messages get wiped out.</p>
<p>If you find this useful, you can thank me by <a href="http://twitter.com/gubatron">following me</a> on Twitter.</p>
<p><a href="http://www.gubatron.com/blog/wp-content/uploads/2009/02/twitter_delete_direct_messages.txt">Get The Script</a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F&amp;title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F&amp;title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F&amp;title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F&amp;headline=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F&amp;title=Delete+All+Direct+Messages+of+your+Twitter+Account+at+once+%28or+at+least+try%21%29&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F02%2F13%2Fdelete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/02/13/delete-all-direct-messages-of-your-twitter-account-at-once-or-at-least-try/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using a linear array as a bidimensional matrix</title>
		<link>http://www.gubatron.com/blog/2009/01/27/using-a-linear-array-as-a-bidimensional-matrix/</link>
		<comments>http://www.gubatron.com/blog/2009/01/27/using-a-linear-array-as-a-bidimensional-matrix/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 20:18:12 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[matrix]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1114</guid>
		<description><![CDATA[Often times I find the need to use a list or linear array as if it was a table. Everytime I need to do so, I always end up coding functions to convert a (x,y) coordinate to the real index n in the array. Let me illustrate, with an example. You have a string that [...]]]></description>
			<content:encoded><![CDATA[<p>Often times I find the need to use a list or linear array as if it was a table.</p>
<p>Everytime I need to do so, I always end up coding functions to convert a (x,y) coordinate to the real index n in the array.</p>
<p>Let me illustrate, with an example. You have a string that defines the elements of a game board, and you want to work using (x,y) coordinates.</p>
<pre class="brush: python; title: ; notranslate">
s=&quot;xxxxx@xx@xxx@@xx&quot;
</pre>
<p>If you were to look at it as a matrix (width=4), it&#8217;d be something like this</p>
<pre class="brush: python; title: ; notranslate">
s=&quot;xxxx
   x@xx
   @xxx
   @@xx&quot;
</pre>
<p>However, I can&#8217;t do<br />
s[x,y], since it&#8217;s a linear array, it&#8217;s a string.</p>
<p>You need to convert from (x,y) to a number that represents an index in the array.</p>
<p>This is very simple:</p>
<pre class="brush: python; title: ; notranslate">
width=4
def getNforXY(x,y):
  return x + width*y
</pre>
<p>What if you want to do it backwards. What if you need to know what&#8217;s the X and Y for a given index N in the string?</p>
<pre class="brush: python; title: ; notranslate">
def getXYforN(n):
  y = int(n/width)
  x = n - width/y
  return (x,y)
</pre>
<p>Cheers</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F&amp;title=Using+a+linear+array+as+a+bidimensional+matrix" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F&amp;title=Using+a+linear+array+as+a+bidimensional+matrix" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F&amp;title=Using+a+linear+array+as+a+bidimensional+matrix" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F&amp;headline=Using+a+linear+array+as+a+bidimensional+matrix" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Using+a+linear+array+as+a+bidimensional+matrix&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Using+a+linear+array+as+a+bidimensional+matrix&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Using+a+linear+array+as+a+bidimensional+matrix&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Using+a+linear+array+as+a+bidimensional+matrix&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Using+a+linear+array+as+a+bidimensional+matrix&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F&amp;title=Using+a+linear+array+as+a+bidimensional+matrix&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2009%2F01%2F27%2Fusing-a-linear-array-as-a-bidimensional-matrix%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2009/01/27/using-a-linear-array-as-a-bidimensional-matrix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery tag wrapping</title>
		<link>http://www.gubatron.com/blog/2008/12/19/jquery-tag-wrapping/</link>
		<comments>http://www.gubatron.com/blog/2008/12/19/jquery-tag-wrapping/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 14:08:51 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[one liners]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wrapping]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1051</guid>
		<description><![CDATA[Many times you&#8217;ll be working on something in HTML that could be long and repetitive, and then for some reason you need to edit the entire thing to wrap each of the tags on some other tags, a common example would be to link many elements. Take this example, there&#8217;s a bunch of photos, they&#8217;re [...]]]></description>
			<content:encoded><![CDATA[<p>Many times you&#8217;ll be working on something in HTML that could be long and repetitive, and then for some reason you need to edit the entire thing to wrap each of the tags on some other tags, a common example would be to link many elements.</p>
<p>Take this example, there&#8217;s a bunch of photos, they&#8217;re all contained in divs that have a css class called &#8220;photos&#8221;, inside we just throw<br />
a bunch of &lt;img> tags, and all of a sudden our boss tells us he wans to have every image on that page linked to &#8220;http://domain.com/photos&#8221;. jQuery to the rescue, no need to wrap each &lt;img> with &lt;a href=&#8221;"> by hand, you can do it all in one line</p>
<p>So if the code looks like this:</p>
<pre>
       &lt;div class="photos">
            &lt;img src="http://domain.com/0670027481_m.jpg"/>
            &lt;img src="http://domain.com/211161aa99_m.jpg"/>
            &lt;img src="http://domain.com/173bb0cd6_m.jpg"/>
        &lt;/div>
        &lt;div class="photos">
            &lt;img src="http://domain.com/841fd90b5b_m.jpg"/>
            &lt;img src="http://domain.com/52dda2cee5_m.jpg"/>
            &lt;img src="http://domain.com/b569399599_m.jpg"/>
        &lt;/div>
        &lt;div class="photos">
            &lt;img src="http://domain.com/8806e863a4_m.jpg"/>
            &lt;img src="http://domain.com/5e43aa95fe_m.jpg"/>
            &lt;img src="http://domain.com/68a74a088c_m.jpg"/>
        &lt;/div>

        &lt;div class="tshirt-photos">
            &lt;img src="http://farm4.static.flickr.com/3149/3113619519_72ce82c545_m.jpg"/>
            &lt;img src="http://farm4.static.flickr.com/3236/3105792155_99f2388869_m.jpg"/>
            &lt;img src="http://farm3.static.flickr.com/2114/2372582266_765842fae9_m.jpg"/>
        &lt;/div>
</pre>
<p>With jQuery you can match all the &lt;img> elements, and wrap them all with &#8220;&lt;a href=&#8221;http://domain.com/photos&#8221;>&lt;/a>&#8221; in a single line of code:</p>
<pre>
$(document).ready(function() { $(".photos img").wrap('&lt;a href="http://domain.com/photos"></a>') })
</pre>
<p>So to explain how it works, when the document is ready (when it&#8217;s finished loading) the function inside is called back, it will use the jQuery selector <strong>$(&#8220;.photos img&#8221;)</strong> to match all the <strong>&lt;img></strong> tags contained withing elements of css class &#8220;photos&#8221;, then it applies the wrap() function, which will wrap the matched elements with the given html tags.</p>
<h2>About jQuery</h2>
<p><img src="http://marcgrabanski.com/img/jQuery-logo.gif" class="alignleft"/>jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML. It was released January 2006 at BarCamp NYC by John Resig.</p>
<p>Dual licensed under the MIT License and the GNU General Public License, jQuery is free and open source software.</p>
<p>jQuery contains the following features:</p>
<ul>
<li>DOM element selections
</li>
<li>DOM traversal and modification, (including support for CSS 1-3 and basic XPath)</li>
<li>Events</li>
<li>CSS manipulation</li>
<li>Effects and animations</li>
<li>Ajax</li>
<li>Extensibility</li>
<li>Utilities &#8211; such as browser version and the each function.</li>
<li>JavaScript Plugins</li>
</ul>
<p><a href="http://docs.jquery.com/Main_Page" rel="none">jQuery Documentation</a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F&amp;title=jQuery+tag+wrapping" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F&amp;title=jQuery+tag+wrapping" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F&amp;title=jQuery+tag+wrapping" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F&amp;headline=jQuery+tag+wrapping" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=jQuery+tag+wrapping&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=jQuery+tag+wrapping&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=jQuery+tag+wrapping&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=jQuery+tag+wrapping&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=jQuery+tag+wrapping&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F&amp;title=jQuery+tag+wrapping&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F12%2F19%2Fjquery-tag-wrapping%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/12/19/jquery-tag-wrapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python Script to Update WordPress in One Step</title>
		<link>http://www.gubatron.com/blog/2008/11/26/python-script-to-update-wordpress-in-one-step/</link>
		<comments>http://www.gubatron.com/blog/2008/11/26/python-script-to-update-wordpress-in-one-step/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 15:23:49 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[one step]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1015</guid>
		<description><![CDATA[During the past week, I think I had to update all my wordpress instances twice, and it&#8217;s become really annoying doing this manually. I&#8217;ve written a python script which I&#8217;ll share with you. How I keep my wordpress updated by hand I tend to keep my wp-content folder outside of my wordpress installation for 2 [...]]]></description>
			<content:encoded><![CDATA[<p>During the past week, I think I had to update all my wordpress instances twice, and it&#8217;s become really annoying doing this manually. I&#8217;ve written a python script which I&#8217;ll share with you.</p>
<p><strong>How I keep my wordpress updated by hand</strong><br />
I tend to keep my wp-content folder outside of my wordpress installation for 2 reasons:</p>
<p>1. I don&#8217;t like to loose my themes, plugins and customizations<br />
2. I like to keep all my customization changes under subversion</p>
<p>So, if I had my wordpress installation say at:<br />
<strong>/home/user/public_html/blog</strong></p>
<p>I&#8217;d keep my wp-content folder for that here:</p>
<p><strong>/home/user/public_html/wp-content-for-blog</strong></p>
<p>So when I upgrade my blog, I always remove the original wp-content folder that comes along wordpress, and I symlink my hard worked on wp-content folder that lives outside to the freshly unzipped wordpress folder.</p>
<pre class="brush: bash; title: ; notranslate">
user@machine:~/public_html/blog$ ls -l
...
lrwxrwxr-x 1 user www    54 2008-11-26 09:29 wp-content -&gt; /home/user/public_html/wp-content-for-blog
...
</pre>
<p>So what I endup doing all the time, is downloading the <a href="http://www.wordpress.org/latest.zip" rel="nofollow">latest.zip</a> to ~/public_html/, it will unzip under ~/public_html/wordpress, and then I&#8217;ll copy the current ~/public_html/blog/wp-config.php to ~/public_html/wordpress, then I&#8217;ll remove the default ~/public_html/wordpress/wp-content and symlink the outer wp-content with all my customizations, themes and plugins to it. Once done, I&#8217;ll make a backup of the old wordpress folder, and then I&#8217;ll rename wordpress folder to the name of the blog folder, and it&#8217;s all done.</p>
<p>It&#8217;s simple, but when you have to do it for 5 blogs, every week, it&#8217;s not fun anymore.</p>
<p><strong>The Update Script</strong></p>
<p>So here&#8217;s a script to do it in one step. If you&#8217;re not using my symlinked technique, this will do it for you, you only need to specify the full path to the folder where you want to keep your current wp-content folder outside the new installation before you apply the update, and the name of the folder where your current blog lives. The script below will have its configuration variables towards the beginning set so that they are in line with the example I&#8217;ve been talking about.</p>
<pre class="brush: python; title: ; notranslate">
#!/usr/bin/python
#########################################################################################
#
# upgrade_wordpress.py - Script to automatically upgrade your wordpress installation.
#
# Requirements:
#   - Python 2.4 or older
#   - WordPress should already be installed
#   - CURL (sudo apt-get install curl)
#
# Author: Angel (Gubatron) Leon
# LICENSE: See the GPL2 license.
# 2008
#########################################################################################
import os

#########################################################################################
#Config (relative to the folder where this script will be run from)
#########################################################################################

#The current folder where the blog lives
BLOG_FOLDER='blog'

#
# The first time you run the script, it will try to make a copy of your
# current wp-content folder outside. Copy here the location of where
# the wp-content folder with your themes and plugins should exist.
#
# After it unzips, it will remove the default wp-content folder from
# the new installation, and it will symlink the external wp-content
# That way you don't ever have to worry about loosing your customizations
# and plugins.
#
WP_CONTENT_OUTSIDE_COPY_FOLDER=&quot;/home/user/public_html/wp-content-for-blog&quot;

#This is where a backup of your current blog will be
BLOG_FOLDER_BACKUP_FOLDER=BLOG_FOLDER+'.old'

#Where to download the wordpress latest.zip from
WORDPRESS_LATEST_ZIP_URL='http://wordpress.org/latest.zip'

#### DO NOT MODIFY AFTER THESE LINES ####

def downloadWordpress(url=WORDPRESS_LATEST_ZIP_URL):
    if os.path.exists('latest.zip'):
        print &quot;Removing old latest.zip&quot;
        os.remove('latest.zip')

    #Try to download with CURL
    print &quot;Attempting to download latest.zip from wordpress.org&quot;
    os.system('curl %s -o latest.zip' % url)

    if not os.path.exists('latest.zip'):
        os.system('wget ' + url)

    return os.path.exists('latest.zip')

def dirExists(dirName):
    return os.path.exists(dirName) and os.path.isdir(dirName)

def backupBlog(currentBlogFolder=BLOG_FOLDER,
               wpContentOriginalFolder=WP_CONTENT_OUTSIDE_COPY_FOLDER,
               backupFolder=BLOG_FOLDER_BACKUP_FOLDER):

    #Remove any previous backups
    if os.path.exists(backupFolder) and os.path.isdir(backupFolder):
        print &quot;Removing previous backup folder&quot;
        os.system('rm -fr ' + backupFolder)

    #Copy the current blog folder into a backup folder just in case.
    #We won't do any database backups for now.
    print &quot;Creating new backup folder&quot;
    os.system('cp -r %s %s' % (currentBlogFolder,backupFolder))

    #Check for the copy of wp-content outside the blog, if it doesn't exist
    #we'll make it for the first time.
    if not dirExists(wpContentOriginalFolder):
        print &quot;Creating outside copy of wp-content&quot;
        os.system('cp -r %s %s' % (os.path.join(currentBlogFolder,'wp-content'),
                                   wpContentOriginalFolder))

    #Copy the latest wp-config.php outside to the current folder
    print &quot;Copying your latest wp-config.php outside&quot;
    os.system('cp %s .' % (os.path.join(currentBlogFolder,'wp-config.php')))

    backupFolderExists = dirExists(backupFolder)
    wpContentFolderExists = dirExists(wpContentOriginalFolder)
    configFileExists = os.path.exists('wp-config.php')

    return backupFolderExists and wpContentOriginalFolder and configFileExists

def upgradeBlog(currentBlogFolder=BLOG_FOLDER,
                backupFolder=BLOG_FOLDER_BACKUP_FOLDER,
                url=WORDPRESS_LATEST_ZIP_URL,
                wpContentOriginalFolder=WP_CONTENT_OUTSIDE_COPY_FOLDER):

    if not downloadWordpress(url):
        print &quot;Could not download latest.zip, aborting.&quot;
        return False

    if not backupBlog(currentBlogFolder,wpContentOriginalFolder,backupFolder):
        print &quot;Could not backup blog or wp-config.ph, aborting.&quot;
        return False

    if currentBlogFolder == 'wordpress':
        print &quot;The current blog folder cannot be 'wordpress, aborting.&quot;
        return False

    #1. If a wordpress/ folder exists, wipe it.
    if dirExists('wordpress'):
        print &quot;Removing old wordpress folder&quot;
        os.system('rm -fr wordpress')

    if dirExists('%s.delete' % currentBlogFolder):
        print &quot;Removing old %s.delete folder&quot; % currentBlogFolder
        os.system('rm -fr %s.delete folder' % currentBlogFolder)

    #2. Unzip new copy
    os.system('unzip latest.zip')

    if not dirExists('wordpress'):
        print &quot;Could not unzip the wordpress installation, aborting.&quot;
        return False

    #1. Copy wp-config.php into the new installation
    os.system('cp wp-config.php wordpress/')

    #2. Remove the default wp-content folder
    os.system('rm -fr wordpress/wp-content')

    #3. Symlink the original wp-content that lives outside
    os.system('ln -s %s wordpress/wp-content' % (wpContentOriginalFolder))

    #4. Verify symlink was created
    if not (os.path.exists('wordpress/wp-content') and os.path.islink('wordpress/wp-content')):
        print &quot;Could not create symlink to wp-content, aborting.&quot;
        return False

    #5. Move original folder to folder.delete, and make this wordpress folder the current folder.
    os.system('mv %s %s.delete' % (currentBlogFolder,currentBlogFolder))

    if not dirExists(currentBlogFolder + &quot;.delete&quot;):
        print &quot;Could not rename current folder for later deletion, aborting.&quot;
        return False

    #6. Rename the new installation as the current blog
    os.system('mv %s %s' % ('wordpress',currentBlogFolder))

    if dirExists('wordpress'):
        print &quot;ALERT: The wordpress folder still exists.&quot;
        return False

    if not dirExists(currentBlogFolder):
        print &quot;ALERT: The blog doesn't exist, recover from the backup folder %s please&quot; % (backupFolder)
        return False

    #7 Cleanup
    os.system('rm -fr %s.delete' % (currentBlogFolder))

    return True

if __name__ == '__main__':
    upgradeBlog()
</pre>
<p><strong>Requirements</strong></p>
<li>shell access to the machine where you have your wordpress installed</li>
<li>a python interpreter installed</li>
<li>curl (sudo apt-get install curl) to download the zip. If you don&#8217;t have it it&#8217;ll attempt to use wget</li>
<p><strong>Installation</strong></p>
<li>Right outside your wordpress installation folder, create a new file called <strong>upgrade_wordpress.py</strong></li>
<li>Copy and paste the script inside that file</li>
<li>Edit the configuration variables to point to the name of your wordpress installation folder, and give it a full path to where you want to keep your wp-content folder (including the name of the folder, so if you want to name it the same way, you could do for example /home/user/wp-content and it&#8217;ll be saved right under your home)</li>
<p><strong>Usage:</strong></p>
<pre class="brush: bash; title: ; notranslate">python upgrade_wordpress.py</pre>
<p>The script is very fault proof, it will always try to abort in case something is not going the way it&#8217;s expected. At the end of the day it&#8217;ll also leave a backup copy of your current blog in case something goes bad, you can always recover.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F&amp;title=Python+Script+to+Update+Wordpress+in+One+Step" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F&amp;title=Python+Script+to+Update+Wordpress+in+One+Step" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F&amp;title=Python+Script+to+Update+Wordpress+in+One+Step" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F&amp;headline=Python+Script+to+Update+Wordpress+in+One+Step" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Python+Script+to+Update+Wordpress+in+One+Step&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Python+Script+to+Update+Wordpress+in+One+Step&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Python+Script+to+Update+Wordpress+in+One+Step&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Python+Script+to+Update+Wordpress+in+One+Step&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Python+Script+to+Update+Wordpress+in+One+Step&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F&amp;title=Python+Script+to+Update+Wordpress+in+One+Step&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F26%2Fpython-script-to-update-wordpress-in-one-step%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/11/26/python-script-to-update-wordpress-in-one-step/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cola: Real-Time Remote Pair coding</title>
		<link>http://www.gubatron.com/blog/2008/11/25/cola-real-time-remote-pair-coding/</link>
		<comments>http://www.gubatron.com/blog/2008/11/25/cola-real-time-remote-pair-coding/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 00:03:24 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[extreme programing]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[pair coding]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=1012</guid>
		<description><![CDATA[This is not new, but I hadn&#8217;t seen it, so maybe you didn&#8217;t either, I&#8217;ll let the video speak for itself, I&#8217;m speechless. Thanks to Daniel Chang for sharing this with me. Cola: Real-Time Shared Editing from Mustafa K. Isik on Vimeo.]]></description>
			<content:encoded><![CDATA[<p>This is not new, but I hadn&#8217;t seen it, so maybe you didn&#8217;t either, I&#8217;ll let the video speak for itself, I&#8217;m speechless.</p>
<p>Thanks to Daniel Chang for sharing this with me.</p>
<p><object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=1195398&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=1195398&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object><br /><a href="http://vimeo.com/1195398">Cola: Real-Time Shared Editing</a> from <a href="http://vimeo.com/mustafa">Mustafa K. Isik</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F&amp;title=Cola%3A+Real-Time+Remote+Pair+coding" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F&amp;title=Cola%3A+Real-Time+Remote+Pair+coding" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F&amp;title=Cola%3A+Real-Time+Remote+Pair+coding" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F&amp;headline=Cola%3A+Real-Time+Remote+Pair+coding" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Cola%3A+Real-Time+Remote+Pair+coding&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Cola%3A+Real-Time+Remote+Pair+coding&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Cola%3A+Real-Time+Remote+Pair+coding&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Cola%3A+Real-Time+Remote+Pair+coding&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Cola%3A+Real-Time+Remote+Pair+coding&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F&amp;title=Cola%3A+Real-Time+Remote+Pair+coding&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F25%2Fcola-real-time-remote-pair-coding%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/11/25/cola-real-time-remote-pair-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java/Reflection notes: Invoking a static main() method from a dinamically loaded class.</title>
		<link>http://www.gubatron.com/blog/2008/11/22/javareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class/</link>
		<comments>http://www.gubatron.com/blog/2008/11/22/javareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 20:02:30 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[reflection]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=980</guid>
		<description><![CDATA[Maybe for some wild reason, your Java application will need to execute a pre launcher that won&#8217;t know about the Main class it&#8217;s supposed to invoke until it&#8217;s being executed. For example, you have distributed your Java application but you used pack200 to compress your jars, and your new application launcher will unpack everything, but [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3009/3050249135_841fd90b5b_m.jpg" class="alignleft"/>Maybe for some wild reason, your Java application will need to execute a pre launcher that won&#8217;t know about the Main class it&#8217;s supposed to invoke until it&#8217;s being executed. For example, you have distributed your Java application but you used pack200 to compress your jars, and your new application launcher will unpack everything, but up to this point, it can&#8217;t do an import of the main class, since the jar that contained it, wasn&#8217;t available to the virtual machine when java was invoked.</p>
<p>So, your launcher class, finishes unpacking your jars, adds the jars to the current classloader, and now you need to invoke your <strong>Main.main(String[] args)</strong>. </p>
<p>This is how I managed to do it, using Java&#8217;s reflection mechanisms</p>
<pre class="brush: java; title: ; notranslate">
    public final void startMain(String[] args) {
        //this will create a new class loader out of all jars available, see below on next
        //code section of this blog post
        addJars2Classpath();

        try {
            //Instantiate the main class, and execute it's static main method
            Class clazz = jarsClassloader.loadClass(&quot;com.mycomp.somepackage.Main&quot;);
            Class[] argTypes = { args.getClass(), };
            Object[] passedArgs = { args };
            Method main = clazz.getMethod(&quot;main&quot;,argTypes);
            main.invoke(null, passedArgs);
        } catch (Exception e) {
            //oh oh
            e.printStackTrace();
        }

    } //startMain
</pre>
<p>In case you&#8217;re interested in how to add new Jars to the classpath during runtime, this is how I managed to do it:</p>
<pre class="brush: java; title: ; notranslate">
    /**
     * Adds all the newly available jars to the classpath
     */
    public final void addJars2Classpath() throws Exception {
        //Create a new class loader with all the jars.
        Object[] jars = getFiles(getApplicationResourcesJavaFolder(), &quot;.jar&quot;);
        URL[] jarUrls = new URL[jars.length];

        for (int i=0; i &lt; jars.length; i++) {
            URL jarURL = null;

            try {
                jarURL = new URL(&quot;jar:file:&quot;+(String) jars[i]+&quot;!/&quot;);
            } catch (Exception e) {
                //LOG.error(&quot;Bad URL for jar (&quot;+jarFile+&quot;):\n&quot;+e.toString()+&quot; (&quot;+jarURL+&quot;)\n&quot;);
                return;
            }

            jarUrls[i] = jarURL;
        }

        //and this guy here, is the classloader used to load
        jarsClassloader = URLClassLoader.newInstance(jarUrls);
      } //addJar2Classpath

    /**
     * Get a Object&lt;String&gt; array that contains the names of the files
     * that end with 'type' on the given folderPath
     *
     * e.g
     *
     * String[] jarFiles = getFiles(&quot;.&quot;,&quot;.jar&quot;);
     *
     */
    public final Object[] getFiles(String folderPath, String type) {
        File f = new File(folderPath);

        String[] files = f.list();

        Vector results = new Vector();

        for (int i=0; i &lt; files.length; i++) {
            if (files[i].endsWith(type)) {
                results.add((String) files[i]);
            }
        }

        if (results.size() == 0)
            return null;

        return results.toArray();
    } //getFiles
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F&amp;title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F&amp;title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F&amp;title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F&amp;headline=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class.&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F&amp;title=Java%2FReflection+notes%3A+Invoking+a+static+main%28%29+method+from+a+dinamically+loaded+class.&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F11%2F22%2Fjavareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/11/22/javareflection-notes-invoking-a-static-main-method-from-a-dinamically-loaded-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to filter logs in lighttpd</title>
		<link>http://www.gubatron.com/blog/2008/10/27/how-to-filter-logs-in-lighttpd/</link>
		<comments>http://www.gubatron.com/blog/2008/10/27/how-to-filter-logs-in-lighttpd/#comments</comments>
		<pubDate>Mon, 27 Oct 2008 15:59:04 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[accesslog]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filter out]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[mod_accesslog]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=913</guid>
		<description><![CDATA[I usually don&#8217;t keep lighttpd access logs turned on to avoid writing for every read, but there are times when you need to monitor what&#8217;s going on, and you&#8217;d like to have a high signal-to-noise ratio so it might be convenient to ignore all requests to .gif, .png, .jpg, .css, .ico and other urls on [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.lighttpd.net/" rel="nofollow" target="_blank"><img align="left" style="margin:5px 5px" src="http://www.lighttpd.net/light_logo.png" width="150" height="150" border="0"/></a> I usually don&#8217;t keep <a href="http://www.lighttpd.net/" rel="nofollow" target="_blank">lighttpd</a> access logs turned on to avoid writing for every read, but there are times when you need to monitor what&#8217;s going on, and you&#8217;d like to have a high signal-to-noise ratio so it might be convenient to ignore all requests to .gif, .png, .jpg, .css, .ico and other urls on your webserver.</p>
<p>To only log certain files, or to NOT log certain files, you resolve this the same way as you do every other thing in lighttpd&#8230; by matching lighttpd variables to regular expressions and applying the settings where they match.</p>
<pre class="brush: perl; title: ; notranslate">
# www -&gt; the main website
$HTTP[&quot;host&quot;] =~ &quot;^www.yoursite.com$&quot; {
  server.document-root = &quot;/var/www/www.yoursite.com&quot;
  server.errorlog = &quot;/var/log/lighttpd/www.yoursite.com/error.log&quot;

  #Only log non-css and images
  &lt;strong&gt;$HTTP[&quot;url&quot;] !~ &quot;(\.css|\.jpg|\.gif|\.png|\.ico)$&quot; {
    accesslog.filename = &quot;/var/log/lighttpd/www.yoursite.com/access.log&quot;
  }&lt;/strong&gt;
}
</pre>
<p>So in this example, we only log, where the URL doesn&#8217;t end with any of the &#8220;.css&#8221;, &#8220;.jpg&#8221;, &#8220;.gif&#8221;, &#8220;.png&#8221; or &#8220;.ico&#8221; extensions. We filter those out.</p>
<p>Hope this works for you.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F&amp;title=How+to+filter+logs+in+lighttpd" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F&amp;title=How+to+filter+logs+in+lighttpd" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F&amp;title=How+to+filter+logs+in+lighttpd" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F&amp;headline=How+to+filter+logs+in+lighttpd" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=How+to+filter+logs+in+lighttpd&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=How+to+filter+logs+in+lighttpd&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=How+to+filter+logs+in+lighttpd&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=How+to+filter+logs+in+lighttpd&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=How+to+filter+logs+in+lighttpd&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F&amp;title=How+to+filter+logs+in+lighttpd&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F27%2Fhow-to-filter-logs-in-lighttpd%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/10/27/how-to-filter-logs-in-lighttpd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apple Wireless Keyboard</title>
		<link>http://www.gubatron.com/blog/2008/10/23/apple-wireless-keyboard/</link>
		<comments>http://www.gubatron.com/blog/2008/10/23/apple-wireless-keyboard/#comments</comments>
		<pubDate>Thu, 23 Oct 2008 16:57:21 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Gubatron]]></category>
		<category><![CDATA[Videos]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[internet tv]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[slim]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[worn out]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=903</guid>
		<description><![CDATA[I just got a new Apple Wireless Keyboad. My laptop currently sits atop a Griffin Elevator, this keeps it cool and also helps keep my neck at a healthy angle, something I need given how many hours I spend on the computer. The problem with the Elevator is that after a while, your arms get [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3226/2966536939_dcaf59f79c.jpg?v=0"/></p>
<p>I just got a new <a href="http://store.apple.com/us/product/MB167LL/A" rel="nofollow" target="_blank">Apple Wireless Keyboad</a>. </p>
<p>My laptop currently sits atop a <a href="http://www.griffintechnology.com/products/elevator" rel="nofollow">Griffin Elevator</a>, this keeps it cool and also helps keep my neck at a healthy angle, something I need given how many hours I spend on the computer.</p>
<p>The problem with the Elevator is that after a while, your arms get tired and you end up resting your arms over your elbows, causing you elbow dryness and sometimes pain.</p>
<p><img src="http://farm4.static.flickr.com/3021/2966569457_b53916a60a.jpg?v=0"/></p>
<p>To rest my elbows and have an <a href="http://en.wikipedia.org/wiki/Ergonomics" rel="nofollow" target="_blank">ergonomic</a> posture, I needed a keyboard that was small enough to fit on my tight desk.</p>
<p>The other reason I got it was that the MacBook keyboard is extremely worn out.</p>
<p><img src="http://farm4.static.flickr.com/3224/2967384682_271babe6c3.jpg?v=0"/></p>
<p><strong>Getting used to the new keyboard</strong><br />
The function keyboard layout is a bit different from the one on the MacBook. It took me a couple hours getting used to the spacing between the keys, but now I&#8217;m fully used to it. The feeling of the keys going down is very addictive.</p>
<p><img src="http://farm4.static.flickr.com/3233/2967383350_95fa7af130.jpg?v=0"/></p>
<p>Since the keyboard is wireless, I&#8217;m planning on getting another one to put it in front of the TV. Once <a href="boxee.tv" target="_blank">Boxee</a> integrates Joost and Hulu perfectly into the system, getting an Apple TV or a cheap custom built computer as a media center will make a lot of sense. </p>
<p>I&#8217;ve been hooking up the laptop via HDMI to the TV, and it sucks every time an episode ends in Hulu, or when there are commercial breaks on the ABC.com HD player because you have to get up and click on continue, or select the next episode to watch (unless you have setup playlists previously). </p>
<p>A wireless mouse and keyboard solve that problem.</p>
<p><img src="http://farm4.static.flickr.com/3243/2966537755_accd94be36.jpg?v=0"/></p>
<p><strong>Useful for Internet TV</strong><br />
Another plus, it can work like a remote control, for your HDMI-TV/Laptop setup.</p>
<p>I can proudly say we&#8217;ve been Cable-TV free for over 10 months now (saving probably around $200), I &#8220;survive&#8221; on Netflix DVDs &#038; Streaming (can&#8217;t wait for the Xbox Live upgrade), <a href="http://www.joost.com" rel="nofollow" target="_blank">Joost</a> and <a href="http://www.hulu.com" target="_blank" rel="nofollow">Hulu</a>.</p>
<p>Given my past history of doing things 2-3 years before regular people, I can see a big future for the Internet TV/Video companies that survive this &#8220;crisis&#8221; (bullshit crisis really, go to Venezuela and see what a real crisis is), eventually the whole thing will be packed on little boxes and CableTV companies will be in trouble if they don&#8217;t jump on the I-watch-what-I-want-whenever-I-want-via-internet boat.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F&amp;title=Apple+Wireless+Keyboard" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F&amp;title=Apple+Wireless+Keyboard" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F&amp;title=Apple+Wireless+Keyboard" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F&amp;headline=Apple+Wireless+Keyboard" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Apple+Wireless+Keyboard&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Apple+Wireless+Keyboard&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Apple+Wireless+Keyboard&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Apple+Wireless+Keyboard&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Apple+Wireless+Keyboard&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F&amp;title=Apple+Wireless+Keyboard&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F10%2F23%2Fapple-wireless-keyboard%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/10/23/apple-wireless-keyboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google&#8217;s Chrome, no extensions? then no go</title>
		<link>http://www.gubatron.com/blog/2008/09/03/googles-chrome-no-extensions-then-no-go/</link>
		<comments>http://www.gubatron.com/blog/2008/09/03/googles-chrome-no-extensions-then-no-go/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 14:49:24 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Opinions]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[evil]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[google]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=843</guid>
		<description><![CDATA[Please correct me if I&#8217;m wrong, but I didn&#8217;t read any mention of Browser extensions on the chrome document, I read about plugins (these are more like Flash plugin and what not), but nothing about extensions. This probably means: &#8211; No StumbleUpon toolbar :( (I&#8217;m a stumbleupon.com addict, I feel crippled with chrome because of [...]]]></description>
			<content:encoded><![CDATA[<p>Please correct me if I&#8217;m wrong,  but I didn&#8217;t read any mention of Browser extensions on the chrome document, I read about plugins (these are more like Flash plugin and what not), but nothing about extensions.</p>
<p>This probably means:<br />
 &#8211; No StumbleUpon toolbar :( (I&#8217;m a stumbleupon.com addict, I feel crippled with chrome because of this)<br />
 &#8211; No Cool Iris<br />
 &#8211; No Twitter extensions<br />
 &#8211; No weather extensions<br />
 &#8211; No firebug-like extensions<br />
 &#8211; No toolbars of any kind<br />
 &#8211; No Synced bookmarks</p>
<p>This means a lot of businesses would die if people were to embrace an extension-less browser. I think it&#8217;s a little scary when you allow one of the most important websites of the world to run the browser industry. Let&#8217;s hope people will stay distributed around IE, Mozilla, Safari and chrome, and that they don&#8217;t become the defacto browser, cause then they would really run the show.</p>
<p>Remember Google, don&#8217;t be evil, right?</p>
<p><strong>Update:</strong><br />
Confirmed, no extensions as of this writing are available.</p>
<p>Taken from the <a rel="nofollow" href="http://dev.chromium.org/developers/faq" target="_blank">Chromium developer FAQ</a>:</p>
<blockquote><p>Q. How can I develop extensions for Chromium like in Firefox?<br />
A. Chromium doesn&#8217;t have an extension system yet. This is something we&#8217;re interested in adding in a future version.</p></blockquote>
<p><strong>To Mac Geeks</strong><br />
If you want to build it for mac, you can (supposedly, I&#8217;m in the process off, I&#8217;ll post screenshots or video if I manage to do it sucessfully)</p>
<p><a href="http://dev.chromium.org/developers/how-tos/build-instructions-os-x" rel="nofollow" target="_blank">Here are instructions</a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F&amp;title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F&amp;title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F&amp;title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F&amp;headline=Google%27s+Chrome%2C+no+extensions%3F+then+no+go" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Google%27s+Chrome%2C+no+extensions%3F+then+no+go&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F&amp;title=Google%27s+Chrome%2C+no+extensions%3F+then+no+go&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F09%2F03%2Fgoogles-chrome-no-extensions-then-no-go%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/09/03/googles-chrome-no-extensions-then-no-go/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Script to automatically detect and ban malicious IPs that try to brute force SSH accounts</title>
		<link>http://www.gubatron.com/blog/2008/05/29/script-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts/</link>
		<comments>http://www.gubatron.com/blog/2008/05/29/script-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts/#comments</comments>
		<pubDate>Thu, 29 May 2008 14:01:51 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[automatic banning]]></category>
		<category><![CDATA[ban]]></category>
		<category><![CDATA[banning]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=816</guid>
		<description><![CDATA[We&#8217;ve noticed that most of our servers have been under heavy attack from random IP addresses to break via SSH. With the help of the last post on how to ban an IP, and the following python script, you&#8217;ll be able to have a cronjob that runs once or twice a day and automagically bans [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve noticed that most of our servers have been under heavy attack from random IP addresses to break via SSH.</p>
<p>With the help of the last post on how to ban an IP, and the following python script, you&#8217;ll be able to have a cronjob that runs once or twice a day and automagically bans all the offending ips from ever trying to brute force their way in ever again.</p>
<p>touch and make executable a file called &#8220;detect_ssh_hostiles&#8221;</p>
<pre>
touch detect_ssh_hostiles
chmod +x detect_ssh_hostiles
</pre>
<p>Then copy the following code inside:</p>
<pre>
# Usage:
# python detect_ssh_hostiles [auth.log file path]
#
# Requirement: There should be "ban_ip" and "unban_ip" command availability on the path
#
# Note: you gotta have read permissions on the auth.log file and sudo
#       permissions for the script to ban the ips.

#If an IP meets this number of failed login attemmpts it will be banned
BAN_THRESHOLD = 7
SUSPECTS = {}

#Put here IP addresses you trust, could be making genuine login errors
SAFE_IPS = ['81.73.111.49','101.73.111.160','72.31.171.235','72.36.23.234','82.36.180.210','202.132.82.16']

import os
import sys
import re

BANNED = {}
def loadBanned():
  '''
  This function will load all the banned IPS into the BANNED Dict.
  It will also count how many times (by mistake) the same IP has
  been banned, and it will unban it, so that it will appear only once.
  '''
  global BANNED
  command = 'sudo iptables --list --numeric'
  try:
    p = os.popen(command,'rb')
  except Exception,e:
    print e
    sys.exit(1)

  line = '-'

  while line != '':
    line = p.readline().strip()

    if line.startswith("DROP"):
      parts = line.split()
      ip = parts[3]

      #add hit or register banned ip
      if BANNED.has_key(ip):
        BANNED[ip]+=1
      else:
        BANNED[ip]=1

  #Make sure banned IPs are banned only once
  for ip in BANNED:
    if BANNED[ip] > 1:
      print "IP %s has been banned %d times" % (ip, BANNED[ip])
      n=BANNED[ip]-1
      while n > 0:
        os.system("unban_ip %s" % ip)
        print ("unban_ip %s" % ip)
        n=n-1

  p.close()

# ---- here we go ----
loadBanned()

#read auth log
logfile = '/var/log/auth.log'

if len(sys.argv)==2:
  logfile = sys.argv[1]

command = 'grep "Failed password for " %s' % logfile
#print command

try:
  p = os.popen(command,'rb')
except Exception,e:
  print e
  sys.exit(1)

line = "123"

while line != '':
  line = p.readline()

  #Sample line:
  # May 25 03:29:49 main sshd[6933]: Failed password for root from 202.118.236.132 port 54863 ssh2
  pattern = "(.*)(from\s)(\d+\.\d+\.\d+\.\d+)(.*)"
  matchObject = re.match(pattern, line)

  suspect = None
  if matchObject is not None:
    suspect = matchObject.groups()[2]

    #skip safe IPs
    if suspect in SAFE_IPS:
      continue

    if SUSPECTS.has_key(suspect):
      #add a hit
      SUSPECTS[suspect] += 1
    else:
      #add first hit
      SUSPECTS[suspect] = 1

p.close() #close the pipe

print "=="*30

import time
t = time.localtime()
#(2008, 6, 6, 9, 35, 21, 4, 158, 1)

timestr = "%d-%d-%d@%d:%d:%d" % (t[0],t[1],t[2],t[3],t[4],t[5])
print timestr
print "--"*30
if len(SUSPECTS) > 0:
  for suspect in SUSPECTS:
    if SUSPECTS[suspect] >= BAN_THRESHOLD and not BANNED.has_key(suspect):
      print "Banning %s with %d attempts" % (suspect,SUSPECTS[suspect])
      BANNED[suspect]=1
      os.system("ban_ip %s" % suspect)
    elif BANNED.has_key(suspect):
      print "Ip %s has already been banned" % (suspect)
    else:
      print "Suspect candidate? %s with %d attempts" % (suspect,SUSPECTS[suspect])
else:
  print "Found no suspects to ban"

print "=="*30</pre>
<p>Then add this as a cronjob of your root user, and it will automatically ban all those IPs that have tried to break in. See the script for configuration. You can always make some IPs immune to banning by adding them on the SAFE_IPS list.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F&amp;title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F&amp;title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F&amp;title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F&amp;headline=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F&amp;title=Script+to+automatically+detect+and+ban+malicious+IPs+that+try+to+brute+force+SSH+accounts&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fscript-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/05/29/script-to-automatically-detect-and-ban-malicious-ips-that-try-to-brute-force-ssh-accounts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to ban/unban ips in linux</title>
		<link>http://www.gubatron.com/blog/2008/05/29/how-to-banunban-ips-in-linux/</link>
		<comments>http://www.gubatron.com/blog/2008/05/29/how-to-banunban-ips-in-linux/#comments</comments>
		<pubDate>Thu, 29 May 2008 14:00:59 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[ban]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[unban]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=814</guid>
		<description><![CDATA[In case you&#8217;re not an iptables guru, you might want to create a couple scripts and put em somewhere on your $PATH. I&#8217;ve created two scripts called ban_ip and unban_ip. Create a file called ban_ip touch ban_ip chmod +x ban_ip Edit it and copy the following code inside: #!/bin/bash sudo iptables -A INPUT -s $1 [...]]]></description>
			<content:encoded><![CDATA[<p>In case you&#8217;re not an iptables guru, you might want to create a couple scripts and put em somewhere on your $PATH. I&#8217;ve created two scripts called <strong>ban_ip</strong> and <strong>unban_ip</strong>. </p>
<p>Create a file called ban_ip</p>
<pre>
touch ban_ip
chmod +x ban_ip
</pre>
<p>Edit it and copy the following code inside:</p>
<pre>
#!/bin/bash
sudo iptables -A INPUT -s $1 -j DROP
echo IP Address $1 has been banned
echo
</pre>
<p>To ban an IP, you must invoke</p>
<pre>ban_ip &lt;someIpAddressHere&gt;</pre>
<p>e.g.</p>
<pre>ban_ip 211.32.44.111</pre>
<p>And the IP will be banned.</p>
<p>Do the same now for the unban_ip script</p>
<pre>
touch unban_ip
chmod +x unban_ip
</pre>
<p>Open your fav. text editor and copy the following code inside:</p>
<pre>
#!/bin/bash
iptables -D INPUT -s $1 -j DROP
echo Unbanned ip $1
echo
</pre>
<p>Save it, and use it.</p>
<p>To unban an IP, you must invoke</p>
<pre>unban_ip &lt;someIpAddressHere&gt;</pre>
<p>e.g.</p>
<pre>unban_ip 211.32.44.111</pre>
<p><strong>Requirements</strong><br />
Have sudo access, have iptables installed.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F&amp;title=How+to+ban%2Funban+ips+in+linux" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F&amp;title=How+to+ban%2Funban+ips+in+linux" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F&amp;title=How+to+ban%2Funban+ips+in+linux" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F&amp;headline=How+to+ban%2Funban+ips+in+linux" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=How+to+ban%2Funban+ips+in+linux&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=How+to+ban%2Funban+ips+in+linux&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=How+to+ban%2Funban+ips+in+linux&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=How+to+ban%2Funban+ips+in+linux&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=How+to+ban%2Funban+ips+in+linux&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F&amp;title=How+to+ban%2Funban+ips+in+linux&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F29%2Fhow-to-banunban-ips-in-linux%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/05/29/how-to-banunban-ips-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function callbacks in C</title>
		<link>http://www.gubatron.com/blog/2008/05/02/function-callbacks-in-c/</link>
		<comments>http://www.gubatron.com/blog/2008/05/02/function-callbacks-in-c/#comments</comments>
		<pubDate>Fri, 02 May 2008 19:46:27 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[function pointers]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=799</guid>
		<description><![CDATA[Ever since I started programming in Javascript, and doing asynchronous function calls, I&#8217;ve found myself to be addicted to passing functions as parameters. I do it a lot in python and php, it&#8217;s very easy to do this on all these dynamic typed languages. I never had this concept of passing functions as parameters, or [...]]]></description>
			<content:encoded><![CDATA[<p>Ever since I started programming in Javascript, and doing asynchronous function calls, I&#8217;ve found myself to be addicted to passing functions as parameters.</p>
<p>I do it a lot in python and php, it&#8217;s very easy to do this on all these dynamic typed languages.</p>
<p>I never had this concept of passing functions as parameters, or pointers to functions as parameters when I was a kid in school and we were doing stuff in C or Pascal, I&#8217;d deal with it with ifs and switches.</p>
<p>So, this afternoon I decided to read a little bit and give it a try in C.</p>
<p>Here&#8217;s some code for future reference If I ever need it, it&#8217;s pretty easy.</p>
<pre>
#include <stdio.h>
void this() { printf("This\n"); }
void that() { printf("That\n"); }

int sum(int x, int y) {	return x+y; }

int mul(int x, int y) { return x*y; }

//Function that takes a callback that uses no parameters
void callanother(void (*callback)()) {
  (*callback)();
}

//Function that takes a callback that
//takes 2 int parameters and returns int
int callComplexCallback(int (*callback)(),int a, int b) {
  return (*callback)(a,b);
}

int main (int argc, char** argv) {
  callanother(this);
  callanother(that);

  printf("\n");

  int w = 20;
  int h = 30;

  printf("%d\n",callComplexCallback(sum,w,h));
  printf("%d\n",callComplexCallback(mul,w,h));

  //this also works
  printf("%d\n",callComplexCallback((*sum),w,h));
  printf("%d\n",callComplexCallback((*mul),w,h));

  return 0;
}
</pre>
<p>The output is this:</p>
<pre>
~$ ./a.out
This
That

50
600
50
600
</pre>
<p>The whole trick is how you define the function that will take the other function as a parameter.</p>
<p>If you have a function:</p>
<pre>
void whatever();
</pre>
<p>The function that&#8217;s supposed to use &#8220;whatever()&#8221; like-functions should look:</p>
<pre>
void useWhateverLikeFunctions(void (*f)()) {
  ...
  (*f)();
}
</pre>
<p>If you have a callback function that needs parameters, then you define the caller as:</p>
<pre>
void callerFunction(void (*f),int paramA, int* paramB, char paramC) {
  ...
  (*f)(paramA,paramB,paramC);
}
</pre>
<p>Then you&#8217;d use the function</p>
<pre>
void someCallback(int a, int* b, char c);

...
callerFunction(someCallback,a,b,c);
...
</pre>
<p>I know this is the oldest thing in the world to C programmers, but it never crossed my mind before, so here it is for my own personal reference, I hope it serves others.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F&amp;title=Function+callbacks+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F&amp;title=Function+callbacks+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F&amp;title=Function+callbacks+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F&amp;headline=Function+callbacks+in+C" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Function+callbacks+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Function+callbacks+in+C&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Function+callbacks+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Function+callbacks+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Function+callbacks+in+C&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F&amp;title=Function+callbacks+in+C&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Ffunction-callbacks-in-c%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/05/02/function-callbacks-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs doesn&#8217;t work after Leopard upgrade?</title>
		<link>http://www.gubatron.com/blog/2008/05/02/emacs-doesnt-work-after-leopard-upgrade/</link>
		<comments>http://www.gubatron.com/blog/2008/05/02/emacs-doesnt-work-after-leopard-upgrade/#comments</comments>
		<pubDate>Fri, 02 May 2008 13:29:54 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[fix]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[macosx]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=796</guid>
		<description><![CDATA[After updating from Tiger to Leopard I started getting this error whener I tried to execute emacs: Fatal malloc_jumpstart() error The solution was basically to reinstall it with dumpemacs sudo mv /usr/bin/emacs-i386 /usr/bin/emacs-i386.backup sudo /usr/libexec/dumpemacs -d emacs --version emacs Via Apple Support Discussions]]></description>
			<content:encoded><![CDATA[<p>After updating from Tiger to Leopard I started getting this error whener I tried to execute emacs:</p>
<p><code><br />
Fatal malloc_jumpstart() error<br />
</code></p>
<p>The solution was basically to reinstall it with dumpemacs</p>
<p><code><br />
sudo mv /usr/bin/emacs-i386 /usr/bin/emacs-i386.backup<br />
sudo /usr/libexec/dumpemacs -d<br />
emacs --version<br />
emacs<br />
</code></p>
<p><a href="http://discussions.apple.com/thread.jspa?messageID=5747427">Via Apple Support Discussions</a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F&amp;title=emacs+doesn%27t+work+after+Leopard+upgrade%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F&amp;title=emacs+doesn%27t+work+after+Leopard+upgrade%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F&amp;title=emacs+doesn%27t+work+after+Leopard+upgrade%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F&amp;headline=emacs+doesn%27t+work+after+Leopard+upgrade%3F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=emacs+doesn%27t+work+after+Leopard+upgrade%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=emacs+doesn%27t+work+after+Leopard+upgrade%3F&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=emacs+doesn%27t+work+after+Leopard+upgrade%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=emacs+doesn%27t+work+after+Leopard+upgrade%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=emacs+doesn%27t+work+after+Leopard+upgrade%3F&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F&amp;title=emacs+doesn%27t+work+after+Leopard+upgrade%3F&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F05%2F02%2Femacs-doesnt-work-after-leopard-upgrade%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/05/02/emacs-doesnt-work-after-leopard-upgrade/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blooploader 0.6 is Hardy compatible</title>
		<link>http://www.gubatron.com/blog/2008/04/26/blooploader-06-is-hardy-compatible/</link>
		<comments>http://www.gubatron.com/blog/2008/04/26/blooploader-06-is-hardy-compatible/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 21:28:47 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[MyBloop.com]]></category>
		<category><![CDATA[blooploader]]></category>
		<category><![CDATA[file sharing]]></category>
		<category><![CDATA[file storage]]></category>
		<category><![CDATA[hardy]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mybloop]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[uploading]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/?p=788</guid>
		<description><![CDATA[Blooploader 0.6 running on Hardy. Currently available only via subversion. For our Linux users, you can safely update to Ubuntu Hardy if the one thing holding your breath was compatibility with the Blooploader. Currently we run the Blooploader in Linux from source, you just need to have installed, Qt4, sip4, and PyQt4 on your machine. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://farm4.static.flickr.com/3273/2440701311_394f9216d1_o.png"><img src="http://farm4.static.flickr.com/3273/2440701311_9733eb15cd_m.jpg" align="left" style="margin:10px 10px" border="0"/></a><br />
Blooploader 0.6 running on Hardy. Currently available only via subversion.</p>
<p>For our Linux users, you can safely update to Ubuntu Hardy if the one thing holding your breath was compatibility with the Blooploader.</p>
<p>Currently we run the Blooploader in Linux from source, you just need to have installed, Qt4,  sip4, and PyQt4 on your machine. If you are an Ubuntu user this translates to:</p>
<ol>
<li>Checking out the source from our <a href="http://code.google.com/p/blooploader/source/checkout">subversion repository</a></li>
<li>sudo apt-get install python-sip4 python-qt4 python-qt-4-common</li>
<li>./run</li>
</ol>
<p>For those of you that want to try the Blooploader in Ubuntu, and you have no clue on how to use the command line, we promise we&#8217;ll have a new .deb installer for our next release now that Hardy has enabled binary packages on their repository for all our dependencies.</p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F&amp;title=Blooploader+0.6+is+Hardy+compatible" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F&amp;title=Blooploader+0.6+is+Hardy+compatible" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F&amp;title=Blooploader+0.6+is+Hardy+compatible" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F&amp;headline=Blooploader+0.6+is+Hardy+compatible" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=Blooploader+0.6+is+Hardy+compatible&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=Blooploader+0.6+is+Hardy+compatible&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=Blooploader+0.6+is+Hardy+compatible&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=Blooploader+0.6+is+Hardy+compatible&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=Blooploader+0.6+is+Hardy+compatible&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F&amp;title=Blooploader+0.6+is+Hardy+compatible&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fblooploader-06-is-hardy-compatible%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/04/26/blooploader-06-is-hardy-compatible/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Pirate Bay, err, The Liberty Bay</title>
		<link>http://www.gubatron.com/blog/2008/04/26/the-pirate-bay-err-the-liberty-bay/</link>
		<comments>http://www.gubatron.com/blog/2008/04/26/the-pirate-bay-err-the-liberty-bay/#comments</comments>
		<pubDate>Sat, 26 Apr 2008 19:20:25 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[gta]]></category>
		<category><![CDATA[piratebay]]></category>
		<category><![CDATA[pissing people]]></category>
		<category><![CDATA[screenshot]]></category>
		<category><![CDATA[thepiratebay]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/2008/04/26/the-pirate-bay-err-the-liberty-bay/</guid>
		<description><![CDATA[A Screenshot of today&#8217;s ThePirateBay.org homepage. &#8220;Hint Hint?&#8221; These guys certainly like to piss people off to get media attention and more traffic for that high priced CPM they must have.read more &#124; digg story]]></description>
			<content:encoded><![CDATA[<p><a href="http://flickr.com/photos/gubatron/2443825378/sizes/o/"><img src="http://farm4.static.flickr.com/3292/2443825378_e83464e62f_m.jpg" border="0" align="right" style="margin:10px 10px"/></a><br />
A Screenshot of today&#8217;s <a href="http://www.thepiratebay.org">ThePirateBay.org</a> homepage.<br />
&#8220;Hint Hint?&#8221; These guys certainly like to piss people off to get media attention and more traffic for that high priced CPM they must have.<br/><br/><a href="http://flickr.com/photos/gubatron/2443825378/sizes/o/">read more</a> | <a href="http://digg.com/gaming_news/The_Pirate_Bay_err_The_Liberty_Bay">digg story</a></p>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F&amp;title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F&amp;title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F&amp;title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F&amp;headline=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F&amp;title=The+Pirate+Bay%2C+err%2C+The+Liberty+Bay&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F04%2F26%2Fthe-pirate-bay-err-the-liberty-bay%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/04/26/the-pirate-bay-err-the-liberty-bay/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[Python] ip2num / num2ip &#8211; Store an IP string as a 4 byte int.</title>
		<link>http://www.gubatron.com/blog/2008/03/27/python-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int/</link>
		<comments>http://www.gubatron.com/blog/2008/03/27/python-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 16:40:37 +0000</pubDate>
		<dc:creator>gubatron</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Geeklife]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[bytes]]></category>
		<category><![CDATA[ip2num]]></category>
		<category><![CDATA[num2ip]]></category>

		<guid isPermaLink="false">http://www.gubatron.com/blog/2008/03/27/python-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int/</guid>
		<description><![CDATA[This is probably everywhere, maybe python also comes with it, but I wanted to have my own implementation, and I&#8217;ll leave it here for future reference. Basically, sometimes you don&#8217;t want to store IPs in Strings cause they take too much space, instead you want to be a good programmer and store them as 4 [...]]]></description>
			<content:encoded><![CDATA[<p>This is probably everywhere, maybe python also comes with it, but I wanted to have my own implementation, and I&#8217;ll leave it here for future reference.</p>
<p>Basically, sometimes you don&#8217;t want to store IPs in Strings cause they take too much space, instead you want to be a good programmer and store them as 4 bytes (IPv4 that is).</p>
<p>So here&#8217;s a couple of functions in python to illustrate the conversion process between string to 4 byte integer, or viceversa:</p>
<pre>
def ip2num(ipString):
    if ipString is None:
        raise Exception("Invalid IP")

    try:
       octets = [octet.strip() for octet in ipString.split('.')]
    except Exception,e:
        raise e

    num = (int(octets[0])<<24) + (int(octets[1])<<16) + (int(octets[2])<<8) + int(octets[3])
    return num

def num2ip(numericIp):
    if numericIp is None or type(numericIp) != int:
        raise Exception("Invalid numeric IP. Must be an integer")
    return str(numericIp >> 24) + '.' + str((numericIp >> 16) &#038; 255) + '.' + str((numericIp >> 8) &#038; 255) + '.' + str(numericIp &#038; 255)
</pre>
<div class="lightsocial_container"><a class="lightsocial_a" href="http://digg.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F&amp;title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/digg.png" alt="Digg This" title="Digg This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.reddit.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F&amp;title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/reddit.png" alt="Reddit This" title="Reddit This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F&amp;title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/stumbleupon.png" alt="Stumble Now!" title="Stumble Now!" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://buzz.yahoo.com/buzz?targetUrl=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F&amp;headline=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int." ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/yahoo_buzz.png" alt="Buzz This" title="Buzz This" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dzone.com/links/add.html?title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dzone.png" alt="Vote on DZone" title="Vote on DZone" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.facebook.com/sharer.php?t=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int.&amp;u=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/facebook.png" alt="Share on Facebook" title="Share on Facebook" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://delicious.com/save?title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/delicious.png" alt="Bookmark this on Delicious" title="Bookmark this on Delicious" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.dotnetkicks.com/kick/?title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetkicks.png" alt="Kick It on DotNetKicks.com" title="Kick It on DotNetKicks.com" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://dotnetshoutout.com/Submit?title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int.&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/dotnetshoutout.png" alt="Shout it" title="Shout it" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F&amp;title=%5BPython%5D+ip2num+%2F+num2ip+-+Store+an+IP+string+as+a+4+byte+int.&amp;summary=&amp;source=" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/linkedin.png" alt="Share on LinkedIn" title="Share on LinkedIn" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/technorati.png" alt="Bookmark this on Technorati" title="Bookmark this on Technorati" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://twitter.com/home?status=Reading+http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/twitter.png" alt="Post on Twitter" title="Post on Twitter" /></a>&nbsp;&nbsp;<a class="lightsocial_a" href="http://www.google.com/buzz/post?url=http%3A%2F%2Fwww.gubatron.com%2Fblog%2F2008%2F03%2F27%2Fpython-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int%2F" ><img class="lightsocial_img" src="http://www.gubatron.com/blog/wp-content/plugins/light-social/google_buzz.png" alt="Google Buzz (aka. Google Reader)" title="Google Buzz (aka. Google Reader)" /></a>&nbsp;&nbsp;</div>]]></content:encoded>
			<wfw:commentRss>http://www.gubatron.com/blog/2008/03/27/python-ip2num-num2ip-store-an-ip-string-as-a-4-byte-int/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
