<?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>AkillesBlog</title>
	<atom:link href="http://blog.akilles.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.akilles.org</link>
	<description>Talk on programming, computers, electronics, web etc</description>
	<lastBuildDate>Sun, 23 Jan 2011 23:46:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>VLC Media Player &#8211; adding to Default Programs list in Windows 7</title>
		<link>http://blog.akilles.org/2010/06/13/vlc-media-player-as-default-for-all-supported-file-types-in-windows-7/</link>
		<comments>http://blog.akilles.org/2010/06/13/vlc-media-player-as-default-for-all-supported-file-types-in-windows-7/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 01:34:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Default Programs]]></category>
		<category><![CDATA[file type associations]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[VLC Media Player]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=89</guid>
		<description><![CDATA[Problems getting rid of Windows Media Player as default media player for media file types in Windows 7? So did I. I wanted to go to the &#8220;Default Programs&#8221;-menu (via Start menu or Control Panel), choose &#8220;Set your default programs&#8221; and setting up VLC Media Player as the default program for all its supported file [...]]]></description>
			<content:encoded><![CDATA[<p>Problems getting rid of Windows Media Player as default media player for media file types in Windows 7? So did I. I wanted to go to the &#8220;Default Programs&#8221;-menu (via Start menu or Control Panel), choose &#8220;Set your default programs&#8221; and setting up VLC Media Player as the default program for all its supported file types (which counts more than 50). However, at least on my computer, VLC doesn&#8217;t show up as a program in the list in the &#8220;Set your default programs&#8221;-utility:</p>
<p><a href="http://blog.akilles.org/wp-content/uploads/2010/06/screen2.png"><img src="http://blog.akilles.org/wp-content/uploads/2010/06/screen2-300x218.png" alt="" title="screen2" width="300" height="218" class="alignnone size-medium wp-image-73" /></a></p>
<p></p>
<p>For adding VLC to the list of programs, so that you easily can choose to set VLC as default for some or all its supported file types, I&#8217;ve made a registry fix/patch. If you choose to try this, use it at your own responsibility (and preferably read through it before executing)! I take no responsibility for this whatsoever. And if you have knowledge of the registry and have comments to my fix, please comment! BTW, the fix requires you to having installed VLC at its default location; C:\Program Files\VideoLAN\VLC\vlc.exe.</p>
<p>Download the registry fix here: <a href='http://blog.akilles.org/wp-content/uploads/2010/06/default_programs_-_register_VLC.reg_.txt'>default_programs_-_register_VLC.reg</a></p>
<p>For execution, download, and remove the &#8220;.txt&#8221;-suffix, so that you gain a &#8220;.reg&#8221;-file. Then double-click this file. </p>
<p>For finishing up, go to Control Panel -> Default Programs -> Set your default programs. Verify that VLC media player shows up in the list of programs. Click it, and choose if you want to make it the default program for supported file types. <img src='http://blog.akilles.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p></p>
<p>For comments about the fix, and about adding programs to the &#8220;Set your default programs&#8221;-utility in general, please <a href="http://blog.akilles.org/2010/06/13/default-programs-in-windows-7-adding-program-to-list-of-programs/">see my blogpost on this topic</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2010/06/13/vlc-media-player-as-default-for-all-supported-file-types-in-windows-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Default Programs in Windows 7 &#8211; adding program to list of programs</title>
		<link>http://blog.akilles.org/2010/06/13/default-programs-in-windows-7-adding-program-to-list-of-programs/</link>
		<comments>http://blog.akilles.org/2010/06/13/default-programs-in-windows-7-adding-program-to-list-of-programs/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 00:58:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Default Programs]]></category>
		<category><![CDATA[file type associations]]></category>
		<category><![CDATA[registry]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=71</guid>
		<description><![CDATA[When you want to control which file types an installed program should open/handle in Windows 7 (or Vista), one option is to go to the &#8220;Default Programs&#8221; via Control Panel or the Start menu, and then choose &#8220;Set your default programs&#8221;. Some programs, however, don&#8217;t show up in this list. This was the case for [...]]]></description>
			<content:encoded><![CDATA[<p>When you want to control which file types an installed program should open/handle in Windows 7 (or Vista), one option is to go to the &#8220;Default Programs&#8221; via Control Panel or the Start menu, and then choose &#8220;Set your default programs&#8221;. Some programs, however, don&#8217;t show up in this list. This was the case for VLC media player on my PC.</p>
<p>If you want a quick fix for VLC, <a href="http://blog.akilles.org/2010/06/13/vlc-media-player-as-default-for-all-supported-file-types-in-windows-7/">look at this other post</a>. If you want to read in general about adding programs to the list in &#8220;Set your default programs&#8221;, read on:</p>
<p>This is probably more a nuisance than a problem, because you can attack the file association from the other side, by opening the settings for each file type one-at-a-time and associate it with the program (right-click file -> open with -> select program). However, this can be really time consuming and frustrating with a media player or any other program with more than 50 file type associations.</p>
<p>Therefore, it would be nice to use the &#8220;Set your default programs&#8221;-feature, where one can view all file types supported by a program, and associate some or all file types to the program with few clicks.</p>
<p></p>
<p>I&#8217;ll soon describe how to add missing programs to this list. First some screenshots to get the picture: <img src='http://blog.akilles.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Screen #1: Open this via Start -> Default Programs, and then click &#8220;Set your default programs&#8221; as indicated below:<br />
<a href="http://blog.akilles.org/wp-content/uploads/2010/06/screen1.png"><img src="http://blog.akilles.org/wp-content/uploads/2010/06/screen1-300x212.png" alt="" title="screen1" width="300" height="212" class="alignnone size-medium wp-image-72" /></a></p>
<p>Screen #2: Here is the program list, with VLC media player (or other program) missing:<br />
<a href="http://blog.akilles.org/wp-content/uploads/2010/06/screen2.png"><img src="http://blog.akilles.org/wp-content/uploads/2010/06/screen2-300x218.png" alt="" title="screen2" width="300" height="218" class="alignnone size-medium wp-image-73" /></a></p>
<p>Screen #3: Here is what we want, and how it looks after our fix:<br />
<a href="http://blog.akilles.org/wp-content/uploads/2010/06/screen3.png"><img src="http://blog.akilles.org/wp-content/uploads/2010/06/screen3-300x218.png" alt="" title="screen3" width="300" height="218" class="alignnone size-medium wp-image-74" /></a></p>
<h3>The fix</h3>
<p>This requires some familiarity with the Windows Registry (regedit). And NOTE: I take no responsibility for anything you do or don&#8217;t in relation to this fix or anything else on this blog. Be careful in the registry (mistakes can break your operative system), and remember it&#8217;s your own responsibility!</p>
<p><em>First some registry terms. In the regedit-editor:</em> A <strong>key</strong> is displayed in left pane with a folder icon, a <strong>value</strong> is an item displayed as a line in right pane, while <strong>data</strong> is the data contained in the value. A &#8220;string value&#8221; is a value containing a string as data.</p>
<p>Now some todo-points (for more specifics, <em>see example</em> below):</p>
<ul>
<li>Fire up regedit.exe with Admin-privileges.</li>
<li>Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\, and find as a key an equivalent to ProgramName (i.e. VLC) or VendorName\ProgramName (i.e. VideoLAN\VLC) under there.</li>
<li>Add a key called &#8216;Capabilites&#8217; under the ProgramName key.</li>
<li>Add these three string values under Capabilities: ApplicationDescription, ApplicationName, ApplicationIcon. <em>For contained data in these values, see example and apply imagination.</em></li>
<li>Now, add a key called &#8216;FileAssociations&#8217; under Capabilities. Under here, add string values referencing file type keys under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ <em>(see example)</em>.</li>
<li>Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications, and add a string value called i.e. &#8220;VLC media player&#8221;, with data set to &#8220;Software\ProgramName\Capabilities&#8221;. <em>Change ProgramName according to actual program name.</em></li>
</ul>
<h3>Example</h3>
<p>As an <strong>example</strong>, here is the registry-export of my registry additions when I was finished fixing VLC media player:</p>
<p><code><br />
[HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC\Capabilites]<br />
"ApplicationDescription"="VLC media player is a free and open source media player and multimedia framework written by the VideoLAN project. The default distribution of VLC includes a large number of free decoding and encoding libraries; this greatly reduces the need for finding/calibrating proprietary plugins."<br />
"ApplicationName"="VLC media player"<br />
"ApplicationIcon"="C:\Program Files\VideoLAN\VLC\vlc.exe,0"</p>
<p>[HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC\Capabilites\FileAssociations]<br />
".mp3"="VLC.mp3"<br />
".wav"="VLC.wav"<br />
".wma"="VLC.wma"<br />
".avi"="VLC.avi"<br />
".mpg"="VLC.mpg"<br />
(TRUNCATED)</p>
<p>[HKEY_LOCAL_MACHINE\SOFTWARE\RegisteredApplications]<br />
"VLC media player"="Software\VideoLAN\VLC\Capabilites"<br />
</code></p>
<p><em>Some comments to the example:</em> Under [HKEY_LOCAL_MACHINE\SOFTWARE\VideoLAN\VLC\Capabilites\FileAssociations] above: The VLC.* values references keys under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\. For instance, the &#8220;VLC.mp3&#8243; references the key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VLC.mp3, which existed from the installation of VLC media player. Under the key HKEY_LOCAL_MACHINE\SOFTWARE\Classes\VLC.mp3, there exists values that describes how a MP3-file is opened if double-clicked while VLC is the associated program.</p>
<p></p>
<p>For a full example, please see my blogpost about <a href="http://blog.akilles.org/2010/06/13/vlc-media-player-as-default-for-all-supported-file-types-in-windows-7/">VLC media player</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2010/06/13/default-programs-in-windows-7-adding-program-to-list-of-programs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing Emacs Muse on Windows XP</title>
		<link>http://blog.akilles.org/2009/03/14/installing-emacs-muse-on-windows/</link>
		<comments>http://blog.akilles.org/2009/03/14/installing-emacs-muse-on-windows/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 19:31:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[editor]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[installing]]></category>
		<category><![CDATA[muse]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=67</guid>
		<description><![CDATA[This post will deal with the installation of the GNU Emacs editor plus the Emacs Muse authoring/publishing environment running Windows XP. Download &#038; extract GNU Emacs First, obtain the latest precompiled Emacs binaries for Windows. Get it directly from the FTP location here, alternatively follow the link from the Getting Emacs guide. Download the latest [...]]]></description>
			<content:encoded><![CDATA[<p>This post will deal with the installation of the GNU Emacs editor plus the Emacs Muse authoring/publishing environment running Windows XP.</p>
<p></p>
<h2>Download &#038; extract</h2>
<h3>GNU Emacs</h3>
<p>First, obtain the latest precompiled Emacs binaries for Windows. Get it directly from <a href="http://ftp.gnu.org/gnu/emacs/windows/">the FTP location here</a>, alternatively follow the link from the <a href="http://www.gnu.org/software/emacs/windows/Getting-Emacs.html">Getting Emacs guide</a>. Download the latest zip-version marked <strong>bin</strong>; <strong>emacs-22.3-<em>bin</em>-i386.zip</strong> these days.</p>
<p>For the full guide on installing emacs on Windows, consult <a href="http://www.gnu.org/software/emacs/windows/Installing-Emacs.html">this</a> guide.</p>
<p>After downloading, extract the Emacs zip-file to a permanent location on your computer, i.e. <strong>C:\Program Files\emacs</strong>, so that this folder directly contains the folders bin,etc,lisp and so on.</p>
<h3>Muse</h3>
<p>Second, download the latest Emacs Muse (hereafter only called Muse) zip-file. Get it directly from <a href="http://download.gna.org/muse-el">here</a>, alternatively follow the link from the project&#8217;s home page <a href="http://mwolson.org/projects/EmacsMuse.html#sec3">here</a>.</p>
<p>Extract the Muse zip-file to, for instance, <strong>C:\Program Files\emacs_muse</strong>.</p>
<h2>Integration</h2>
<p>Now it&#8217;s time to make include Muse into your Emacs installation/folder: Copy all contents of <strong>C:\Program Files\emacs_muse\lisp\</strong> to <strong>C:\Program Files\emacs\lisp\</strong>.</p>
<h3>The HOME environmental variable</h3>
<p>We must now set up the <strong>.emacs</strong> <em>init file</em>, residing in your HOME directory. But first, we need to make sure you have HOME environmental variable. Check it by clicking Start->Run. Type in %HOME% and click OK. Does it open a folder? If so, notice the path of this folder. This is where we&#8217;re putting the .emacs init file. If you instead get an error, you must first set the HOME environmental variable:</p>
<p>Start->Settings->Control Panel->System->Advanced->Environmental Variables. In the upper field (user variables), press New. Name=HOME, Value=(whatever path you choose as your home folder. Make sure it exists!). OK x 2.</p>
<h3>Editing the .emacs init file</h3>
<p>Now that you have a HOME folder, open it: Start->Run. Type in %HOME% and click OK.</p>
<p>Create and edit a file named <strong>_emacs</strong> or <strong>.emacs</strong>, any one is good (.emacs is the original file name as used in Unix environments, but Explorer won&#8217;t let you create a file with filename starting with a dot, so therefore it&#8217;s easier to use the name _emacs). Put this contents into the file:</p>
<p><code><br />
	(setq load-path (add-to-list 'load-path "C:\Program Files\emacs_muse"))<br />
	(require 'muse-mode)<br />
	(require 'muse-publish)<br />
	(require 'muse-html)  ;; and so on<br />
</code></p>
<p>For further contents regarding Muse in this file; see <a href="http://mwolson.org/projects/MuseQuickStart.html">here</a> under the heading &#8220;Getting Started&#8221;.</p>
<p></p>
<h2>Testing</h2>
<p>Now, start emacs by running the file: <strong>C:\Program Files\emacs\bin\runemacs.exe</strong>.</p>
<p>Create a new file <em>with the .muse filename extension</em>, (automatically puts emacs in muse mode) i.e. <em>musetest.muse</em>, and you&#8217;re set. Try typing something like (notice space bewtween asterisk and text in headings):</p>
<p><code><br />
* Heading 1<br />
** Heading 2</p>
<p>Test contents.</p>
<p>----</p>
<p>The end of the beginning.<br />
</code></p>
<p>&#8230; and notice that the two first lines (the headings) aquire different font weights. If they do; congratulations on your successful Emacs + Emacs Muse installation! If not, maybe you haven&#8217;t got emacs into muse mode. Try doing so by pressing Alt-x, then write muse-mode and hit return.</p>
<p>In the end, try publishing to HTML by hitting Ctrl-c Ctrl-t on the keyboard and follow the instructions in the &#8220;status field&#8221; in the bottom of the Emacs window.</p>
<h2>Diving deeper</h2>
<p>For diving deeper into muse, reference the project&#8217;s documentation:</p>
<ul>
<li><a href="http://mwolson.org/projects/MuseQuickStart.html">http://mwolson.org/projects/MuseQuickStart.html</a></li>
<li><a href="http://mwolson.org/static/doc/muse/">http://mwolson.org/static/doc/muse/</a></li>
<li><a href="http://mwolson.org/projects/EmacsMuse.html">http://mwolson.org/projects/EmacsMuse.html</a> &#8211; the muse maintainer&#8217;s project page</li>
</ul>
<h2>References</h2>
<ul>
<li><a href="http://www.gnu.org/software/emacs/windows/Installing-Emacs.html">http://www.gnu.org/software/emacs/windows/Installing-Emacs.html</a></li>
<li><a href="http://mwolson.org/projects/MuseQuickStart.html">http://mwolson.org/projects/MuseQuickStart.html</a></li>
<li><a href="http://www.linuxjournal.com/article/9116#comment-331272">http://www.linuxjournal.com/article/9116#comment-331272</a> <em>(on lisp to lisp folder copying, regarding Org-mode installation in emacs)</em></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2009/03/14/installing-emacs-muse-on-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caching of PHP scripts with query strings</title>
		<link>http://blog.akilles.org/2009/01/10/caching-of-php-scripts-with-query-strings/</link>
		<comments>http://blog.akilles.org/2009/01/10/caching-of-php-scripts-with-query-strings/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 19:41:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[url rewrite]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=66</guid>
		<description><![CDATA[Trying to decrease bandwith usage and page loading time, I&#8217;ve enabled caching on some of my web pages recently. Caching can be done in many ways, and with PHP-scripts running on Apache, I have the choice of enabling caching in either .htaccess-files, in the HTML-header or in the HTTP header. I think sending HTTP headers [...]]]></description>
			<content:encoded><![CDATA[<p>Trying to decrease bandwith usage and page loading time, I&#8217;ve enabled caching on some of my web pages recently. Caching can be done in many ways, and with PHP-scripts running on Apache, I have the choice of enabling caching in either .htaccess-files, in the HTML-header or in the HTTP header. I think sending HTTP headers from PHP gives the best control, having all programatically possibilities for conditional caching and headers.</p>
<p>For basic caching of a generated PHP-page I find the &#8220;Expires&#8221; / &#8220;max-age&#8221; HTTP headers the most convenient to use;</p>
<pre class="brush: php; title: ;">
//Cache for 15 minutes:
$maxage = 60*15;
header (&quot;Cache-Control: max-age=$maxage&quot;);
header ('Expires: ' . gmstrftime(&quot;%a, %d %b %Y %H:%M:%S GMT&quot;, time() + $maxage));
</pre>
<p>With this method, the page will be loaded from the user&#8217;s browser-cache instead of from my server until $maxage seconds have passed. After that, a new visit to the page will be freshly loaded from my server to the browser&#8217;s cache again, and will live there for another $maxage seconds. This <strong>works well with</strong> URLs such as </p>
<ul>
<li>http://www.example.com/index.php</li>
<li>http://www.example.com/index.html</li>
<li>http://www.example.com/</li>
<li>http://www.example.com/pages/frontpage/</li>
</ul>
<p><strong>but not with</strong> URLs containing query strings:</p>
<p>http://www.example.com/index.php<em>?page=frontpage&#038;itemcount=10</em></p>
<p></p>
<h2>The problem with query strings</h2>
<p>If the URL to the page in question contains a query string (starting with the question mark in this URL: http://www.example.com/index.php?page=frontpage&#038;itemcount=10), the HTTP standard says that the browser never should cache that page. Using standard-compliant browsers like Opera, you&#8217;ll have to <strong>get rid of that query string</strong> to enable caching of such pages.</p>
<p>I long scratched my head over this, but was after a while enlightened by <a href="http://www.thinkvitamin.com/features/webapps/serving-javascript-fast">Cal Henderson&#8217;s post</a>:</p>
<blockquote><p>
According the letter of the HTTP caching specification, user agents should never cache URLs with query strings. While Internet Explorer and Firefox ignore this, Opera and Safari don’t &#8211; to make sure all user agents can cache your resources, we need to keep query strings out of their URLs.
</p></blockquote>
<h2>Getting rid of the query string &#8211; URL rewriting</h2>
<p></p>
<p>URL rewriting can be used to <em>tricking</em> the browser into believing we&#8217;re browsing an ordinary page without query strings. URL rewriting means that the user and the user&#8217;s browser enters and sees an URL like http://www.example.com/frontpage.asdf, while the Apache web server internally translates this to, let&#8217;s say, http://www.example.com/index.php?page=frontpage, running your index.php script with the right GET parameters.</p>
<p>Using Apache, this is as easy as writing some RewriteRules in a .htaccess-file, for instance:<br />
<code><br />
RewriteEngine On</p>
<p>#do not rewrite requests for /index.php:<br />
RewriteRule	^index.php$	-			[L]</p>
<p>#rewrite /frontpage.asdf, /photos.asdf<br />
#to /index.php?page=frontpage etc:<br />
RewriteRule	^(.*?).asdf$	/index.php?page=$1	[QSA,L]<br />
</code></p>
<p>More tips and tricks about URL rewriting can be read <a href="http://www.askapache.com/htaccess/mod_rewrite-tips-and-tricks.html">here</a> and many other places. Google it!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2009/01/10/caching-of-php-scripts-with-query-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>preg_replace in PHP with /e flag</title>
		<link>http://blog.akilles.org/2008/09/17/preg_replace-in-php-with-e-flag/</link>
		<comments>http://blog.akilles.org/2008/09/17/preg_replace-in-php-with-e-flag/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 18:36:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[RegEx]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=65</guid>
		<description><![CDATA[The /e flag makes the (quoted) replacement string to be treated as PHP-code, so that one can make more complex regex-replacements in a one-liner. An example: I want to search for a pattern in a string, and replace any occurences with an array element whose key/index equals the occurence. Without the /e flag this wouldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>The /e flag makes the (quoted) replacement string to be treated as PHP-code, so that one can make more complex regex-replacements in a one-liner.</p>
<p>An example: I want to search for a pattern in a string, and replace any occurences with an array element whose key/index equals the occurence.</p>
<p>Without the /e flag this wouldn&#8217;t be as easy, because this <strong>does not</strong> work;</p>
<pre class="brush: php; title: ;">
$pattern = '/\{(.*?)\}/i';
$outputline = preg_replace($pattern, $array[\\1], $inputline); //doesn't make any sense
</pre>
<p>With the /e flag, however, this works like a charm;</p>
<pre class="brush: php; title: ;">
$pattern = '/\{(.*?)\}/ei'; //note the /e flag
$outputline = preg_replace($pattern, '$array[\\1]', $inputline); //works with /e flag
</pre>
<p>This replaces occurences of $pattern in $inputline with $array[OccurenceOfPatternInInputline] and assigns the result to $outputline.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2008/09/17/preg_replace-in-php-with-e-flag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gentoo md (Software RAID) RAID5 disk crash</title>
		<link>http://blog.akilles.org/2008/05/13/exciting-days-with-md-raid5-disk-crash/</link>
		<comments>http://blog.akilles.org/2008/05/13/exciting-days-with-md-raid5-disk-crash/#comments</comments>
		<pubDate>Mon, 12 May 2008 23:55:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[crash]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[md]]></category>
		<category><![CDATA[RAID]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=64</guid>
		<description><![CDATA[How to recreate and assemble a Gentoo md software RAID (RAID5) array, where two disks have bad superblocks and one of these are permanently faulty.]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s spring, so the weather outside is outstanding. The days are longer, the birds are singing and people enjoy the nature wakening up for a new summer of growth.<br />
Having my exams in near future, I&#8217;m content that I can&#8217;t use a great deal of my time enjoying the spring yet for another few weeks. But at least I&#8217;ve set aside the time I need for preparing my exams&#8230;<br />
&#8230;, I thought. Then, in the middle of my mail inbox I&#8217;ve received a mail from Charlie Root at my Gentoo server. Hardly a request for a bicycle ride in the sunshine:<br />
<code>WARNING: Some disks in your RAID arrays seem to have failed!</code> is the message.</p>
<p></p>
<p><i>Damn,</i> the third year in a row(!) something erroneous happens to my server in the middle of my exam preparations. Why can&#8217;t it happen during fall, when the weather&#8217;s bad and I have the time for such challenges.<br />
Well, I suppose it&#8217;s <em><a href="http://en.wikipedia.org/wiki/Murphy's_law">Murphy&#8217;s law</a></em>. However, over to a more precise description of the problem&#8230;</p>
<h2>The problem</h2>
<p>I have 6 SATA disks in a RAID5 software array (through the use of Gentoo&#8217;s md), on which an XFS filesystem is mounted.</p>
<p>The actual error is that two(!) of my disks became faulty overnight. Diagnostics follow.</p>
<p><em>/proc/mdstat</em>:<br />
<code>md0 : active raid5 sdf1[5] sde1[6](F) sdd1[3] sdc1[2] sdb1[1] sda1[7](F)<br />
      (some number) blocks level 5, 64k chunk, algorithm 2 [6/4] [_UUU_U]</code><br />
I really got nervous here; 2 faulty disks in a RAID5 array means trouble. But why on earth did two disks fail at one time??  I&#8217;m not sure yet.</p>
<p><em>dmesg</em> excerpt:<br />
<code>md: Autodetecting RAID arrays.<br />
md: autorun ...<br />
md: considering sdf1 ...<br />
md:  adding sdf1 ...<br />
md:  adding sde1 ...<br />
md:  adding sdd1 ...<br />
md:  adding sdc1 ...<br />
md:  adding sdb1 ...<br />
md:  adding sda1 ...<br />
md: created md0<br />
md: bind<sda1><br />
md: bind<sdb1><br />
md: bind<sdc1><br />
md: bind<sdd1><br />
md: bind<sde1><br />
md: bind<sdf1><br />
md: running: <sdf1><sde1><sdd1><sdc1><sdb1><sda1><br />
md: kicking non-fresh sde1 from array!<br />
md: unbind<sde1><br />
md: export_rdev(sde1)<br />
md: kicking non-fresh sda1 from array!<br />
md: unbind<sda1><br />
md: export_rdev(sda1)<br />
raid5: device sdf1 operational as raid disk 5<br />
raid5: device sdd1 operational as raid disk 3<br />
raid5: device sdc1 operational as raid disk 2<br />
raid5: device sdb1 operational as raid disk 1<br />
raid5: not enough operational devices for md0 (2/6 failed)<br />
RAID5 conf printout:<br />
 --- rd:6 wd:4<br />
 disk 1, o:1, dev:sdb1<br />
 disk 2, o:1, dev:sdc1<br />
 disk 3, o:1, dev:sdd1<br />
 disk 5, o:1, dev:sdf1<br />
raid5: failed to run raid set md0<br />
md: pers->run() failed ...<br />
md: do_md_run() returned -5<br />
md: md0 stopped.<br />
md: unbind<sdf1><br />
md: export_rdev(sdf1)<br />
md: unbind<sdd1><br />
md: export_rdev(sdd1)<br />
md: unbind<sdc1><br />
md: export_rdev(sdc1)<br />
md: unbind<sdb1><br />
md: export_rdev(sdb1)</code></p>
<p>It seems like sda is the only faulty one (<i>mdadm &#8211;examine</i> says it doesn&#8217;t have a superblock at all), but the crash of this one must have messed up the superblock of sde. However, it (the superblock of sde) was recreatable, and thereby also the RAID5-array as a whole: RAID5 allows for one disk (in this case, sda) to fail, but then you have no extra parachute, until you replace that faulty one.</p>
<p></p>
<h2>The (temporary) solution</h2>
<p>The superblock information for the different disks in the RAID-array were extracted for each disk with<br />
<code>mdadm --examine /dev/sda1</code><br />
and so on. I noted (that is, copy-paste) the exact information for all disks, for (at least) using as option input to the <i>mdadm &#8211;create</i>-command in the next paragraph.</p>
<p>I ran (<b><em>Warning:</em></b> do this at your <b>own risk</b>! It&#8217;s incredibly important setting the right options here, so be sure you&#8217;ve read and understand the contents of <i>man mdadm</i> first! Failing to do so will result in loss of data!):<br />
<code>mdadm --create --verbose /dev/md0 --level=5 --raid-devices=6 missing /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1</code>, which put the array back up in degraded mode, with the erroneous disk sda set to missing. This was sufficient to be able to mount the array, but not without problems.</p>
<h2>Mounting the degraded array</h2>
<p>A first attempt on &#8220;mount /dev/md0 /mnt&#8221; gave the error &#8220;mount: Structure needs cleaning&#8221;. This is the XFS filesystem telling it&#8217;s not entirely consistent. I could possibly run xfs_repair (I did, in a pretend-type-mode, with the -n option), but I&#8217;m not willing to risk my data on this yet. Instead, I did get the device mounted with this command:<br />
<code>mount -r -o norecovery /dev/md0  /mnt</code></p>
<p>In this way, I can now access my data and make a backup of them. Some data is probably corrupted without repairing the XFS file system, but hopefully most of it is recoverable&#8230;</p>
<h2>Some of the pages I visited in my frustration</h2>
<ul>
<li><a href="http://www.issociate.de/board/post/461227/kicking_non-fresh_member_from_array?.html">Kicking non-fresh member from array</a></li>
<li><a href="http://www.issociate.de/board/post/413817/Linux_Software_RAID_Bitmap_Question.html">Linux RAID bitmap question</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2008/05/13/exciting-days-with-md-raid5-disk-crash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Saving as JPEG with Photoshop</title>
		<link>http://blog.akilles.org/2008/04/21/saving-as-jpeg-with-photoshop/</link>
		<comments>http://blog.akilles.org/2008/04/21/saving-as-jpeg-with-photoshop/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 18:07:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[photoshop]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=63</guid>
		<description><![CDATA[After having edited a photo from camera with 16-bit AdobeRGB color, here is what I do to save as JPEG while maintaining finetuned colors and tones: Flatten image (from many layers to one layer). Convert to 8 bit (JPEG doesn&#8217;t support 16 bit): Image -> Mode -> 8 bits/Channel Convert Color Profile (Edit->Convert To Profile&#8230;) [...]]]></description>
			<content:encoded><![CDATA[<p>After having edited a photo from camera with 16-bit AdobeRGB color, here is what I do to save as JPEG while maintaining finetuned colors and tones:</p>
<ul>
<li>Flatten image (from many layers to one layer).</li>
<li>Convert to 8 bit (JPEG doesn&#8217;t support 16 bit): Image -> Mode -> 8 bits/Channel</li>
<li><strong>Convert</strong> Color Profile (Edit->Convert To Profile&#8230;) to sRGB.<br />
Important to choose <em>Convert to&#8230;</em> and not <em>Assign&#8230;</em>!</li>
<li>Then save as JPEG using either <em>Save As</em> or <em>Save for Web &#038; Devices</em>. Use the first to preserve EXIF tags from camera, use the latter if you want to finetune compression and target file size.</li>
</ul>
<p>Read more about color spaces/profiles and skin tones at <a href="http://www.smugmug.com/help/srgb-versus-adobe-rgb-1998">SmugMug.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2008/04/21/saving-as-jpeg-with-photoshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails: Experimenting with ActiveScaffold</title>
		<link>http://blog.akilles.org/2008/04/17/ruby-on-rails-experimenting-with-activescaffold/</link>
		<comments>http://blog.akilles.org/2008/04/17/ruby-on-rails-experimenting-with-activescaffold/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 01:00:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[ActiveScaffold]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[scaffolding]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/?p=61</guid>
		<description><![CDATA[Introduction Here I will set up a sample Ruby on Rails application with the ActiveScaffold scaffolding plugin. I will first give the basic instructions to a default setup (as found on ActiveScaffold&#8217;s site, only with my field names and values), and will then make some tweaks and override some of the default configuration. It&#8217;s all [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p>Here I will set up a sample Ruby on Rails application with the ActiveScaffold scaffolding plugin. I will first give the <strong><a href="#basic">basic instructions to a default setup</a></strong> (as found on ActiveScaffold&#8217;s site, only with my field names and values), and will then make some <strong><a href="#overrides">tweaks and override</a></strong> some of the default configuration. It&#8217;s all very basic, but it can be a help for those trying out ActiveScaffold for their first time.</p>
<p><strong>The case we&#8217;re working on:</strong> create a list of <em>Equipment</em>, i.e. electronic gadgets you&#8217;re planning to buy. We want to register title, price, an url to the product page of a webstore, an image url, some description and whether it&#8217;s in the webstore&#8217;s stock. Aditionally, we would like to <em>calculate</em> the registered price into another currency. All of this is to be shown in a sortable, searchable list.</p>
<p>It will be <strong><a href="http://blog.akilles.org/wp-content/uploads/2008/04/equipment.png">looking like this</a></strong> when we&#8217;re done.</p>
<p>After some years developing and experimenting with PHP, I&#8217;ve become curious of Ruby on Rails and what it has to offer in ease and &#8220;speedy&#8221; development. I&#8217;m for the time being an absolute rookie in RoR, but I&#8217;ve had a look on some resources on the net and have tried making a few very basic &#8220;test&#8221; applications.</p>
<p>Having limited experience regarding web development <em>frameworks</em>, it takes a few scratches on the head to get the <a href="http://betterexplained.com/articles/intermediate-rails-understanding-models-views-and-controllers/">concept of MVC</a> and knowing what does what (M=model, V=view, C=controller) and what calls what. Generating a scaffold and investigating the different files helps grasping the concept after a while.</p>
<p>The first time I saw the result of a scaffold-generation, I was convinced that this kind of development was something to look further into. However, after having seen samples of other scaffold generators, the default one seems a little <em>static</em> and cumersome to override: It seems like the default scaffolding generator is meant for running once, and then hardcode-editing the scaffold-generated code. Then, if you for some reason have to rescaffold, you must reimplement the changes. Also, the result is rather static without &#8220;fancy stuff&#8221; like Ajax.</p>
<p>Therefore, I had to test out the ActiveScaffold scaffolding plugin. It&#8217;s very easily installed, quickly up and running (a getting-started-tutorial on their site is estimated to 2 minutes from scratch), produces a smooth Ajax&#8217;ed design and is very easily to override and configure.</p>
<p>Remember, though, that I&#8217;m quite new to RoR, so I haven&#8217;t a broad basis of comparison, and there may be better practices for what I&#8217;m doing here. If so, please tell me! <img src='http://blog.akilles.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Assumptions</h3>
<p>I think the majority of the steps in this tutorial should work with most versions (except the scaffolding, which is different in rails v. >= 2), but here&#8217;s what I&#8217;ve used:</p>
<ul>
<li>Rails 1.2.6 <em>(yes, I know, it&#8217;s time to upgrade&#8230;)</em></li>
<li>Ruby 1.8.6</li>
<li>ActiveScaffold rev. 739</li>
</ul>
<p><strong>I assume you have</strong> a working rails-application, set up with connection to an existing database and accessible through a web browser before starting off.</p>
<p></p>
<p><a name="basic"><br />
<h3>Basic setup</h3>
<p></a></p>
<p>The first thing we&#8217;re gonna do, is <strong>create a new table</strong> in the database to which the application connects. I created a table called <em>equipment</em> like this in my MySql database:</p>
<pre class="brush: sql; title: ;">
CREATE TABLE equipment (
  id int(10) unsigned NOT NULL auto_increment,
  title varchar(255) NOT NULL,
  descr text NOT NULL,
  price float NOT NULL,
  updated timestamp NOT NULL
    default CURRENT_TIMESTAMP
    on update CURRENT_TIMESTAMP,
  url varchar(255) NOT NULL,
  imgurl varchar(255) NOT NULL,
  instock tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (id)
) ;
</pre>
<p>Then, let the generator scripts <strong>make the appropriate files</strong> we&#8217;ll be working on. 4 types of files are created, but we&#8217;re only interested in 3 of these; the <em>model</em>, <em>controller</em> and <em>helper</em> files, not the <em>view</em> files. However, we&#8217;ll just delete the view files afterwards&#8230;<br />
Open up a terminal window, and cd to your rails application root folder. Then run<br />
<code>./script/generate scaffold Equipment</code></p>
<p>Now, <strong>delete</strong> the unnecessary views files (not only unnecessary; they also override the ActiveScaffold which we&#8217;ll put to work later on, so <strong>follow this step!</strong>):<br />
<code>rm -R app/views/equipment/</code></p>
<p>Now it&#8217;s about time to <strong>install</strong> the ActiveScaffold plugin:<br />
<em>([Parts of] the following few steps are borrowed from ActiveScaffold&#8217;s <a href="http://activescaffold.com/">website</a>)</em><br />
<code>./script/plugin install http://activescaffold.googlecode.com/svn/tags/active_scaffold</code></p>
<p>When the plugin has been downloaded and installed, you need to <strong>update</strong> a few of your files.<br />
Add this to the <em>head</em>-section of your <em>app/views/layouts/equipment.rhtml</em> file:</p>
<pre class="brush: ruby; title: ;">
  &lt;%= javascript_include_tag :defaults %&gt;
  &lt;%= active_scaffold_includes %&gt;
</pre>
<p>It should then look something like this:</p>
<pre class="brush: ruby; title: ;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
       &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html;charset=UTF-8&quot; /&gt;
  &lt;title&gt;as test&lt;/title&gt;
  &lt;%= javascript_include_tag :defaults %&gt;
  &lt;%= active_scaffold_includes %&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;p style=&quot;color: green&quot;&gt;&lt;%= flash[:notice] %&gt;&lt;/p&gt;

&lt;%= yield  %&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Then, <strong>edit</strong> your <em>app/controllers/equipment_controller.rb</em>, so that it looks similar to this:</p>
<pre class="brush: ruby; title: ;">
class EquipmentController &lt; ApplicationController
  @equipment_pages, @equipment = paginate :equipment, :per_page =&gt; 10
  layout &quot;equipment&quot;
  active_scaffold :equipment
end
</pre>
<p>Also, quote from <a href="http://activescaffold.com/tutorials/getting-started">http://activescaffold.com/tutorials/getting-started</a>:</p>
<blockquote><p>3a. Make sure that you don’t have AjaxScaffold installed in your project. Since ActiveScaffold evolved out of AjaxScaffold they share some common method names and are incompatible with each other.</p></blockquote>
<p>Then you&#8217;re <strong>done</strong> with basic setup. Now browse to http://your-rails-app-root/Equipment, and hopefully you&#8217;ll see the magnificent Ajax&#8217;ed layout created by ActiveScaffold. Isn&#8217;t it wonderful?</p>
<p>If you, like me, are running Rails on Apache/FastCGI, you may have to restart your Apache httpd-server every now and then (I don&#8217;t know of any other methods of killing/restarting the rails fastCGI-scripts being run by apache. If you know; please tell me!). When testing new stuff and/or when getting errors, I always restart apache to see if the problem still persists.</p>
<p>Up to now, we&#8217;ve basically dealt with initial setup covered by ActiveScaffold&#8217;s own <a href="http://activescaffold.com/tutorials/getting-started">Getting Started-tutorial</a>. Now it&#8217;s time to tweak the config to our needs.</p>
<p></p>
<p><a name="overrides"><br />
<h3>Tweaking and overriding default ActiveScaffold config</h3>
<p></a></p>
<p>I&#8217;m over all very satisfied with the looks and functionality of the initial output, especially when considering it almost takes no time at all. However, since ActiveScaffold can&#8217;t know how I plan to view my data, there are some overrides to be done. Datafields are overridden very smoothly by creating small methods with designated names in the right classes.</p>
<p>Anyways, here&#8217;s what I&#8217;m gonna do:</p>
<ul>
<li>Show the <strong>image</strong> pointed to by <em>imgurl</em> instead of the url itself.</li>
<li>Put the image inside an <em>&lt;a href&#8230;&gt;</em>-tag, so that the image <strong>links to the url</strong> in the <em>url</em>-field.</li>
<li>Create/include a <strong>virtual column</strong> that shows the price in <strong>a foreign currency</strong> as well as in USD.</li>
<li><strong>Format</strong> the two price-columns with <em>sprintf</em></li>
<li><strong>Reorder</strong> the columns</li>
<li><strong>Exclude</strong> the <em>descr</em>-column from list view</li>
<li>Tweak the output of the boolean field <em>instock</em></li>
<li>Apply a <strong>default sorting</strong> of the rows in the list view</li>
</ul>
<p>This may sound as a lot of work, but fact is it&#8217;s quite easily implemented.</p>
<p>First a note on the two price-columns: I live in Norway, and am sometimes interested in monitoring prices in some US webshops. Therefore, I register the USD price in the <em>price</em>-field in the database, while I calculate what this will cost me in NOK (Norwegian kroner) based on the current exchange rate. Since most of you probably are not from Norway, I called NOK the foreign currency.</p>
<p>First, place a floating point number (for instance 4.99 &#8211; the actual rate on 2008-Apr-15, the lowest rate in 25 years!) as the only line in a file placed here (though customized for your rails-path!):<br />
<em>/usr/local/www/rails/as/myincludes/nok_usd_rate.txt</em></p>
<p>We want a global variable (<em>yeah, I know everyone&#8217;s not found of that</em>) to hold the exchange rate, read from a file in the event of page loading. I do this so that I won&#8217;t have to read the file over for each record.</p>
<p>Edit the <em>app/controllers/application.rb</em>-file, so that it looks like this:</p>
<pre class="brush: ruby; title: ;">
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController &lt; ActionController::Base
  def setmyglobalvar
    # reads exchange rate from file: UPDATE TO YOUR PATH!
    contents = File.read('/usr/local/www/rails/as/myincludes/nok_usd_rate.txt')
    # converts to NOK and includes 25% &quot;mva&quot; (=Norwegian VAT). Stores in global var:
    $myglobalvar= contents.to_f * 1.25
  end

  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key =&gt; '_testapp_session_id'

  before_filter :setmyglobalvar
end
</pre>
<p>Here, we have defined a method, and calls this by the <em>before_filter</em>-statement.</p>
<p>Next, we must extend our record-model so that it includes the field to be used as a virtual column. Edit <em>app/models/equipment.rb</em> to look like this:</p>
<pre class="brush: ruby; title: ;">
class Equipment &lt; ActiveRecord::Base
  def price_nok
    # $myglobalvar is set in controllers/application_controller,
    # and contains exchange rate incl VAT:
    # self.price references the price-
    # field from current database record.
    self.price * $myglobalvar
  end
end
</pre>
<p>Then we must tell the controller to include this new field as a (virtual) column.<br />
At the same time, we reorder the columns and apply a default sorting for the list view.<br />
Note that we only alter the columns of the <em>list</em> action and not of any other actions (<em>list</em> is an action, so is <em>new</em>, <em>edit</em>, <em>show</em> etc). Altering the columns of <em>edit</em> or <em>new</em> can result in an error on record edit or creation attempts.<br />
Note also that only the columns listed in <em>config.list.columns</em> will be shown in the list view.<br />
Here it goes &#8211; <em>app/controllers/equipment_controller.rb</em>:</p>
<pre class="brush: ruby; title: ;">
class EquipmentController &lt; ApplicationController
  @equipment_pages, @equipment = paginate :equipment, :per_page =&gt; 10
  layout &quot;equipment&quot;

  active_scaffold :equipment do |config|
    list.sorting = {:price =&gt; 'DESC'}
    config.list.columns = [:imgurl, :instock, :price, :price_nok, :title, :updated]
  end
end
</pre>
<p>Then, at last, we alter the way some of the columns are shown. This is done in <em>app/helpers/equipment_helper.rb</em>, by creating methods with name <em>columnname_column</em>. All output within the method will be printed in the respective table cell (td) for each record of that column. Here is the contents of that file:</p>
<pre class="brush: ruby; title: ;">
module EquipmentHelper
  def imgurl_column(record)
    '&lt;a href=&quot;'+record.url+'&quot;&gt;' + image_tag(record.imgurl, :alt =&gt; &quot;Image&quot;) + '&lt;/a&gt;'
  end
  def url_column(record)
    '&lt;b&gt;&lt;a href=&quot;'+record.url+'&quot;&gt;[ link ]&lt;/a&gt;&lt;/b&gt;'
  end
  def instock_column(record)
    if record.instock
      image_tag(&quot;/img/yes.png&quot;, :alt =&gt; &quot;yes!&quot;)
    else
      image_tag(&quot;/img/no.png&quot;, :alt =&gt; &quot;no, sadly!&quot;)
    end
  end
  def price_column(record)
    # http://railsmanual.org/module/ActionView::Helpers::NumberHelper
    number_to_currency(record.price)
  end
  def price_nok_column(record)
    number_to_currency(record.price_nok, :unit =&gt; &quot;NOK &quot;, :delimiter =&gt; &quot; &quot;, :separator =&gt; &quot;,&quot;)
  end
  def descr_column(record)
    # for the show action, where we want to show the description as well.
    record.descr.gsub(&quot;\n&quot;, &quot;&lt;br /&gt;&quot;)
  end
end
</pre>
<h5>Custom stylesheet</h5>
<p>If you want to apply your own css-formatting, don&#8217;t edit the default stylesheets, because they may be overwritten. Instead, include this <strong>as the very last line</strong> in the <em>head</em>-section of <em>app/views/layouts/equipment.rhtml</em>:</p>
<pre class="brush: ruby; title: ;">
  &lt;%= stylesheet_link_tag 'active_scaffold_overrides' %&gt;
</pre>
<p>Then, add your css rules in the stylesheet <em>public/stylesheets/active_scaffold_overrides.css</em>! For instance:</p>
<pre class="brush: css; title: ;">
.price_nok-column
{
        font-weight: bold;
}
</pre>
<hr />
<p><a name="links"><br />
<h3>Links</h3>
<p></a></p>
<ul>
<li><a href="http://betterexplained.com/articles/intermediate-rails-understanding-models-views-and-controllers/">MVC-concept @ betterexplained.com</a></li>
</ul>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2008/04/17/ruby-on-rails-experimenting-with-activescaffold/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The last days of my Logitech MX3200 wireless keyboard/mouse?</title>
		<link>http://blog.akilles.org/2008/04/07/the-last-days-of-my-logitech-mx3200-wireless-keyboardmouse/</link>
		<comments>http://blog.akilles.org/2008/04/07/the-last-days-of-my-logitech-mx3200-wireless-keyboardmouse/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 18:16:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[keyboards]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/2008/04/07/the-last-days-of-my-logitech-mx3200-wireless-keyboardmouse/</guid>
		<description><![CDATA[I found this very thorough review regarding the MX5500, with some comparisons to the MX3200: http://aphnetworks.com/reviews/logitech_mx5500_revolution I&#8217;ve had my MX3200 for a year and five months now, and it has been alright, but the last few months I&#8217;ve experienced times of frustration: Sometimes when I write a character (which requires the shift-button??), the character is [...]]]></description>
			<content:encoded><![CDATA[<p>I found this very thorough review regarding the MX5500, with some comparisons to the MX3200:</p>
<p><a href="http://aphnetworks.com/reviews/logitech_mx5500_revolution">http://aphnetworks.com/reviews/logitech_mx5500_revolution</a></p>
<p>I&#8217;ve had my MX3200 for a year and five months now, and it has been alright, but the last few months I&#8217;ve experienced times of frustration:<br />
Sometimes when I write a character (which requires the shift-button??), the character is being repeated until I hit another key, even though I released the first key. The problem is not related to the key itself, so I guess it&#8217;s a problem regarding weak wireless reception or something. When the problem first occurs, it can happen over and over again for hours, while other times there can be days/weeks when there&#8217;s no problem at all. This makes me suspect that maybe the signal/noise ratio is too low; maybe the signal reception is too weak on this model and that the problem occurs when the noise from cellulars etc is having its peaks?</p>
<p>What made me suspect the reception quality in the first place, was when I first plugged the receiver in the back of my computer, curious to try out my new keyboard. The reception was less than low: Not all keystrokes were recorded, and I had to use the equipped USB extension cable to place the receiver nearer my keyboard. Considering that the back of my computer is no more than 1,5 m away from the keyboard &#8212; though visually hidden by the cabinet itself &#8212; I think <em>that&#8217;s</em> poor reception.</p>
<p>Anyways, I haven&#8217;t had this problem with any other (Logitech) wireless keyboards I&#8217;ve had, so I hope and think it&#8217;s just this model. Therefore, I found the review linked to above interesting, especially since they mention good reception on the MX5500.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2008/04/07/the-last-days-of-my-logitech-mx3200-wireless-keyboardmouse/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Escaping backslash character in C# .NET MySQL-queries</title>
		<link>http://blog.akilles.org/2008/03/12/escaping-backslash-character-in-c-net-mysql-queries/</link>
		<comments>http://blog.akilles.org/2008/03/12/escaping-backslash-character-in-c-net-mysql-queries/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 00:20:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[escapecharacters]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://blog.akilles.org/2008/03/12/escaping-backslash-character-in-c-net-mysql-queries/</guid>
		<description><![CDATA[Using escape-sequences like \t or \n is one thing, but escaping the escapecharacter (often &#8216;\&#8217;) can sometimes be a pain&#8230; This is especially true when the string you&#8217;re escaping is about to be processed by several succeeding processes, like: 1) a compiler, 2) a regex-engine, 3) a database, &#8230; , etc. Anyways, I&#8217;ve experimented some [...]]]></description>
			<content:encoded><![CDATA[<p>Using escape-sequences like \t or \n is one thing, but escaping the escapecharacter (often &#8216;\&#8217;) can sometimes be a pain&#8230; This is especially true when the string you&#8217;re escaping is about to be processed by several succeeding processes, like: 1) a compiler, 2) a regex-engine, 3) a database, &#8230; , etc.</p>
<p>Anyways, I&#8217;ve experimented some with MySql-queries from within C# .NET, using Windows paths (containing backslashes as path separators) in the WHERE-clauses. We have a query of one of the forms:</p>
<p><strong>case 1: = operator</strong><br />
querystring1 =<br />
  &quot;SELECT a,b,path FROM table &quot; +<br />
  &quot;WHERE path = &#8216;&quot; + patharg1 + &quot;&#8217;;&quot;;</p>
<p><em>or</em></p>
<p><strong>case 2: LIKE operator</strong><br />
querystring2 =<br />
  &quot;SELECT a,b,path FROM table &quot; +<br />
  &quot;WHERE path LIKE &#8216;&quot; + patharg2 + &quot;&#8217;;&quot;;</p>
<p>Here is what I&#8217;ve found out:</p>
<p><strong>case 1: = operator</strong><br />
Use <strong>4</strong> backslashes for each backslash in the saved record you&#8217;re matching against. You could do:<br />
patharg1 =<br />
  patharg1.Replace(&quot;\\&quot;, &quot;\\\\&quot;);<br />
(The 2 backslashes in the first replace-argument is for escaping the backslash within the compiler.)</p>
<p><strong>case 1: LIKE operator</strong><br />
Use <strong>8</strong>(!) backslashes for each backslash in the saved record you&#8217;re matching against. You could do:<br />
patharg2 =<br />
  patharg2.Replace(&quot;\\&quot;, &quot;\\\\\\\\&quot;);<br />
(The 2 backslashes in the first replace-argument is for escaping the backslash within the compiler.)</p>
<p>The two cases could then look like this:</p>
<p><strong>case 1:</strong><br />
querystring1 =<br />
  &quot;SELECT a,b,path FROM table &quot; +<br />
  &quot;WHERE path = &#8216;c:\\\\some\\\\path.txt&#8217;;&quot;;</p>
<p><strong>case 2:</strong><br />
querystring2 =<br />
  &quot;SELECT a,b,path FROM table &quot; +<br />
  &quot;WHERE path LIKE &#8216;c:\\\\\\\\some\\\\\\\\path.txt&#8217;;&quot;;</p>
<p>The above is if you put the querystring into, for instance, a MySqlCommand&#8217;s CommandText.</p>
<p>However, if you use datasets and run something like<br />
dataTable.Select(filterExpression)<br />
where dataTable is a DataTable instance and filterExpression is a string, you must <strong>not</strong> escape the backslash more than for a usual string (you&#8217;ll just write &#8220;\\&#8221; or @&#8221;\&#8221;, because some kind of escape of the backslash is <em>always</em> necessary for the compiler).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.akilles.org/2008/03/12/escaping-backslash-character-in-c-net-mysql-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

