<?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/"
	>

<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>
	<pubDate>Sun, 04 Jan 2009 17:04:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SQLite3: Unable to Open Database File</title>
		<link>http://jaux.net/2008/12/18/sqlite3-unable-to-open-database-file/</link>
		<comments>http://jaux.net/2008/12/18/sqlite3-unable-to-open-database-file/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 02:52:32 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[Skypiea]]></category>

		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=205</guid>
		<description><![CDATA[Recently, I&#8217;m working on my Skypiea project which is powered by SQLite3 and Python (as CGI script). Yesterday I encountered a program: When the web server ran a CGI script which would update the database, I got an error message said &#8220;sqlite3.OperationalError: unable to open database file&#8220;.

I searched the web and Google told me I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;m working on my <a href="http://jaux.net/my-works/project-skypiea/">Skypiea</a> project which is powered by SQLite3 and <a href="http://python.org">Python</a> (as CGI script). Yesterday I encountered a program: When the web server ran a CGI script which would update the database, I got an error message said &#8220;<strong>sqlite3.OperationalError: unable to open database file</strong>&#8220;.</p>
<p><img src="http://jaux.net/uploads/2008/12/sqlite.gif" alt="sqlite" title="sqlite" width="327" height="97" class="align-center size-full wp-image-209" /></p>
<p>I searched the web and Google told me I need to specify <em>the <strong>full path</strong> (no ~ or $HOME etc.) of the database file</em> and the <em>web server needs the <strong>write permission</strong> to the file</em>. Sure, I actually had done both before the exception occurred.</p>
<p>Having being pissed for a while, I finally figured out what was wrong here: The web server needs the write permission to not only the database file, but also <em><strong>the containing directory</strong></em> of that file.</p>
<p>Yea, just simple like that.</p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/12/18/sqlite3-unable-to-open-database-file/feed/</wfw:commentRss>
		</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: yahoo_weather.py.
Requirement:

Python >= 2.5

How to use it:

Download yahoo.weather.py.
Edit the file, fill in required parameters (read CONFIGURATION first).
Add ${execi 3600 python the_path_to/yahoo_weahter.py} to your .conkyrc.

]]></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/sandbox/tree/master/yahoo_weather.py">yahoo_weather.py</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/sandbox/raw/master/yahoo_weather.py">Download yahoo.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>/yahoo_weahter.py} to your .conkyrc.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/12/13/weather-script-for-conky/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Patch to Broadcom 802.11 Linux STA driver for Kernel 2.6.27</title>
		<link>http://jaux.net/2008/10/14/patch-to-broadcom-80211-linux-sta-driver-for-kernel-2627/</link>
		<comments>http://jaux.net/2008/10/14/patch-to-broadcom-80211-linux-sta-driver-for-kernel-2627/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 07:53:40 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Broadcom]]></category>

		<category><![CDATA[C/C++]]></category>

		<category><![CDATA[Kernel]]></category>

		<category><![CDATA[patch]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=128</guid>
		<description><![CDATA[Update 2009-01-04: As Jose mentioned, the latest driver (ver. 5.10.27.12) no longer needs this patch!
If you have problem to compile Broadcom 802.11 Linux STA driver (version 5.10.27.6) on Kernel 2.6.27 and get error message like the following:

/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c: In function ‘wl_iw_get_scan’:
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: warning: passing argument 1 of ‘iwe_stream_add_event’ from incompatible pointer type
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: warning: passing argument 3 of [...]]]></description>
			<content:encoded><![CDATA[<p><em>Update 2009-01-04: As Jose mentioned, the latest driver (ver. 5.10.27.12) no longer needs this patch!</em></p>
<p>If you have problem to compile Broadcom 802.11 Linux STA driver (<strong>version <em>5.10.27.6</em></strong>) on <strong>Kernel <em>2.6.27</em></strong> and get error message like the following:</p>
<pre>
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c: In function ‘wl_iw_get_scan’:
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: warning: passing argument 1 of ‘iwe_stream_add_event’ from incompatible pointer type
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: warning: passing argument 3 of ‘iwe_stream_add_event’ from incompatible pointer type
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: warning: passing argument 4 of ‘iwe_stream_add_event’ makes pointer from integer without a cast
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:934: error: too few arguments to function ‘iwe_stream_add_event’
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:939: warning: passing argument 1 of ‘iwe_stream_add_point’ from incompatible pointer type
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:939: warning: passing argument 3 of ‘iwe_stream_add_point’ from incompatible pointer type
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:939: warning: passing argument 4 of ‘iwe_stream_add_point’ from incompatible pointer type
/home/ye/downloads/bcm4328/hybrid_wl/src/wl/sys/wl_iw.c:939: error: too few arguments to function ‘iwe_stream_add_point’
...
</pre>
<p>Then you need to apply the patch: <a href='http://jaux.net/uploads/2008/10/hybrid_wl-5.10.27.6_patch-2.6.27'>hybrid_wl-5.10.27.6_patch-2.6.27</a></p>
<p>How to apply the patch:</p>
<ol>
<li>Download the STA driver and the patch.</li>
<li>Extract the STA driver and switch to the root of source tree (where Makefile is located).</li>
<li><strong>patch -p1 -E < <em>path_to_patch</em>/hybrid_wl_5.10.27.6_patch-2.6.27</strong></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/10/14/patch-to-broadcom-80211-linux-sta-driver-for-kernel-2627/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Windows Vista: Install Python 2.6 for all users</title>
		<link>http://jaux.net/2008/10/02/windows-vista-install-python-26-for-all-users/</link>
		<comments>http://jaux.net/2008/10/02/windows-vista-install-python-26-for-all-users/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 23:19:59 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=113</guid>
		<description><![CDATA[Python 2.6 final was release yesterday. If you are using Windows Vista and you want to install Python 2.6 for all users, but the &#8220;Vista Note&#8221; from the release page does not work for you, you may try this:

Run the command line program (cmd/powershell) as Administrator (right-click -> Run as Administrator), then issue the following [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://jaux.net/uploads/2008/10/python-logo.png" alt="python-logo" title="python-logo" width="211" height="71" class="align-left size-full wp-image-116" />Python 2.6 final was release yesterday. If you are using Windows Vista and you want to install Python 2.6 for all users, but the &#8220;Vista Note&#8221; from the release page does not work for you, you may try this:</p>
<ol>
<li><strong>Run the command line program (cmd/powershell) as Administrator</strong> (right-click -> Run as Administrator), then issue the following command:</li>
<li><strong>msiexec /i <em>path_to_the_msi</em>\python-2.6.msi</strong></li>
</ol>
<p>That&#8217;s it!</p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/10/02/windows-vista-install-python-26-for-all-users/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What I&#8217;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[Discovery]]></category>

		<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>
		</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 temporary variable as a container to hold a value first then do the swap.
What if in some situation you can&#8217;t use [...]]]></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 name="code" class="py">

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 name="code" class="py">

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>
		</item>
		<item>
		<title>Solution to Lenovo Y410 Sound Problem On Ubuntu 8.04</title>
		<link>http://jaux.net/2008/04/27/solution-to-lenovo-y410-sound-problem-ubuntu-804/</link>
		<comments>http://jaux.net/2008/04/27/solution-to-lenovo-y410-sound-problem-ubuntu-804/#comments</comments>
		<pubDate>Sun, 27 Apr 2008 09:21:45 +0000</pubDate>
		<dc:creator>jaux</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Internet]]></category>

		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://jaux.net/?p=83</guid>
		<description><![CDATA[Update 2008-11-20: In a comment, Ace pointed out that Ubuntu 8.10 already has this problem fixed.
Update 2008-10-6: please don&#8217;t use the y410_sound script from this article since I don&#8217;t own a Y410 anymore, so I couldn&#8217;t test and maintain the script. Instead, please follow the solutions given in the comments. They seem to work pretty [...]]]></description>
			<content:encoded><![CDATA[<p><em>Update 2008-11-20: In a comment, <a href="http://jaux.net/2008/04/27/solution-to-lenovo-y410-sound-problem-ubuntu-804/#comment-390">Ace</a> pointed out that Ubuntu 8.10 already has this problem fixed.</em></p>
<p><em>Update 2008-10-6: <strong>please don&#8217;t use the y410_sound script from this article</strong> since I don&#8217;t own a Y410 anymore, so I couldn&#8217;t test and maintain the script. Instead, please follow the solutions given in the comments. They seem to work pretty well.</em></p>
<p><em>Update 2008-4-3: This script will only make speaker work, but not headphone. As Sam mentioned, there is another easy way to get sound work without installing anything: Suspend your machine and resume. The drawback is you have to do it every time after you (re)boot.</em></p>
<p><img src="http://jaux.net/uploads/2008/04/ubuntulogo.png" alt="Ubuntu Logo Linux jaux.net" title="ubuntulogo" width="202" height="55" class="align-left size-full wp-image-74" />Well, this is another post about <a href="http://ubuntu.com">Ubuntu 8.04</a>!</p>
<p><a href="http://jaux.net/2008/04/25/hardy-heron/">As I mentioned</a> before, Lenovo Y410 laptop&#8217;s sound card wouldn&#8217;t work out of box on Ubuntu 8.04, which is very disappointing for Y410 owners like me.</p>
<p>Fortunately, we can solve this problem in the same way as on Ubuntu 7.10 and the most intuitive solution I could find on Internet is <a href="http://linuxondesktop.blogspot.com/2007/12/getting-sound-to-work-on-your-ubuntu.html">&#8220;Getting Sound to work on your Ubuntu 7.10 installation on Lenovo Y410 Series laptop&#8221;</a>. Thanks the author, Ambuj Varshney, for the good job!</p>
<p>The solution is straightforward, but <del datetime="2008-04-27T09:49:52+00:00">it&#8217;s kind of verbose</del> there are too many steps to perform, kind of; so I wrote a <em>bash</em> script to do the job. <strong>You can download the script from my <a href="http://www.box.net/shared/s3ijaguosc">box</a>.</strong></p>
<p>After you downloaded this script (y410_sound-20080427.sh), run it as follow:</p>
<pre lang="bash">
chmod +x y410_sound-20080427.sh
sudo ./y410_sound-20080427.sh
</pre>
<p>This script may take a long time to finish since it will download all the required packages and compile the driver, so please be patient.</p>
<p>After it&#8217;s done, reboot your Y410 and then you should be able to enjoy your music!</p>
<p><em>Note: I only tested this script on my Lenovo Y410. If you have any problem while applying this script, please leave comments.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jaux.net/2008/04/27/solution-to-lenovo-y410-sound-problem-ubuntu-804/feed/</wfw:commentRss>
		</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>
		</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 my solution:

class Foo
{
public:
    Foo(const Foo&#038; f) {}
    static Foo getAnInstance()
 [...]]]></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 lang="cpp" line="1">
class Foo
{
public:
    Foo(const Foo&#038; 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>
		</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, you find a word and you want to go to the next same word in the [...]]]></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>
		</item>
	</channel>
</rss>
