<?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>Ole Bakstad&#039;s blog &#187; Programming</title>
	<atom:link href="http://dibon.net/wordpress/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://dibon.net/wordpress</link>
	<description>About stuff that happens, when it happens, if it happens.</description>
	<lastBuildDate>Mon, 15 Jun 2009 20:08:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Use twitter from the terminal!</title>
		<link>http://dibon.net/wordpress/use-twitter-from-terminal/</link>
		<comments>http://dibon.net/wordpress/use-twitter-from-terminal/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 22:43:12 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[terminal]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=77</guid>
		<description><![CDATA[Today I decided that I&#8217;m going to give twitter another try, but the first thing that struck me was how cumbersome it was to actually post a tweet.
The way I did it:

Open your favourite browser
Go to twitter.com
Log in
Write a tweet

I&#8217;m a Linux user and I love the terminal. Wouldn&#8217;t it be better to write tweets [...]]]></description>
			<content:encoded><![CDATA[<p>Today I decided that I&#8217;m going to give <a href="http://twitter.com">twitter</a> another try, but the first thing that struck me was how cumbersome it was to actually post a tweet.</p>
<p>The way I did it:</p>
<ol>
<li>Open your favourite browser</li>
<li>Go to twitter.com</li>
<li>Log in</li>
<li>Write a tweet</li>
</ol>
<p>I&#8217;m a Linux user and I love the terminal. Wouldn&#8217;t it be better to write tweets from the terminal? &#8211; Yes it would!</p>
<p>I have written a quick and dirty python script that enables you to write tweets from the terminal.</p>
<p>You can download the script <a href="http://dibon.net/tweet" target="_blank">here</a>.</p>
<h5>Install guide for Debian:</h5>
<p><strong>Step 1: Download<br />
</strong></p>
<p><code>$ wget http://dibon.net/tweet<br />
$ chmod +x tweet<br />
$ sudo mv tweet /usr/bin/</code></p>
<p><strong>Step 2: Install curl</strong></p>
<p>The script uses curl to send data to twitter, if you don&#8217;t have curl installed you have to install it:</p>
<p><code>$ sudo aptitude install curl</code></p>
<p><strong>Step 3: Make the config</strong></p>
<p>Make a file called &#8220;.tweet&#8221; in your home directory:</p>
<p><code>$ vim .tweet</code></p>
<p>And insert the following:</p>
<p><code>[login]<br />
username = YOURUSERNAME<br />
password = YOURPASSWORD</code></p>
<p>You may want to edit the permissions for the file</p>
<p><code>$ chmod 0700 .tweet</code></p>
<p>That&#8217;s about it. You may have you reopen your terminal window before you can use the tweet command.</p>
<p><strong>Usage:</strong></p>
<p><code>$ tweet "I'm writing a tweet in terminal!"</code></p>
<p>Unfortunately it is necessary to use single or double quotes before and after the message.</p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/use-twitter-from-terminal/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Tech Talk: Java Puzzlers</title>
		<link>http://dibon.net/wordpress/google-tech-talk-java-puzzlers/</link>
		<comments>http://dibon.net/wordpress/google-tech-talk-java-puzzlers/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 19:21:55 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[advanced]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[puzzles]]></category>
		<category><![CDATA[talk]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=32</guid>
		<description><![CDATA[Tobias found this cool Google Tech Talk about Advanced Topics in Programming Languages: Java Puzzlers.
The puzzles are sometimes very non-intuitive, and is mostly results of bad API&#8217;s or other strange features. Some of the puzzles aren&#8217;t very useful, but it&#8217;s always nice to have a deep understanding of a programming language.
Watch the talk a YouTube:

]]></description>
			<content:encoded><![CDATA[<p><a href="http://saiboten.com/blog/">Tobias</a> found this cool <a href="http://research.google.com/video.html">Google Tech Talk</a> about Advanced Topics in Programming Languages: Java Puzzlers.</p>
<p>The puzzles are sometimes very non-intuitive, and is mostly results of bad API&#8217;s or other strange features. Some of the puzzles aren&#8217;t very useful, but it&#8217;s always nice to have a deep understanding of a programming language.</p>
<p>Watch the talk a YouTube:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/wDN_EYUvUq0&amp;eurl" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/wDN_EYUvUq0&amp;eurl"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/google-tech-talk-java-puzzlers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learn Python in 10 minutes</title>
		<link>http://dibon.net/wordpress/learn-python-in-10-minutes/</link>
		<comments>http://dibon.net/wordpress/learn-python-in-10-minutes/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 21:25:11 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[10]]></category>
		<category><![CDATA[learn]]></category>
		<category><![CDATA[minutes]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=31</guid>
		<description><![CDATA[My friend He Yu provided me with a link where you can learn Python in 10 minutes. A nice introduction to Python assuming that you know general programming.
I&#8217;m looking into Python for two reasons. One; I want to expand my knowledge of programming languages. Two; Next term I&#8217;m taking the course Introduction to Algorithms where [...]]]></description>
			<content:encoded><![CDATA[<p>My friend He Yu provided me with a link where you can <a href="http://www.poromenos.org/tutorials/python" target="_blank">learn Python in 10 minutes</a>. A nice introduction to Python assuming that you know general programming.</p>
<p>I&#8217;m looking into Python for two reasons. One; I want to expand my knowledge of programming languages. Two; Next term I&#8217;m taking the course Introduction to Algorithms where Python is the language we will be using. It&#8217;s always nice to have a head start.</p>
<p><strong>Update</strong>:</p>
<p>It turns out that the professor teaching the course has written <a href="http://hetland.org/writing/">books</a> about Python and also written a short tutorial. <a href="http://hetland.org/writing/instant-python.html">Click here for tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/learn-python-in-10-minutes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to use and write snippets</title>
		<link>http://dibon.net/wordpress/how-to-use-and-write-snippets/</link>
		<comments>http://dibon.net/wordpress/how-to-use-and-write-snippets/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 16:27:26 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[gedit]]></category>
		<category><![CDATA[saver]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[textmate]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=25</guid>
		<description><![CDATA[In TextMate and in gedit (probably more editors too) you have the option to use snippets. I love snippets, and they make my day much easier.
To make a snippet you have to define a tab-trigger which is a word or a random sequence of characters that you will remember. Then you have to write the [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://macromates.com/" target="_blank">TextMate</a> and in <a href="http://www.gnome.org/projects/gedit/" target="_blank">gedit</a> (probably more editors too) you have the option to use <a href="http://en.wikipedia.org/wiki/Code_snippets" target="_blank">snippets</a>. I love snippets, and they make my day much easier.</p>
<p>To make a snippet you have to define a tab-trigger which is a word or a random sequence of characters that you will remember. Then you have to write the snippet body.</p>
<p><strong>Easy example</strong>: If and else statements. When you write &#8220;ife&#8221; and press tab you want an if-else statement to pop up. We write the snippet:</p>
<div class="geshi no php">
<div class="head">if($1)</div>
<ol>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; $<span class="nu0">2</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">else</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; $<span class="nu0">0</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>$0, $1 and $2 are where the cursor will be placed. When you first type &#8220;ife&#8221; and press the tab button the cursor will be where the $1 is. If you hit tab again the cursor moves to $2 and so on, but you always ends up at $0. Now you can use this snippet whenever you need it. Just write &#8220;ife&#8221; press tab and fill inn the code you need.</p>
<p><strong>More advanced example</strong>: Lets say you are getting tired of writing all the code for a for loop every time you need one. Make a snippet!. We set the tab-trigger to be the string &#8220;for&#8221; and write the snippet:</p>
<div class="geshi no php">
<div class="head">for (\$${1:i}=${2:0}; \$${1:i} &lt; $3; \$${1:i}++)</div>
<ol>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; $<span class="nu0">0</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>What the ${1:i} does is that it sets the 1st cursor position <em>and</em> sets a default value (&#8220;i&#8221; in this case). The default value is marked, so when you tab to the position you can immediately overwrite the default text. And an other thing in this example worth mentioning is that we use ${1:i} more than once. This enables you to change the default at more than one place at once. Let&#8217;s say you don&#8217;t want your variable called &#8220;i&#8221;, but &#8220;index&#8221;. You still just write &#8220;for&#8221;, press tab, and &#8220;i&#8221; is marked. You now write &#8220;index&#8221;, and the &#8220;i&#8221; in all 3 places where it&#8217;s used will change to &#8220;index&#8221;. Then tab again to set the start value of the for loop, and yet again to set the max value for the loop. After choosing variable name, start value and max value you just have one tab left. The last tab brings to you $0 and you&#8217;re ready to write some code inside the for loop. If you tab one more time while the cursor is at $0 the tab sequence will start over.</p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/how-to-use-and-write-snippets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>gedit + plugins = \o/</title>
		<link>http://dibon.net/wordpress/gedit-plugins-o/</link>
		<comments>http://dibon.net/wordpress/gedit-plugins-o/#comments</comments>
		<pubDate>Tue, 17 Jun 2008 16:07:21 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Hints]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[gedit]]></category>
		<category><![CDATA[ide]]></category>
		<category><![CDATA[micah carrick]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=24</guid>
		<description><![CDATA[I&#8217;ve been looking for good editor for Ubuntu for a while, and I think I found it.  After reading Micah Carrick&#8217;s post on Customizing gedit as a Web Developer’s IDE I was amazed how much gedit with plug-ins could do. It almost have anything I want in an editor. I don&#8217;t know if I would [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking for good editor for Ubuntu for a while, and I think I found it.  After reading Micah Carrick&#8217;s post on <a href="http://www.micahcarrick.com/09-29-2007/gedit-html-editor.html" target="_blank">Customizing gedit as a Web Developer’s IDE</a> I was amazed how much gedit with plug-ins could do. It almost have anything I want in an editor. I don&#8217;t know if I would call it an IDE though. Missing debugging and CVS/SVN is kinda important in an IDE. There are debugging plug-ins for Perl and Python, but not for PHP, Java and JS (which is the languages I mostly use).</p>
<p>Personally I like the same preferences that Micah uses. I enable indent with 4 spaces, turn of line wrapping and enable line numbering. Read a more detailed description in Micah&#8217;s post.</p>
<p><strong style="font-size: 18px;">Plug-ins I use:</strong></p>
<p>- <strong><a href="http://www.garyharan.com/index.php/2006/11/16/gemini-gedit-plugin-for-all-those-textmate-fans/" target="_blank">Gemini</a></strong><br />
A plug-in which auto-completes parenthesis, brackets and so on (the  characters: &lt; { [ ' " " ' ] } &gt;) and nicely indents and places the cursor where you (me) want it. This plug-in is an absolute life saver!</p>
<p>Before return is pressed (notice that there is no &#8220;}&#8221;):</p>
<pre>{//Cursor here</pre>
<p>After return is pressed:</p>
<pre>{
    // Cursor here
}</pre>
<p>- <strong><a href="http://www.micahcarrick.com/11-14-2007/gedit-symbol-browser-plugin.html" target="_blank">Symbol Browser</a></strong><br />
Shows a list of classes, functions, enums and class fields.</p>
<p>- <strong>Snippets</strong><br />
This plug-in allows you to define snippets of codes which appear when you use a tab-trigger. This one saves you a lot of time. Make a for-loop with a few keystrokes. See my post on <a href="http://dibon.net/wordpress/?p=25" target="_blank">how to use snippets</a>.</p>
<p>Screenshot of my gedit (oblivion theme):</p>
<p><img class="alignnone size-full wp-image-26" title="gedit" src="http://dibon.net/wordpress/wp-content/uploads/2008/06/gedit.png" alt="" width="628" height="415" /></p>
<p>If you use an awesome plug-in or something for gedit please leave comment!</p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/gedit-plugins-o/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Amazing twelve year old talks about jQuery</title>
		<link>http://dibon.net/wordpress/amazing-twelve-year-old-talks-about-jquery/</link>
		<comments>http://dibon.net/wordpress/amazing-twelve-year-old-talks-about-jquery/#comments</comments>
		<pubDate>Mon, 16 Jun 2008 01:16:23 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[amazing]]></category>
		<category><![CDATA[dmitri]]></category>
		<category><![CDATA[gaskin]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[talks]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=23</guid>
		<description><![CDATA[I just found this amazing clip with the wonder child Dmitri Gaskin. He&#8217;s twelve years old, contributes to dupral, involved in the google summer of code and attending 6th grade classes! This is something you don&#8217;t see everyday. He talks a bit fast, but that&#8217;s just because he&#8217;s nervous. Anyways, a twelve year old kid [...]]]></description>
			<content:encoded><![CDATA[<p>I just found this amazing clip with the wonder child <span>Dmitri Gaskin. He&#8217;s twelve years old, </span><span>contributes to <a href="http://drupal.org/" target="_blank">dupral</a>, involved in the google summer of code and attending 6th grade classes! This is something you don&#8217;t see everyday. He talks a bit fast, but that&#8217;s just because he&#8217;s nervous. Anyways, a twelve year old kid on Google Tech Talks is damn impressive! </span></p>
<p>I just realized how powerful <a href="http://jquery.com/" target="_blank">jQuery</a> library is, and I will definitely start using it.</p>
<p>See the clip on YouTube:</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="350" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://www.youtube.com/v/8mwKq7_JlS8" /><embed type="application/x-shockwave-flash" width="425" height="350" src="http://www.youtube.com/v/8mwKq7_JlS8"></embed></object></p>
<p>Wish I was that smart when I were twelve years old :-|.</p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/amazing-twelve-year-old-talks-about-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>LaTeX in WP</title>
		<link>http://dibon.net/wordpress/testing-latex/</link>
		<comments>http://dibon.net/wordpress/testing-latex/#comments</comments>
		<pubDate>Sat, 24 May 2008 01:21:53 +0000</pubDate>
		<dc:creator>Ole Bakstad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[codecogs]]></category>
		<category><![CDATA[latex]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://dibon.net/wordpress/?p=12</guid>
		<description><![CDATA[I finally got LaTeX in WP! Now I can write [ tex ]  [ / tex ] and voilá! I&#8217;m now using a external site for rendering my equations, but as soon as I get the code running on my own server I will of course use my own.
To get this working I had [...]]]></description>
			<content:encoded><![CDATA[<p>I finally got <a href="http://en.wikipedia.org/wiki/LaTeX" target="_blank">LaTeX</a> in WP! Now I can write [ tex ]  [ / tex ] and voilá! I&#8217;m now using a <a href="http://www.codecogs.com/" target="_blank">external site</a> for rendering my equations, but as soon as I get the code running on my own server I will of course use my own.</p>
<p>To get this working I had to write a little plugin for WP, which was easier than I thought. Here is the code I&#8217;m using:</p>
<div class="geshi no php">
<div class="head">/*</div>
<ol>
<li class="li1">
<div class="de1">Plugin Name<span class="sy0">:</span> LaTeX</div>
</li>
<li class="li1">
<div class="de1">Version<span class="sy0">:</span> <span class="nu0">0.1</span></div>
</li>
<li class="li1">
<div class="de1">Author<span class="sy0">:</span> Ole</div>
</li>
<li class="li1">
<div class="de1"><span class="sy0">*/</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="kw2">function</span> addLatex<span class="br0">&#40;</span><span class="re1">$text</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="re1">$text</span> <span class="sy0">=</span> <span class="kw3">preg_replace</span><span class="br0">&#40;</span><span class="st0">&quot;/<span class="es0">\[</span>tex<span class="es0">\]</span>(.+)<span class="es0">\[</span><span class="es0">\/</span>tex<span class="es0">\]</span>/&quot;</span><span class="sy0">,</span><span class="st0">&#39;&lt;img src=&quot;http://www.codecogs.com/eq.latex?<span class="es0">\\</span>1&quot; alt=&quot;&quot; /&gt;&#39;</span><span class="sy0">,</span><span class="re1">$text</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">return</span> <span class="re1">$text</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">add_filter<span class="br0">&#40;</span><span class="st0">&#39;the_content&#39;</span><span class="sy0">,</span><span class="st0">&#39;addLatex&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
</ol>
</div>
<p>WP need the comment to get data about the plugin and you simply use the add_filter() to apply your own function on given data. Here I&#8217;m using addLatex() on the content.</p>
<p>Here is how it works:</p>
<p>[ tex ] V_{ind} = -\frac{d}{dt}{\int_A{\vec B d\vec A } = -\frac{d\Phi_B}{dt} =  -\frac{d}{dt}\left( \int_{a+vt}^{a+b+vt}{ \frac{\mu_oI}{2\pi x} cdx \right) = &#8230; = -\frac{\mu_0 Ic}{2\pi}\left( \frac{v}{a+b+vt} &#8211; \frac{v}{a+vt} \right) [ / tex ]</p>
<p>Gives:</p>
<p><img src="http://www.codecogs.com/eq.latex?V_{ind} = -\frac{d}{dt}{\int_A{\vec B d\vec A } = -\frac{d\Phi_B}{dt} =  -\frac{d}{dt}\left( \int_{a+vt}^{a+b+vt}{ \frac{\mu_oI}{2\pi x} cdx \right) = . . . = -\frac{\mu_0 Ic}{2\pi}\left( \frac{v}{a+b+vt} &#8211; \frac{v}{a+vt} \right)" alt="" /></p>
<p>You gotta love LaTeX, and you gotta love physics. This equation is actually the solution to a problem on an old exam.</p>
]]></content:encoded>
			<wfw:commentRss>http://dibon.net/wordpress/testing-latex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
