<?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>jaux.net &#187; Programming</title>
	<atom:link href="http://jaux.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://jaux.net</link>
	<description></description>
	<lastBuildDate>Tue, 22 Jun 2010 04:15:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Disable Bell in VIM</title>
		<link>http://jaux.net/2010/03/09/disable-bell-vim/</link>
		<comments>http://jaux.net/2010/03/09/disable-bell-vim/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 15:22:51 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VIM]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=376</guid>
		<description><![CDATA[&#34; Disable both beep and visual flash set visualbell t_vb= via]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">
&quot; Disable both beep and visual flash
set visualbell t_vb=
</pre>
<p><small><a href="http://www.computing.net/answers/linux/disable-bell-in-vim/24657.html">via</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2010/03/09/disable-bell-vim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nothing Could Fail in C</title>
		<link>http://jaux.net/2010/01/27/nothing-could-fail-in-c/</link>
		<comments>http://jaux.net/2010/01/27/nothing-could-fail-in-c/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 08:50:05 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C/C++]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=361</guid>
		<description><![CDATA[Best comment of the C programming language ever! via:reddit Here is the whole story: Going back to C by buddhabrot When I was 12 someone gave me a Metrowerks IDE to learn programming on my mac. I learned a lot &#8230; <a href="http://jaux.net/2010/01/27/nothing-could-fail-in-c/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Best comment of the C programming language ever!</p>
<p>via:<a href="http://www.reddit.com/r/programming/comments/aue06/going_back_to_c/">reddit</a></p>
<p>Here is the whole story:</p>
<blockquote><p>
Going back to C<br />
by buddhabrot</p>
<p>When I was 12 someone gave me a Metrowerks IDE to learn programming on my mac. I learned a lot with it, and got programming in C. I never really wrote a large program in it, only things like ROM hacks that extracted levels and models from snes/psx games I liked. Later, I got a windows PC and messed around with MFC in C++. That was the end for me, programming UI&#8217;s was too much work in C++ and I couldn&#8217;t handle the encyclopedic knowledge needed to program the Microsoft framework.</p>
<p>Later, I learned Java, which was also the language most commonly in my college. Making UI&#8217;s was a blast with it, I could factorize anything and really loved making as generic code as possible with it, even for small projects. Everything I made was made in Java.</p>
<p>Later in uni, I started learning functional languages, we used Haskell in one class. I got intrigued with Haskell and started solving Euler problems, up to this day I still have not written anything useful in Haskell but I love using it.</p>
<p>In the mean time I did some jobs for writing web sites. I used perl and php. After a while I only used php and used it more frequently.</p>
<p>After working for a while as a programmer I started to love higher-level languages, most of all Ruby. I became convinced that higher-level interpreted languages were the future because the slower execution times were to become meaningless. For any web projects I started using Ruby on Rails and to this day it still is my favourite framework.</p>
<p>Then, I learned Erlang because everyone was talking about it, and it showed me how to unleash parallellization, in whole new ways. I still think Erlang is the most amazing language I have ever seen. But then I found out it was also rather slow for the things I had in mind with it. I just didn&#8217;t find any use for it and never completely learned the language.</p>
<p>Last week I wanted to make a big poster of a fractal. I wanted to compute it on a friend&#8217;s octocore, and write a fast parallellized program. At first, I used Ruby, thinking it would perform better than I thought. And I quickly abandoned the idea because it was too slow.</p>
<p>Then I rewrote the same single-threaded algorithm in Haskell and saw that it was much, much quicker. But when I tried to parallallize it, I couldn&#8217;t fathom how to do it in Haskell and abandoned the idea. I tried to write a parallellized version in Erlang, and while it spreak across the machine nicely, each individual process was way too slow, the parallellized algorithm was hundreds of times slower than the single-threaded haskell.</p>
<p>Because I really wanted that poster, I decided to switch to C because I had this idea that nothing could fail in C. And I started to code in a language I hadn&#8217;t used for years, even a decade. And suddenly it hit me, everything made sense. Sure, I was writing so much boilerplate but it didn&#8217;t bother me. I suddenly realized that everything I wrote would be inside the program&#8217;s code, and that nothing more would. It was a great feeling.<br />
I used simple pthreads to do the parallellization, and I used libgd to output my data to a png file. I started learning about mutex lock hierarchies to make the parallellizations overlap without endangering thread safety, it was all ugly code and the API&#8217;s felt horrible compared to what I was used to.. but it all worked out. The resulting program was thousands of times faster than anything I had written.</p>
<p>And now, I am seriously wondering where I have been all this time. Sure, I still think C is incredibly clunky. But now I got the dust off of my old course on writing compilers (Modern compiler implementation in C), and I want to write a compiler in C for a small programming language. I want to get down to earth again, and write things that are efficient and just run very quickly. I want to write lots and lots of code and know exactly what every line does.</p>
<p>Has anyone else had this feeling, this evolution? Am I going mad? Do you think C will last, and there are intersting jobs left for pure C developers?
</p></blockquote>
<p>I have the same question: <strong>Are there intersting jobs left for pure C developers?</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2010/01/27/nothing-could-fail-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;&#8211;&#8221; (Double-hyphen) in Bash</title>
		<link>http://jaux.net/2009/11/24/double-hyphen-in-bash/</link>
		<comments>http://jaux.net/2009/11/24/double-hyphen-in-bash/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 19:09:13 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Notes]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=335</guid>
		<description><![CDATA[$cat out if [ $# -eq 0 ] then echo &#34;Usage: out [-v] filenames...&#34; 1&#62;&#38;2 exit 1 fi if [ &#34;$1&#34; = &#34;-v&#34; ] then shift less -- &#34;$@&#34; else cat -- &#34;$@&#34; fi In out the -- arguments to &#8230; <a href="http://jaux.net/2009/11/24/double-hyphen-in-bash/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">
$cat out
if [ $# -eq 0 ]
    then
        echo &quot;Usage: out [-v] filenames...&quot; 1&gt;&amp;2
        exit 1
fi
if [ &quot;$1&quot; = &quot;-v&quot; ]
    then
        shift
        less -- &quot;$@&quot;
    else
        cat -- &quot;$@&quot;
fi
</pre>
<blockquote>
<p>In out the <code>--</code> arguments to cat and less tells these utilities that no more options follow on the command line and not to consider leading hyphen (-) in the following list as indicating options. Thus <code>--</code> allows you to view a file with a name that starts with a hyphen&#8230; <code>--</code> argument works with all Linux utilities that use the getopts builtin&#8230; This argument is particularly useful when used in conjunction with rm to remove a file whose name starts with a hyphen (<code>rm -- -fname</code>)&#8230;</p>
</blockquote>
<p><em>A Practical Guide to Linux Commands, Editors and Shell Programming (p. 442)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2009/11/24/double-hyphen-in-bash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handle Filenames with Spaces Properly in Bash Loops</title>
		<link>http://jaux.net/2009/11/24/handle-filenames-with-spaces-properly-in-bash-loops/</link>
		<comments>http://jaux.net/2009/11/24/handle-filenames-with-spaces-properly-in-bash-loops/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 10:44:41 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Bash]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=329</guid>
		<description><![CDATA[find ~ -name '* *' &#124; while read FILE do echo &#34;$FILE rocks.&#34; done via Handling Filenames with Spaces in Bash]]></description>
			<content:encoded><![CDATA[<pre class="brush: bash;">
find ~ -name '* *' | while read FILE
do
    echo &quot;$FILE rocks.&quot;
done
</pre>
<p>via <a href="http://www.macgeekery.com/tips/cli/handling_filenames_with_spaces_in_bash">Handling Filenames with Spaces in Bash</a></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2009/11/24/handle-filenames-with-spaces-properly-in-bash-loops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Weather Script for Conky</title>
		<link>http://jaux.net/2008/12/13/weather-script-for-conky/</link>
		<comments>http://jaux.net/2008/12/13/weather-script-for-conky/#comments</comments>
		<pubDate>Sat, 13 Dec 2008 06:32:10 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[yahoo_weather_script]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=183</guid>
		<description><![CDATA[Wanna Conky to show your local weather? You might had found tons of solutions already on the web, but here comes a simpler one: SimpleWeather. Requirement: Python >= 2.5 How to use it: Download weather.py. Edit the file, fill in &#8230; <a href="http://jaux.net/2008/12/13/weather-script-for-conky/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wanna <a href="http://conky.sourceforge.net/">Conky</a> to show your local weather? You might had found tons of solutions already on the web, but here comes a simpler one: <strong><a href="http://github.com/jaux/simpleweather">SimpleWeather</a></strong>.</p>
<h3>Requirement:</h3>
<ul>
<li><a href="http://python.org">Python</a> >= 2.5</li>
</ul>
<h3>How to use it:</h3>
<ol>
<li><a href="http://github.com/jaux/simpleweather">Download weather.py</a>.</li>
<li>Edit the file, fill in required parameters (read CONFIGURATION first).</li>
<li>Add ${execi 3600 python <i>the_path_to</i>/weahter.py} to your .conkyrc.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/12/13/weather-script-for-conky/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What I’ve been up to?</title>
		<link>http://jaux.net/2008/06/13/what-ive-been-up-to/</link>
		<comments>http://jaux.net/2008/06/13/what-ive-been-up-to/#comments</comments>
		<pubDate>Sat, 14 Jun 2008 04:44:17 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=96</guid>
		<description><![CDATA[via]]></description>
			<content:encoded><![CDATA[<p><img src="http://jaux.net/uploads/2008/06/img_0003-300x224.jpg" alt="Eat Sleep Code" title="Eat Sleep Code" width="300" height="224" class="align-center size-medium wp-image-95" /></p>
<p><small><a href="http://bp3.blogger.com/_MR7bT7RHlnY/SFLXiqsNpiI/AAAAAAAAACk/k62Uha5y7k4/s1600-h/IMG_0003.JPG">via</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/06/13/what-ive-been-up-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Swap without Temporary Variable</title>
		<link>http://jaux.net/2008/04/30/swap-without-temporary-variabl/</link>
		<comments>http://jaux.net/2008/04/30/swap-without-temporary-variabl/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 17:47:54 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Math]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=85</guid>
		<description><![CDATA[When we&#8217;re programming, if we want to swap values of two integer values, the &#8220;normal&#8221; way we do it would look like: x = 5 y = 3 temp = x x = y y = temp We need a &#8230; <a href="http://jaux.net/2008/04/30/swap-without-temporary-variabl/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When we&#8217;re programming, if we want to swap values of two integer values, the &#8220;normal&#8221; way we do it would look like:</p>
<pre class="brush: python;">
x = 5
y = 3

temp = x
x = y
y = temp
</pre>
<p>We need a temporary variable as a container to hold a value first then do the swap.</p>
<p><strong>What if in some situation you can&#8217;t use the extra variable? How would you do it?</strong></p>
<p>Well, let&#8217;s forget computer programming but pick up some little math we learned in elementary school:</p>
<pre class="brush: python;">
x = 5
y = 3

x = x - y (=2)
y = x + y (=5)
x = y - x (=3)
</pre>
<p>Here we go!</p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/04/30/swap-without-temporary-variabl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Merry Christmas!</title>
		<link>http://jaux.net/2007/12/26/merry-christmas/</link>
		<comments>http://jaux.net/2007/12/26/merry-christmas/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 20:14:31 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Christmas]]></category>

		<guid isPermaLink="false">http://jaux.net/2007-12-26/merry-christmas/</guid>
		<description><![CDATA[Hey, this is the first christmas for jaux.net, and today is my first boxing day to crash a door. Got nothing but happy holidays :) Merry Christmas, everyone!]]></description>
			<content:encoded><![CDATA[<p>Hey, this is the first christmas for <a href="http://jaux.net">jaux.net</a>, and today is my first boxing day to crash a door. Got nothing but happy holidays :)</p>
<p><strong>Merry Christmas, everyone!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2007/12/26/merry-christmas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How To Prevent Creating Objects On Heap</title>
		<link>http://jaux.net/2007/12/12/how-to-prevent-creating-objects-on-heap/</link>
		<comments>http://jaux.net/2007/12/12/how-to-prevent-creating-objects-on-heap/#comments</comments>
		<pubDate>Wed, 12 Dec 2007 20:55:33 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C/C++]]></category>

		<guid isPermaLink="false">http://jaux.net/2007-12-12/how-to-prevent-creating-objects-on-heap/</guid>
		<description><![CDATA[Yesterday I saw a C++ interview question that was asking the interviewees to prevent the clients from creating objects on heap. That is, you write a class and your class users can&#8217;t use new to create an object. Here is &#8230; <a href="http://jaux.net/2007/12/12/how-to-prevent-creating-objects-on-heap/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I saw a <strong>C++</strong> interview question that was asking the interviewees to <em>prevent the clients from creating objects on heap</em>. That is, you write a class and your class users can&#8217;t use <strong>new</strong> to create an object.</p>
<p>Here is my solution:</p>
<pre class="brush: cpp;">
class Foo
{
public:
    Foo(const Foo&amp; f) {}
    static Foo getAnInstance()
    {
        return Foo();
    }
private:
    Foo() {}
};
</pre>
<h3>Explanation:</h3>
<p>To prevent users from creating objects on heap, I basically can&#8217;t give them any public constructors (ctor); therefore, I need to write at least one ctor myself and make it private since if I fail to do so, the compiler will generate a public default ctor for me and that is exactly what I don&#8217;t want. Then the user can only use the static member function <code>getAnInstance</code> to get an object to use.</p>
<h3>Analysis:</h3>
<p>In fact, my solution contradicts the explanation because I actually have a public ctor &#8212; the copy ctor. The copy ctor makes the following usage work:</p>
<pre lang="cpp" line="1">
Foo f0 = Foo::getAnInstance();
</pre>
<p>But because there is a copy ctor, after the user get his/her first object, he/she can do the following:</p>
<pre lang="cpp" line="1">
Foo* f1 = new Foo(f0);
</pre>
<p>This is saying that my solution can only guarantee <strong>the first object</strong> is on stack and it can&#8217;t go further.</p>
<p>So, my solution fails to solve the question.</p>
<p>p.s. I haven&#8217;t really seen the point of the interview question, but it&#8217;s interesting to think about ;)</p>
<h3>Update:</h3>
<p>The correct solution is to overload the <code>new</code> operator and make it private. <small>Credit to <a href="http://www.daniweb.com/forums/thread100867.html">DANIWEB</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2007/12/12/how-to-prevent-creating-objects-on-heap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Search for next</title>
		<link>http://jaux.net/2007/11/20/search-for-next/</link>
		<comments>http://jaux.net/2007/11/20/search-for-next/#comments</comments>
		<pubDate>Tue, 20 Nov 2007 17:21:48 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[VIM]]></category>

		<guid isPermaLink="false">http://jaux.net/2007-11-20/search-for-next/</guid>
		<description><![CDATA[This is a VIM tip. I saw it before, but I forgot it after a while. I saw it today, I don&#8217;t want lose it again, so I write it down. When you are going though a document in VIM, &#8230; <a href="http://jaux.net/2007/11/20/search-for-next/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img class='align-right' src='http://jaux.net/uploads/2007/11/vim.gif' alt='Vim' />This is a VIM tip. I saw it before, but I forgot it after a while. I saw it today, I don&#8217;t want lose it again, so I write it down.</p>
<p>When you are going though a document in VIM, you find a word and you want to go to the next same word in the document, you just need to put the cursor on the word and press <strong>* </strong> (SHIFT + 8).</p>
<p>What if you want to the previous one? Answer: <strong>#</strong> (SHIFT + 3).</p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2007/11/20/search-for-next/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
