<?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>vultaire.net</title>
	<atom:link href="http://www.vultaire.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vultaire.net/blog</link>
	<description>The Blog</description>
	<lastBuildDate>Tue, 24 Apr 2012 13:12:52 +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>New program: &#8220;Kanji&#8221;, a simple flashcard-like study program</title>
		<link>http://www.vultaire.net/blog/2011/12/12/new-program-kanji-a-simple-flashcard-like-study-program/</link>
		<comments>http://www.vultaire.net/blog/2011/12/12/new-program-kanji-a-simple-flashcard-like-study-program/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 07:36:06 +0000</pubDate>
		<dc:creator>Paul Goins</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.vultaire.net/blog/?p=219</guid>
		<description><![CDATA[Last Saturday, I got up early and decided to whip up something quick yet useful. Roughly two hours later, I had released the first version of &#8220;Kanji&#8221;. &#8220;Kanji&#8221; is a simple tool for reviewing Japanese characters or words. It reads in a UTF-8 encoded file and displays the entries within at random, showing a new [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.vultaire.net/blog/wp-content/uploads/2011/12/kanji_2.jpeg"><img src="http://www.vultaire.net/blog/wp-content/uploads/2011/12/kanji_2.jpeg" alt="Screenshot of &quot;Kanji&quot;" title="kanji_2" width="288" height="309" class="alignnone size-full wp-image-220" /></a></p>
<p>Last Saturday, I got up early and decided to whip up something quick yet useful.  Roughly two hours later, I had released the first version of &#8220;Kanji&#8221;.</p>
<p>&#8220;Kanji&#8221; is a simple tool for reviewing Japanese characters or words.  It reads in a UTF-8 encoded file and displays the entries within at random, showing a new entry every 30 seconds.  It is intended to be run in &#8220;always on top&#8221; mode, in which case it can be used for passive studying of Japanese while working on other things.</p>
<p>This tool is minimalistic by design.  There are no config files nor preferences.  Everything is specified via the command line, after which, the program simply runs until closed.</p>
<p><span id="more-219"></span></p>
<p>As an example, the above screenshot was actually created via the following invocation (on Windows 7):</p>
<p><a href="http://www.vultaire.net/blog/wp-content/uploads/2011/12/kanji_1.jpeg"><img src="http://www.vultaire.net/blog/wp-content/uploads/2011/12/kanji_1.jpeg" alt="&quot;Kanji,&quot; with corresponding command line." title="kanji_1" width="677" height="574" class="alignnone size-full wp-image-221" /></a></p>
<p>The code is available on Github for those who wish to try it: <a href="https://github.com/Vultaire/flashcards">https://github.com/Vultaire/flashcards</a></p>
<p><strong>Update:</strong> A new &#8220;card flipping&#8221; feature has been added, and cards are now defined in CSV files with one line per card and one &#8220;side&#8221; per column.  The program has also been renamed to &#8220;flashcards&#8221; to reflect its more general intended usage.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vultaire.net/blog/2011/12/12/new-program-kanji-a-simple-flashcard-like-study-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun with xargs: parallelized FLAC to MP3 conversion</title>
		<link>http://www.vultaire.net/blog/2011/10/11/fun-with-xargs-parallelized-flac-to-mp3-conversion/</link>
		<comments>http://www.vultaire.net/blog/2011/10/11/fun-with-xargs-parallelized-flac-to-mp3-conversion/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 05:23:37 +0000</pubDate>
		<dc:creator>Paul Goins</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.vultaire.net/blog/?p=202</guid>
		<description><![CDATA[I&#8217;ve been wanting to use xargs for a practical application for some time. I&#8217;ve read many articles that have mentioned it, but it was Ted Dziuba&#8217;s Taco Bell Programming which was the tipping point. Here&#8217;s the situation: I want to convert my FLAC collection to an MP3 collection so that I can upload my CD [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been wanting to use xargs for a practical application for some time.  I&#8217;ve read many articles that have mentioned it, but it was Ted Dziuba&#8217;s <a href="http://teddziuba.com/2010/10/taco-bell-programming.html">Taco Bell Programming</a> which was the tipping point.</p>
<p>Here&#8217;s the situation: I want to <strong>convert my FLAC collection to an MP3 collection</strong> so that I can upload my CD collection to Amazon.  Further, I&#8217;d like to <strong>store the MP3s in a different folder,</strong> while maintaining the original subfolder structure.  Finally, I want to <strong>maintain the metadata in my FLAC files;</strong> the flac command line utility only seems to support decoding to .wav without metadata.</p>
<p>Finally, <strong>I have 8 virtual cores, and I want to use them all to convert everything as quickly as possible.</strong></p>
<p><span id="more-202"></span></p>
<h3>Creating a mirrored directory structure, using xargs</h3>
<p>First, let&#8217;s create the directories to store our MP3 files in:</p>
<pre class="brush: bash; title: ; notranslate">
find Music_CDs_FLAC/ -iname '*.flac' \
    | sed -re 's#^Music_CDs_FLAC/(.*)/[^/]*$#Music_CDs_MP3s/\1#' \
    | sort \
    | uniq \
    | xargs -r -P1 -n1 -d'\n' mkdir -pv
</pre>
<p>This command pulls all unique folder names under Music_CDs_FLAC and creates directories.  In this case I used -P1 which only allocates 1 process.  Of course, at this rate xargs is not necessary; the above could be accomplished with a simple bash for loop instead.</p>
<h3>Creating a FLAC to MP3 script, using xargs</h3>
<p>Next, let&#8217;s convert a single FLAC file to an MP3.  This is a complex process since we can&#8217;t easily convert straight from FLAC to MP3.  (Well, I&#8217;m sure there&#8217;s programs out there, but I don&#8217;t know what&#8217;s good and this serves as a good example.)</p>
<p>Oh, but wait, there&#8217;s more: lame expects tags on the command line, and what do we do about tags containing quotes or apostrophes?  Do we escape them?  I&#8217;d rather not bother here; let&#8217;s allow xargs to do the work for us.</p>
<p>Let&#8217;s make a script which takes an input and output file name, and which performs the needed conversion, using xargs for passing tags:</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash

# Author: Paul Goins
# License: Public Domain
# File: flac2mp3.sh
#
# Script to convert FLAC files to MP3, using xargs for passing tag
# arguments to lame.
#
# Why do we do this?  It's for the metatags which may contain
# characters requiring shell quotes.  This gets around having to do
# any escaping.
#
# Note: This script &quot;works for me&quot;; it may not keep all metadata from
# your FLAC files.  It does keep most of the data from my FLAC files
# which were generated via abcde.

set -o nounset
set -o errexit

infile=&quot;$1&quot;
outfile=&quot;$2&quot;
argfile=&quot;$(mktemp)&quot;

# Extract metadata and push tags to argfile
metafile=&quot;$(mktemp)&quot;
metaflac --export-tags-to &quot;$metafile&quot; &quot;$infile&quot;

arg_regex='s/^[^=]*=(.*)$/\1/'
ARTIST=$(grep &quot;$metafile&quot; -e 'ARTIST=' | sed -re &quot;$arg_regex&quot;)
if [ ! -z &quot;$ARTIST&quot; ]; then
    echo -e &quot;--ta\n$ARTIST&quot; &gt;&gt; &quot;$argfile&quot;
fi
ALBUM=$(grep &quot;$metafile&quot; -e 'ALBUM=' | sed -re &quot;$arg_regex&quot;)
if [ ! -z &quot;$ALBUM&quot; ]; then
    echo -e &quot;--tl\n$ALBUM&quot; &gt;&gt; &quot;$argfile&quot;
fi
TITLE=$(grep &quot;$metafile&quot; -e 'TITLE=' | sed -re &quot;$arg_regex&quot;)
if [ ! -z &quot;$TITLE&quot; ]; then
    echo -e &quot;--tt\n$TITLE&quot; &gt;&gt; &quot;$argfile&quot;
fi
DATE=$(grep &quot;$metafile&quot; -e 'DATE=' | sed -re &quot;$arg_regex&quot;)
if [ ! -z &quot;$DATE&quot; ]; then
    echo -e &quot;--ty\n$DATE&quot; &gt;&gt; &quot;$argfile&quot;
fi
GENRE=$(grep &quot;$metafile&quot; -e 'GENRE=' | sed -re &quot;$arg_regex&quot;)
if [ ! -z &quot;$GENRE&quot; ]; then
    echo -e &quot;--tg\n$GENRE&quot; &gt;&gt; &quot;$argfile&quot;
fi
TRACKNUMBER=$(grep &quot;$metafile&quot; -e 'TRACKNUMBER=' | sed -re &quot;$arg_regex&quot;)
if [ ! -z &quot;$TRACKNUMBER&quot; ]; then
    echo -e &quot;--tn\n$TRACKNUMBER&quot; &gt;&gt; &quot;$argfile&quot;
fi

rm &quot;$metafile&quot;

# Push infile/outfile as final args
echo &quot;-&quot; &gt;&gt; &quot;$argfile&quot;
echo &quot;$outfile&quot; &gt;&gt; &quot;$argfile&quot;

# Perform the conversion
flac --decode --stdout --silent &quot;$infile&quot; \
    | xargs --arg-file=&quot;$argfile&quot; -r -d'\n' lame --quiet -b320

rm &quot;$argfile&quot;
</pre>
<p>Okay, this bit of code does have some real benefit from using xargs.  However, it&#8217;s not what really makes me excited.</p>
<h3>A sidenote: xargs and multiple commands</h3>
<p>xargs runs a single command.  For complex behavior involving pipes, it is possible to run something like the following (contrived) example:</p>
<pre class="brush: bash; title: ; notranslate">
# Contrived example!  Yay!!
cat /dev/null | xargs -n1 bash -c &quot;echo foo | grep -e \&quot;oo\&quot;&quot;
</pre>
<p>For complex behavior like the above file conversion script, the benefits of writing a dedicated script are rather obvious.  However, even when piping a couple of commands together, it may be worth writing a quick and dirty script and calling it via xargs, rather than messing with shell quoting.  This is especially true if you&#8217;re dealing with lots of data which could contain characters requiring special quoting.</p>
<h3>Using xargs for parallelization: fully utilizing 8 virtual cores</h3>
<p>This brings us to the final part: to automatically convert all my FLAC files to MP3, and to do so in parallel.  I run a Core i7, which means I have 4 physical cores with hyperthreading, coming out to 8 virtual cores.  I&#8217;m going to run 12 parallel processes to perform the conversion, ensuring my processor stays as busy as possible.</p>
<p>Here&#8217;s the script:</p>
<pre class="brush: bash; title: ; notranslate">
find Music_CDs_FLAC -iname '*.flac' \
    | sed -re 's#^Music_CDs_FLAC/(.*)\.flac$#Music_CDs_FLAC/\1.flac\nMusic_CDs_MP3s/\1.mp3#' \
    | xargs -t -r -P12 -n2 -d'\n' ~/scripts/flac2mp3.sh
</pre>
<p>There we go.  The above will print out each command as it&#8217;s executed, and it will quickly take up nearly 100% of all my CPU cores.  It may hit a bottleneck when writes need to be flushed to disk, but this should (hopefully) take less time overall than doing things one-by-one.</p>
<p>A quick description of what I did:</p>
<ul>
<li>I found all .flac files and printed out one per line.  (find command)</li>
<li>I took each .flac file and output two lines: the original .flac and the target .mp3.  (sed command)</li>
<li>I launched concurrent conversion scripts, up to 12 at a time, taking two arguments per script call (input/output files), separating input args on newlines.  The commands were echoed to the console as they were run.  (xargs command)</li>
</ul>
<p>Final note: after actually running the above snippet, converting 36 GiB of FLACs (1283 files) clocked in as follows:</p>
<pre class="brush: plain; title: ; notranslate">
real    41m56.118s
user    321m43.014s
sys     3m18.788s
</pre>
<p>Note: the real time was only 42 minutes, yet the user time was 5 hours and 22 minutes!  Without xargs, using just a for loop to work through all the files, this would have taken <strong>much</strong> longer.  This workload obviously benefitted from parallelization via xargs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vultaire.net/blog/2011/10/11/fun-with-xargs-parallelized-flac-to-mp3-conversion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using nvidia drivers on Debian Squeeze 64-bit with backported kernel</title>
		<link>http://www.vultaire.net/blog/2011/08/14/using-nvidia-drivers-on-debian-squeeze-64-bit-with-backported-kernel/</link>
		<comments>http://www.vultaire.net/blog/2011/08/14/using-nvidia-drivers-on-debian-squeeze-64-bit-with-backported-kernel/#comments</comments>
		<pubDate>Sun, 14 Aug 2011 06:39:08 +0000</pubDate>
		<dc:creator>Paul Goins</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.vultaire.net/blog/?p=167</guid>
		<description><![CDATA[This article consists of notes I&#8217;ve written while attempting to get the official nvidia drivers to work on Debian Squeeze with a backported kernel. For the record, on my system I am using kernel version 2.6.39-bpo.2-amd64. I forget the exact forum page I found, but it seems using DKMS is now the preferred way of [...]]]></description>
			<content:encoded><![CDATA[<p>This article consists of notes I&#8217;ve written while attempting to get the official nvidia drivers to work on Debian Squeeze with a backported kernel.</p>
<p>For the record, on my system I am using kernel version 2.6.39-bpo.2-amd64.</p>
<p><span id="more-167"></span></p>
<p>I forget the exact forum page I found, but it seems using DKMS is now the preferred way of installing the official drivers in Debian.  <a href="http://wiki.debian.org/NvidiaGraphicsDrivers">http://wiki.debian.org/NvidiaGraphicsDrivers</a> seems to confirm this, although it is not immediately obvious.</p>
<p>Anyway, basically the procedure <strong>should</strong> be as simple as:</p>
<pre class="brush: bash; title: ; notranslate">
apt-get install -t squeeze-backports dkms nvidia-kernel-dkms
</pre>
<p>However, if you look carefully, an error likely occurred.  If you missed the error, you should be able to reproduce it via:</p>
<pre class="brush: bash; title: ; notranslate">
dpkg-reconfigure nvidia-kernel-dkms
</pre>
<p>The output should be something like:</p>
<pre class="brush: plain; title: ; notranslate">
------------------------------
Deleting module version: 195.36.31
completely from the DKMS tree.
------------------------------
Done.
Loading new nvidia-195.36.31 DKMS files...
Building only for 2.6.39-bpo.2-amd64
Building initial module for 2.6.39-bpo.2-amd64

Error! Bad return status for module build on kernel: 2.6.39-bpo.2-amd64 (x86_64)
Consult the make.log in the build directory
/var/lib/dkms/nvidia/195.36.31/build/ for more information.
</pre>
<p>Looking at /var/lib/dkms/nvidia/195.36.31/build/make.log, I found the following errors:</p>
<pre class="brush: plain; title: ; notranslate">
$ grep -ie error /var/lib/dkms/nvidia/195.36.31/build/make.log
/var/lib/dkms/nvidia/195.36.31/build/nv-linux.h:22:28: error: linux/autoconf.h: No such file or directory
/var/lib/dkms/nvidia/195.36.31/build/nv-linux.h:92:75: error: linux/smp_lock.h: No such file or directory
make[4]: *** [/var/lib/dkms/nvidia/195.36.31/build/nv.o] Error 1
make[3]: *** [_module_/var/lib/dkms/nvidia/195.36.31/build] Error 2
make[2]: *** [sub-make] Error 2
make[1]: *** [all] Error 2
make: *** [modules] Error 2
</pre>
<p>Okay, we&#8217;re missing some include files.  It seems these are files which are not included in recent kernel versions.</p>
<p>Reference for smp_lock.h: <a href="http://idratherhack.blogspot.com/2011/04/nvidia-drivers-fail-without-smplockh.html">http://idratherhack.blogspot.com/2011/04/nvidia-drivers-fail-without-smplockh.html</a></p>
<p>References for autoconf.h:</p>
<ol>
<li><a href="https://bugs.launchpad.net/ubuntu/+source/dahdi-linux/+bug/591375">https://bugs.launchpad.net/ubuntu/+source/dahdi-linux/+bug/591375</a></li>
<li><a href="http://alxrem.blogspot.com/2011/05/nvidia-drivers-on-debian-squeeze-with.html">http://alxrem.blogspot.com/2011/05/nvidia-drivers-on-debian-squeeze-with.html</a></li>
</ol>
<p>Basically, smp_lock.h is for the now obsolete Big Kernel Lock, and autoconf.h got moved.</p>
<p>So, how do we kludge together a fix?  The following is what I could come up with.  <strong>Copy/paste this into a bash shell:</strong></p>
<pre class="brush: bash; title: ; notranslate">
(
    set -o errexit

    die () {
        echo &quot;$@&quot; &gt; /dev/stderr
        exit 1
    }

    if (($(id -u) != 0)); then
        die &quot;This snippet must be run as root.&quot;
    fi

    # Install prerequisites
    apt-get install -t squeeze-backports dkms nvidia-kernel-dkms

    # Create fake smp_lock.h
    cd /lib/modules/$(uname -r)/source/include/linux
    if [ ! -e &quot;smp_lock.h&quot; ]; then
        touch smp_lock.h
        echo &quot;Created dummy smp_lock.h.&quot;
    fi

    # Link to relocated autoconf.h
    cd /lib/modules/$(uname -r)/build/include/linux
    ln -sv ../generated/autoconf.h

    # Patch header file in nvidia sources
    # (Patch based on: http://alxrem.blogspot.com/2011/05/nvidia-drivers-on-debian-squeeze-with.html)
    cd /usr/src/nvidia-195.36.31
    cp -v nv-linux.h{,.bak}
    patchfile=$(tempfile)
    cat &lt;&lt;&quot;EOF&quot; &gt; $patchfile
--- a/nv-linux.h     2011-05-11 12:26:22.206190191 +0400
+++ b/nv-linux.h  2011-05-04 15:36:27.163263047 +0400
@@ -975,8 +975,13 @@
 #endif

 #if defined(NV_ACQUIRE_CONSOLE_SEM_PRESENT)
-#define NV_ACQUIRE_CONSOLE_SEM() acquire_console_sem()
-#define NV_RELEASE_CONSOLE_SEM() release_console_sem()
+# if LINUX_VERSION_CODE &gt;= KERNEL_VERSION(2, 6, 38)
+#  define NV_ACQUIRE_CONSOLE_SEM() console_lock()
+#  define NV_RELEASE_CONSOLE_SEM() console_unlock()
+# else
+#  define NV_ACQUIRE_CONSOLE_SEM() acquire_console_sem()
+#  define NV_RELEASE_CONSOLE_SEM() release_console_sem()
+# endif
 #else
 #define NV_ACQUIRE_CONSOLE_SEM()
 #define NV_RELEASE_CONSOLE_SEM()
EOF
    patch -Np1 -i $patchfile
    rm $patchfile

    # Reconfigure kernel sources (which will automatically build the nvidia DKMS module)
    dpkg-reconfigure linux-headers-$(uname -r)

    # Explicitly reconfigure the nvidia bits (sometimes this seems to be done automatically, sometimes not...)
    dpkg-reconfigure nvidia-kernel-dkms
)
</pre>
<p>Okay, that was a little long, but the above should successfully install the kernel module.  (No warranty, but I developed and tested this on my two amd64 Debian Squeeze machines.)</p>
<p>For full disclosure, side effects of the above snippet are as follows:</p>
<ol>
<li>New empty header: /usr/src/linux-headers-$(uname -r)/include/linux/smp_lock.h</li>
<li>New symlink: /usr/src/linux-headers-$(uname -r)/include/linux/autoconf.h (-> ../generated/autoconf.h)</li>
<li>Modified header: /usr/src/nvidia-195.36.31/nv-linux.h (original is backed up as /usr/src/nvidia-195.36.31/nv-linux.h.bak)</li>
</ol>
<p>From here, what typically remains is:</p>
<pre class="brush: bash; title: ; notranslate">
apt-get install -y nvidia-glx  # or one of the nvidia-glx-legacy-* modules
apt-get install -y nvidia-glx-ia32  # optional
apt-get install -y nvidia-xconfig nvidia-settings
if [ -e &quot;/etc/X11/xorg.conf&quot; ]; then
    echo &quot;/etc/X11/xorg.conf exists; please change the display driver to &quot;nvidia&quot;.
else
    nvidia-xconfig
fi
</pre>
<p>At this point, reboot, and you should be up and running!</p>
<p>Note that none of what I&#8217;ve done here is really original; I&#8217;ve just assembled notes from others and put them together in a few bash snippets.  Just hope it&#8217;ll help someone get up and running faster than it took me. =)</p>
<hr />
<p><strong>Sidenote #1:</strong> On the <a href="http://wiki.debian.org/NvidiaGraphicsDrivers#Create_an_xorg.conf">Debian wiki page</a>, if you don&#8217;t know about DKMS and try to read this page, you&#8217;ll likely end up assuming that module-assistant is the way to go, but I found that this would not work in my case, probably due to the backported kernel.  (I don&#8217;t exactly remember the error.)</p>
<p><strong>Sidenote #2:</strong> Installing nvidia-kernel-dkms adds a blacklist rule for the nouveau module, but Xorg&#8217;s defaults will cause nouveau to be loaded anyway unless an appropriate Xorg.conf file exists.</p>
<p><strong>Sidenote #3:</strong> Found someone who had nearly an identical problem: <a href="http://alxrem.blogspot.com/2011/05/nvidia-drivers-on-debian-squeeze-with.html">http://alxrem.blogspot.com/2011/05/nvidia-drivers-on-debian-squeeze-with.html</a>  The notes are almost a complete solution, minus the smp_lock.h fix.  I&#8217;m guessing it was written before the BKL was completely removed.</p>
<p><strong>UPDATE #1:</strong> Unfortunately WordPress decided to butcher my source code and replace HTML special characters with character entities.  I&#8217;ve fixed the code; hopefully the character replacements were the only changes it &#8220;helped&#8221; me with.  Please let me know if this works.</p>
<p><strong>UPDATE #2:</strong> Thank you everyone for your feedback.  I was pretty late getting back to this but have finally updated the procedure based on your comments.  Thanks!</p>
<p><strong>UPDATE #3:</strong> Just a quick note, as I haven&#8217;t had time to fully apply and test this myself.  I&#8217;ve noticed an update is necessary for this to work with the new backported 3.2 kernel.  At a minimum, the following patch looks to be needed.  (Note: the sourcecode WordPress plugin is not preserving tabs in the patch, so please apply manually.)</p>
<pre class="brush: diff; title: ; notranslate">
--- /usr/src/nvidia-195.36.31/Makefile.bak	2012-02-14 20:31:03.000000000 -0800
+++ /usr/src/nvidia-195.36.31/Makefile	2012-02-14 22:57:22.000000000 -0800
@@ -155,8 +155,9 @@

 # Check for kernel versions that we don't support.

-BELOW26 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 6 ]; then \
-		echo y; fi)
+#BELOW26 := $(shell if [ $(VERSION) -lt 2 -o $(PATCHLEVEL) -lt 6 ]; then \
+#		echo y; fi)
+BELOW26 :=

 ifeq ($(BELOW26),y)
 $(error Only 2.6.x and later kernels are supported \
</pre>
<p>Yes, I know this doesn&#8217;t &#8220;fix&#8221; the if condition; however it should allow the compilation to proceed.  I&#8217;ll post more once I have details.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vultaire.net/blog/2011/08/14/using-nvidia-drivers-on-debian-squeeze-64-bit-with-backported-kernel/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Mozilla Firefox/Google Chrome and Flash on Debian Squeeze 64-bit</title>
		<link>http://www.vultaire.net/blog/2011/05/26/google-chrome-and-flash-on-debian-squeeze-64-bit/</link>
		<comments>http://www.vultaire.net/blog/2011/05/26/google-chrome-and-flash-on-debian-squeeze-64-bit/#comments</comments>
		<pubDate>Thu, 26 May 2011 11:52:38 +0000</pubDate>
		<dc:creator>Paul Goins</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.vultaire.net/blog/?p=162</guid>
		<description><![CDATA[Update, 2012-04-24: This procedure updates the Flash player in use by Firefox. Chrome can also pick this up, so this solution appears to work for both browsers. I recently re-installed Debian Squeeze on my main machine. I&#8217;m using the 64-bit version along with 64-bit Chrome. However, the 64-bit Chrome does not come with a built-in [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update, 2012-04-24:</strong> This procedure updates the Flash player in use by Firefox.  Chrome can also pick this up, so this solution appears to work for both browsers.</p>
<p>I recently re-installed Debian Squeeze on my main machine.  I&#8217;m using the 64-bit version along with 64-bit Chrome.</p>
<p>However, the 64-bit Chrome does not come with a built-in Flash player.  Instead, it seems to be finding the plugin by searching the Mozilla plugin folder (/usr/lib/mozilla/plugins/), where it finds flash-mozilla.so, which is a symlink to /usr/lib/gnash/libgnashplugin.so, the Gnash flash plugin.</p>
<p>Don&#8217;t get me wrong; I&#8217;m happy to see how Gnash is looking, and I&#8217;m happy that a free software alternative exists.  However, I&#8217;m not a FLOSS puritan; I&#8217;ll use the best tool for the job which, in my opinion, remains as the official Flash plugin.</p>
<p>So, how to install the Flash plugin?</p>
<p>Adobe says to refer to the browser documentation.  Google&#8217;s docs mention Flash as being built-in for 32-bit, but I couldn&#8217;t find mention of how to install for 64-bit.</p>
<p>Here&#8217;s how I did it: since Chrome seems to be using the symlink in the mozilla folder, which is managed by Debian&#8217;s &#8220;alternatives&#8221; system, I installed the plugin and added it as an alternative.</p>
<p>Step 1: Download the plugin from <a href="http://get.adobe.com/flashplayer/">http://get.adobe.com/flashplayer/</a>.  (This procedure explains the .tar.gz installation method; Adobe now offers an Apt-oriented solution as well but I have not tested this.)</p>
<p>Step 2: Install the plugin as follows:</p>
<pre class="brush: bash; title: ; notranslate">
sudo mkdir -pv /opt/flashplugin
cd /opt/flashplugin
sudo tar -xf &lt;path/to/flashplugin.tar.gz&gt;
</pre>
<p>Step 3: Install the plugin as a flash-mozilla.so alternative:</p>
<pre class="brush: bash; title: ; notranslate">
sudo update-alternatives --install \
    /usr/lib/mozilla/plugins/flash-mozilla.so \
    flash-mozilla.so \
    /opt/flashplugin/libflashplayer.so \
    10
</pre>
<p>Step 4: Select the Adobe plugin for use as the active plugin:</p>
<pre class="brush: bash; title: ; notranslate">
sudo update-alternatives --set flash-mozilla.so /opt/flashplugin/libflashplayer.so
</pre>
<p>That&#8217;s it!  Flash should now work in both Chrome and Firefox.  If it does not work immediately, restart your browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vultaire.net/blog/2011/05/26/google-chrome-and-flash-on-debian-squeeze-64-bit/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Adventures with C #1: GLib on Windows with MinGW/MSys using autotools</title>
		<link>http://www.vultaire.net/blog/2011/01/18/adventures-with-c-1-glib-on-windows-with-mingwmsys-using-autotools/</link>
		<comments>http://www.vultaire.net/blog/2011/01/18/adventures-with-c-1-glib-on-windows-with-mingwmsys-using-autotools/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 12:50:44 +0000</pubDate>
		<dc:creator>Paul Goins</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.vultaire.net/blog/?p=135</guid>
		<description><![CDATA[This is the first document in what may become a series of docs on cross-platform development using pure C (not C++) along with commonly available libraries. A brief aside about my background for newcomers: I&#8217;m experienced with Python and C++ (although admittedly rusty in the latter), and I&#8217;ve written straight C as well (in college, [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first document in what may become a series of docs on cross-platform development using pure C (<strong>not</strong> C++) along with commonly available libraries.</p>
<p>A brief aside about my background for newcomers: I&#8217;m experienced with Python and C++ (although admittedly rusty in the latter), and I&#8217;ve written straight C as well (in college, for work, for GNU Typist).  However, I feel my C skills are not as strong as they could be.</p>
<p>Basically, I know how to program and am not interested in reinventing the wheel.  My focus is on developing my skills with practical C development, using any open source available libraries which I can along with, if feasible/possible, the MinGW/MSys toolchain.</p>
<p>This first article is a tutorial of how to use GLib with the autotools on Windows via MinGW/MSys.</p>
<p><span id="more-135"></span></p>
<p>MinGW/MSys were installed via the <a href="http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/mingw-get-inst-20101030/mingw-get-inst-20101030.exe/download">automatic installer</a>.  Relevant versions of installed programs include gcc 4.5.0, automake 1.11.1, and autoconf 2.67.</p>
<p>The GTK+ bundle in use is <a href="http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/2.22/gtk+-bundle_2.22.0-20101016_win32.zip">gtk+-bundle_2.22.0-20101016_win32.zip</a>.  <em>I&#8217;m not actually using GTK+ in this project; however, the bundle includes GLib, pkg-config and the needed autoconf macros.</em></p>
<p>Unzip the GTK+ bundle somewhere on your system.  Add the bin folder to your PATH, likely at the beginning to avoid conflicts with other tools.</p>
<p>The m4 macros in the share/aclocal folder of the GTK+ bundle should be copied to the folder identified by <code>aclocal --print-ac-dir</code>.  On my system, this is /mingw/share/aclocal via the MSys shell.</p>
<p>Before going further, you should test pkg-config and make sure it works as expected:</p>
<pre class="brush: bash; title: ; notranslate">
pkg-config --cflags --libs glib-2.0

# Output on my machine:
#   -mms-bitfields -Ic:/gtk_bundle/include/glib-2.0 -Ic:/gtk_bundle/lib/glib-2.0/include  -Lc:/gtk_bundle/lib -lglib-2.0 -lintl
</pre>
<p>If this works, then create the following source file:</p>
<p>glib_test.c:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;glib.h&gt;
#include &lt;stdio.h&gt;

int main(int argc, char **argv) {
	printf(&quot;GLib version: %d.%d.%d\n&quot;,
		GLIB_MAJOR_VERSION,
		GLIB_MINOR_VERSION,
		GLIB_MICRO_VERSION);
	return 0;
}
</pre>
<p>Run autoscan to create configure.scan.  It should look like this initially:</p>
<pre class="brush: plain; title: ; notranslate">
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.67])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([glib_test.c])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT
</pre>
<p>We need to make a few changes to configure.scan to make a working configure.ac.</p>
<p>Autoconf will actually work without automake.  So, if we want to use automake as well, we need to add a macro for it:</p>
<pre class="brush: plain; title: ; notranslate">
AM_INIT_AUTOMAKE([foreign])
</pre>
<p>Also, we&#8217;re using GLib, which requires special linker and compiler flags provided by the pkg-config tool.  When using autoconf, we link these in via some special macros.</p>
<p>The following will check for pkg-config, get the needed flags from pkg-config for GLib, and assign them to two variables usable in automake:</p>
<pre class="brush: plain; title: ; notranslate">
PKG_PROG_PKG_CONFIG([0.23])  # Replace with target pkg-config version (I just used &quot;pkg-config --version&quot;)
PKG_CHECK_MODULES([GLIB], [glib-2.0 &gt;= 2.26.0])  # Replace with target GTK version number
AC_SUBST([GLIB_CFLAGS])
AC_SUBST([GLIB_LIBS])
</pre>
<p>Finally, we need to specify the makefiles we want to generate via ./configure.  For this example, we just need one: Makefile.</p>
<pre class="brush: plain; title: ; notranslate">
AC_CONFIG_FILES([Makefile])
</pre>
<p>While we&#8217;re working on this, go ahead and fill in some values for FULL-PACKAGE-NAME, VERSION and BUG-REPORT-ADDRESS.</p>
<p>Finally, if we merge all the above changes together and save as configure.ac, we should have something like the following:</p>
<pre class="brush: plain; title: ; notranslate">
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.67])
AC_INIT([glibtest], [0.1], [fakeaddress@foo.net])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([glib_test.c])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC
PKG_PROG_PKG_CONFIG([0.23])

# Checks for libraries.
PKG_CHECK_MODULES([GLIB], [glib-2.0 &gt;= 2.26.0])
AC_SUBST([GLIB_CFLAGS])
AC_SUBST([GLIB_LIBS])

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile])
AC_OUTPUT
</pre>
<p>Now that configure.ac is out of the way, we need a Makefile.am.  This will use the GLIB_CFLAGS and GLIB_LIBS variables made in the autoconf.ac.</p>
<p>Makefile.am:</p>
<pre class="brush: plain; title: ; notranslate">
bin_PROGRAMS = glib_test

glib_test_SOURCES = glib_test.c
glib_test_CFLAGS = $(GLIB_CFLAGS)
glib_test_LDADD = $(GLIB_LIBS)
</pre>
<p>The next step is to run <code>autoreconf -i</code>, which run all the necessary autotools and creates a configure file.</p>
<p>Run <code>./configure</code> followed by <code>make</code>.  This should compile the program.</p>
<p>Test the program: glib_test.exe.  The MSys shell output should be something like the following:</p>
<pre class="brush: plain; title: ; notranslate">
Vultaire@core /c/code/projects/glibtest
$ glib_test.exe
GLib version: 2.26.0
</pre>
<p>If you got this far, excellent.  You&#8217;re ready to start hacking with GLib.</p>
<p><em>An aside: why GLib?  Because it provides a number of the data structures which would be covered by the STL in C++, or as part of the standard library in many higher level languages.  It seems like a good foundation library to use for general development purposes, even if GTK+ is never used in the project.</em></p>
<p><strong>Update, 2011-Jan-19:</strong></p>
<p>Minor fix: Replaced glib_test_LIBS with glib_test_LDADD.  The former was a mistake; the latter is the proper variable for specifying extra libraries which need to be linked.</p>
<p>Also, some documentation references:</p>
<p><a href="http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/pkg_check_modules.html">http://www.flameeyes.eu/autotools-mythbuster/pkgconfig/pkg_check_modules.html</a>: My original source for the pkg-config macros.<br />
<a href="http://people.freedesktop.org/~dbn/pkg-config-guide.html#faq">http://people.freedesktop.org/~dbn/pkg-config-guide.html#faq</a>: Documents simple usage of the pkg-config macros with automake.<br />
<a href="http://sources.redhat.com/automake/automake.html">http://sources.redhat.com/automake/automake.html</a>: Automake manual (confirms that glib_test_LDADD is where we should put pkg-config input.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vultaire.net/blog/2011/01/18/adventures-with-c-1-glib-on-windows-with-mingwmsys-using-autotools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

