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

<channel>
	<title>actionshrimp.com</title>
	<atom:link href="http://www.actionshrimp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.actionshrimp.com</link>
	<description>fun and geekery</description>
	<pubDate>Wed, 13 Aug 2008 23:02:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Logitech QuickCam E2500 on Ubuntu Skype</title>
		<link>http://www.actionshrimp.com/2008/08/logitech-quickcam-e2500-on-ubuntu-skype/</link>
		<comments>http://www.actionshrimp.com/2008/08/logitech-quickcam-e2500-on-ubuntu-skype/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 23:12:57 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.actionshrimp.com/?p=8</guid>
		<description><![CDATA[I recently discovered the wonders of skype, and tried to get my new webcam working with it under linux, and of course this proved to be quite tricky. After much fiddling I eventually got it to work, hopefully these steps will work for you too.

The gspca drivers are available from here, I was using a [...]]]></description>
			<content:encoded><![CDATA[<p>I recently discovered the wonders of skype, and tried to get my new webcam working with it under linux, and of course this proved to be quite tricky. After much fiddling I eventually got it to work, hopefully these steps will work for you too.</p>
<p><span id="more-8"></span></p>
<p>The gspca drivers are available from <a href="http://mxhaard.free.fr/download.html">here</a>, I was using a specific version dated 20071224 to work with a patch file I found - many thanks to <a href="http://forums.quickcamteam.net/showthread.php?tid=310">redeye on the QuickCam team forums</a>. If you use a different version of the drivers, you can just examine the patch file and insert the changes manually.</p>
<p>First, download the drivers and the patch</p>
<pre>wget http://mxhaard.free.fr/spca50x/Download/gspcav1-20071224.tar.gz
wget http://forums.quickcamteam.net/attachment.php?aid=86 -O patch.tar.gz
</pre>
<p>Then extract and apply the patch:</p>
<pre>tar -xvf gspcav1-20071224.tar.gz
tar -xvf patch.tar.gz
cd gspcav1-20071224
patch -p1 &lt; ../quickcamE2500.diff
</pre>
<p>There&#8217;s a handy build script included with the drivers so just run that (requires root):</p>
<pre>sudo ./gspca_build
</pre>
<p>This generates the file</p>
<pre>gspca.ko</pre>
<p>which we use to replace the old gspca module.<br />
Check to see if the old module is loaded, you should see something like:</p>
<pre>dave@baracus:~$ lsmod | grep gspca
gspca                 680656  0
videodev               29440  1 gspca
usbcore               146028  9 gspca,snd_usb_audio,snd_usb_lib,usb_storage,usbhid,libusual,ehci_hcd,ohci_hcd
</pre>
<p>We want to find out where it is, so do the following:</p>
<pre>sudo rmmod gspca
sudo modprobe -v gspca
</pre>
<p>You should see something like:</p>
<pre>insmod /lib/modules/2.6.24-20-generic/ubuntu/media/gspcav1/gspca.ko
</pre>
<p>That is the location of the file we&#8217;re looking for, so, replacing where appropriate with what was output for you above, type:</p>
<pre>sudo rmmod gspca
sudo rm /lib/modules/2.6.24-20-generic/ubuntu/media/gspcav1/gspca.ko
sudo mv gspca.ko /lib/modules/2.6.24-20-generic/ubuntu/media/gspcav1/
sudo modprobe gspca
</pre>
<p>This should have loaded the new module in place of the old one. See if you have a video device:</p>
<pre>dave@baracus:~$ ls /dev/video*
/dev/video0
</pre>
<p>You can try and run Skype now, and in fact, if you&#8217;re not using the camera for Skype, this may well be enough. But for the Skype users: see if you get any picture by testing in the video devices option menu (be warned, it can take a little while to show up there after skype loads, and a little while for the picture to show when you press the test button, so be patient). If anything show&#8217;s up at all that&#8217;s a plus.</p>
<p>Originally, I had a black image, so I assumed the camera wasn&#8217;t working, but I soon realised that the image was there, just very dark - shining a light on it showed this was the case. I tried fiddling around with gstfakevideo for a while to try and alter the output, but there was a much simpler solution. The gspca driver itself can take options, and an autoexposure setting was ruining my lighting. To fix this, edit the file /etc/modprobe.d/options, and add a line at the bottom:</p>
<pre>
options gspca gamma=1 autoexpo=0
</pre>
<p>The gamma=1 may not be necessary, but if it still appears too dark or too light for your taste you can change this parameter as you like. Finally, reload the module:</p>
<pre>
sudo rmmod gspca
sudo modprobe gspca
</pre>
<p>and try out skype again. Hopefully it works!</p>
<p>I ran into quite a lot of other problems while I was trying this out, so if you come across any errors, drop a comment below and I&#8217;ll try and get back to you asap.</p>
<p><strong>UPDATE</strong>: I found a large problem when using the camera in Skype was that CPU usage would shoot up to 100%, causing things to freeze up and conversations to crash after a while. I had played around with <a href="http://code.google.com/p/gstfakevideo">gstfakevideo</a> a bit when trying to get the camera to work originally, and it seems using this when the camera already &#8216;works&#8217; means it uses up far less CPU. I haven&#8217;t had a chance to test it for a long period yet but it seems like it should do the trick. Here&#8217;s what I did:</p>
<p>First, download gstfakevideo using subversion (you may need to install the subversion package, sudo apt-get subversion probably does the trick, and then the command below will make a directory called gstfakevideo in your current location, so make sure it&#8217;s somewhere nice), then compile and install it:</p>
<pre>
svn checkout http://gstfakevideo.googlecode.com/svn/trunk/ gstfakevideo
cd gstfakevideo
make
sudo make install
</pre>
<p>gstfakevideo creates a new video stream using your webcam, which is formatted differently and skype seems to get along with it more. The only problem is, it outputs its stream to /dev/video0 which is where our webcam currently lives. So we have to move the webcam, but this is easy enough:</p>
<pre>
sudo mv /dev/video0 /dev/video1
</pre>
<p>(Actually, gstfakevideo seems to work for me with lower CPU without moving this - but try it moved first anyway). Watch out though, every time you reboot, your webcam will probably go to /dev/video0 by default, assuming you have no other video devices, so you will have to move stuff about to make a space in video0 each time. Now we see if it works:</p>
<pre>
gstfakevideo v4lsrc device=/dev/video1 ! ffmpegcolorspace
</pre>
<p>What this does is runs gstfakevideo, telling it that the source we&#8217;re using is a v4l source, and its from /dev/video1. The ffmpegcolorspace argument seems to be for making the stream YUV instead of RGB for some cameras so may not be necessary. It then launches skype, with hopefully the output below:</p>
<pre>
dave@baracus:~$ gstfakevideo v4lsrc device=/dev/video1 ! ffmpegcolorspace
gst.c create_pipeline (155): pipeline created
gst.c create_pipeline (159): pipeline linked
</pre>
<p>If you look in the skype video options now there will be no camera listed. You have to wait a while (it can take 30s or so), until you get some output, ending with something like:</p>
<pre>
gst.c shim_ioctl (201): request=803c7601 nr 1
gst.c shim_ioctl (208): VIDIOCGCAP
gst.c shim_ioctl (313): result=0 error=0 Success
</pre>
<p>Now a camera should show up in the video menu in skype, with a name like GStreamer fake video (/dev/video0). Try it out, and compare your CPU performance to before. Also try exiting skype, and moving your video source from /dev/video1 back to video0, and running gstfakevideo again, only with device=/dev/video0, and see if it works (and let me know your findings below!).</p>
<p>Finally if gstfakevideo works, we can clean it up so the command isn&#8217;t so long to type. The script should be stored in:</p>
<pre>
/usr/local/bin/gstfakevideo
</pre>
<p>(Can check this using):</p>
<pre>
dave@baracus:~$ whereis gstfakevideo
gstfakevideo: /usr/local/bin/gstfakevideo
</pre>
<p>So we edit this file (requires root):</p>
<pre>
sudo gedit /usr/local/bin/gstfakevideo
</pre>
<p>Now, find the line that looks like this:</p>
<pre>
export GST_PIPE="videotestsrc is-live=true ! video/x-raw-yuv,width=640,height=480,framerate=10/1 ! videoscale ! ffmpegcolorspace ! vertigotv ! ffmpegcolorspace"
</pre>
<p>and change it to (remember where you put your webcam source - if you moved it back to /dev/video0, change the device parameter accordingly):</p>
<pre>
export GST_PIPE="v4lsrc device=/dev/video1 ! ffmpegcolorspace"
</pre>
<p>and finally look a bit further down, and delete the line:</p>
<pre>
export GST_PIPE="$*"
</pre>
<p>Now Skype will launch with your faked video stream, just from the command gstfakevideo. Good luck! Let me know how you get on.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionshrimp.com/2008/08/logitech-quickcam-e2500-on-ubuntu-skype/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jsvi and TiddlyWiki</title>
		<link>http://www.actionshrimp.com/2008/05/jsvi-and-tiddlywiki/</link>
		<comments>http://www.actionshrimp.com/2008/05/jsvi-and-tiddlywiki/#comments</comments>
		<pubDate>Tue, 13 May 2008 14:26:28 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[TiddlyWiki]]></category>

		<guid isPermaLink="false">http://www.actionshrimp.com/?p=6</guid>
		<description><![CDATA[When adding posts to my TiddlyWiki, I oft found myself craving vi, rather than a simple textarea. There were a few options that involved using a plugin for Firefox such as mozEx, and using an external program to edit textareas. However, I found a nice &#8216;integrated&#8217; option instead.

jsvi is an excellent javascript implementation of vi. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">When adding posts to my TiddlyWiki, I oft found myself craving <a title="vi" href="http://en.wikipedia.org/wiki/Vi" target="_blank">vi</a>, rather than a simple textarea. There were a few options that involved using a plugin for Firefox such as mozEx, and using an external program to edit textareas. However, I found a nice &#8216;integrated&#8217; option instead.</p>
<p style="text-align: left;"><span id="more-6"></span></p>
<p style="text-align: left;"><a title="jsvi" href="http://gpl.internetconnection.net/vi/" target="_blank">jsvi</a> is an excellent javascript implementation of vi. I decided to try and integrate it into my TiddlyWiki, and the steps I took are shown below. To try out the final result, use the edit mode on my <a title="PhysiWiki" href="http://www.actionshrimp.com/physiwiki/" target="_blank">wiki</a>.</p>
<p style="text-align: center;"><a href="http://www.actionshrimp.com/wordpress/wp-content/uploads/2008/05/jsvi.png"><img class="size-medium wp-image-7" title="jsvi" src="http://www.actionshrimp.com/wordpress/wp-content/uploads/2008/05/jsvi-300x225.png" alt="jsvi in action on my wiki" width="300" height="225" /></a></p>
<p style="text-align: left;"><em><strong>Be warned:</strong></em> <em>this is a bit of a dirty hack, and requires a few files external to the TiddlyWiki file, which makes TiddlyWiki a bit less portable. At some point it&#8217;d be nice if this was build as a TiddlyWiki plugin instead, but at the minute I&#8217;m not experienced enough with writing plugins for TW. There is also a slight bug which means you can&#8217;t scroll up while editing. </em></p>
<p style="text-align: left;">First of all, I installed the <a title="iFrameEditorPlugin" href="http://visualtw.ouvaton.org/old/VisualTW.old.html#iFrameEditorPlugin" target="_blank">iFrameEditorPlugin</a> from an old version of the <a title="VisualTW" href="http://visualtw.ouvaton.org/VisualTW.html" target="_blank">VisualTW</a> site. I don&#8217;t think VisualTW uses the plugin anymore, and has instead changed it&#8217;s wysiwig editors to using plugins rather than iFrames - a far superior solution, but one I didn&#8217;t have the time or ability for. The plugin alone is not quite enough though, and a few changes to it are required.</p>
<p style="text-align: left;">iFrameEditorPlugin loads an iFrame containing your editor, passes the editor the text from the body of the tiddler, you edit it, and then when you save the page, the plugin gets your changes and saves them to the tiddler. However, it expects you to use a custom field rather than the default text field, which is a slight problem in our case. The function getContent() is what actually performs this:</p>
<pre style="text-align: left;">getContent=function(tiddler, field) {
    var t,f;
    t=store.getTiddler(tiddler);
    f = t ? t.fields[field] : "";
    f = f ? f : "";
    return f;
}</pre>
<p style="text-align: left;">As you can see, it reads the field of the tiddler with t.fields[field]. To read the default text field instead, I added a new function to the plugin:</p>
<pre style="text-align: left;">getContentText=function(tiddler) {
 var t,f;
 t=store.getTiddler(tiddler);
 f = t ? t.text : "";
 f = f ? f : "";
 return f;
}</pre>
<p style="text-align: left;">Great. So that&#8217;s set up. There&#8217;s also another problem with the plugin - it was originally intended for use with wysiwig html style editors, but I enjoy editing my wiki content raw. Also, the content has to be passed in a URL to the editor, so strange characters in the URL will mess it up, so there were problem with escaping html entities and things like that. To get around this, I found a handy javascript function that converted html entities back to their original form, and added this to the top of the plugin (thanks to The JavaScript Source):</p>
<pre style="text-align: left;">/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Ultimater | http://webdeveloper.com/forum/member.php?u=30185 */
function html_entity_decode(str) {
  var ta=document.createElement("textarea");
  ta.innerHTML=str.replace(/&lt;/g,"&lt;").replace(/&gt;/g,"&gt;");
  return ta.value;
}</pre>
<p style="text-align: left;">Ok, now we actually have to use this function, so we edit the plugin a bit more. Look for the line that reads the data back from the iFrame:</p>
<pre style="text-align: left;">if(f) fields[f] = e.contentWindow.getContent();</pre>
<p style="text-align: left;">and change it to:</p>
<pre style="text-align: left;">if(f) fields[f] = html_entity_decode(e.contentWindow.getContent());</pre>
<p style="text-align: left;">The plugin is all ready to go now, so we have to make the actual external editor that&#8217;s gonna go in the iFrame, using jsvi. Download these three files, and put them in the same folder as your TiddlyWiki html file.</p>
<blockquote style="text-align: left;"><p><a href="http://gpl.internetconnection.net/vi/vi.js" target="_blank">vi.js</a><br />
<a title="jsvi css file" href="http://gpl.internetconnection.net/vi/vi.css" target="_blank">vi.css</a><br />
<a title="editor" href="http://www.actionshrimp.com/physiwiki/editor.html" target="_blank">editor.html</a></p></blockquote>
<p style="text-align: left;">The first two are the actual jsvi javascript file and it&#8217;s style sheet, the second is my own editor iFrame. Let&#8217;s have a look at the important lines of the <em>editor.html</em> file:</p>
<pre style="text-align: left;">&lt;script type="text/javascript" src="vi.js"&gt;&lt;/script&gt;</pre>
<p style="text-align: left;">This includes the jsvi javascript file.</p>
<pre style="text-align: left;">&lt;textarea style="width: 99%" name="theEditor" onfocus="editor(this);"&gt;
&lt;/textarea&gt;</pre>
<p style="text-align: left;">This builds the actual textarea that&#8217;s gonna be edited by jsvi. Ok, now the javascript &#8220;meat&#8221; of the page:</p>
<pre style="text-align: left;">var oEditor = document.getElementsByName('theEditor')[0];
function getContent() {return oEditor.value;}
tiddlers=/[\\?&amp;]tiddler=([^&amp;#]*)/.exec(unescape(window.location.href));
fields=/[\\?&amp;]field=([^&amp;#]*)/.exec(unescape(window.location.href));
if (tiddlers&amp;&amp;fields) oEditor.value = parent.getContentText(tiddlers[1]);
oEditor.focus();</pre>
<p style="text-align: left;">All that happens here is we write the getContent() function that the iFrameEditorPlugin calls to read your changes. The tiddlers line reads the URL to get which tiddler you&#8217;re editing, and the fields line does the same for the field (actually this isn&#8217;t even necessary with our getContentText() function). The last two lines read the tiddler&#8217;s content, so we can edit it, and set the focus to the textarea to launch jsvi automatically when the iFrame loads.</p>
<p style="text-align: left;">That&#8217;s everything setup now, so all we need to do is tell Tiddlywiki when we want to make our edits with the iFrameEditor instead of with it&#8217;s default text field. I made a plugin (based on code from VisualTW&#8217;s EasyEditPlugin - thanks a lot!). <a title="jsviPlugin" href="http://www.actionshrimp.com/physiwiki/#jsviPlugin">You can view the plugin here</a>. Hopefully it should add a &#8216;vi&#8217; button next to the edit button on each tiddler. If no button appears, add &#8216;jsvi&#8217; to the first line of the ViewTemplate tiddler to look like this:</p>
<pre>&lt;div class='toolbar' macro='toolbar closeTiddler closeOthers +editTiddler jsvi &gt; fields syncing ....</pre>
<p style="text-align: left;">To make jsvi the default, remove the + from in front of editTiddler and put it in front of jsvi.</p>
<p style="text-align: left;">Now when you press the vi button, you should be presented with a rather gorgeous vi interface! <em><strong>One note, when you&#8217;re done editing a tiddler with jsvi, you must save it using the usual vi write command, :w, or press the &#8220;Save and Close&#8221; button. Otherwise the textarea does not get updated, and the iFrameEditorPlugin cannot read your changes. Also beware editing config shadow tiddlers with jsvi, as the line &#8220;macro=stuff&#8221; in some of the tooldbars etc. is interpreted by jsvi as it&#8217;s own command and it can end up destroying certain things.<br />
</strong></em></p>
<p style="text-align: left;">Update: I found a small problem with focusing using this in Firefox (didn&#8217;t test in other platforms) - after editing a post I was unable to select other fields and items in the window. This was fixed by changing one line in the vi.js file, line <strong>3588</strong>, which needs to be uncommented (the comment line before even refers to a bug in Firefox, possibly in an older version?) to look like this:</p>
<pre>document.body.removeChild(backing);</pre>
<p style="text-align: left;">Now it should work perfectly, apart from a few kinks: being able to edit the tiddler title the first time jsvi launches. Save and close vi, and it&#8217;s editable again, and still editable when you relaunch jsvi by clicking on the text area. If you cant get focus back on jsvi, right click it.</p>
<p style="text-align: left;">Hope you enjoy this as much as I do, and hopefully at some point soon when I have a bit more free time, I&#8217;ll have it in plugin format so it&#8217;s all incorporated into TW. Any problems, leave a comment and I&#8217;ll try and get back to you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionshrimp.com/2008/05/jsvi-and-tiddlywiki/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Integrating LatexRender into TiddlyWiki</title>
		<link>http://www.actionshrimp.com/2008/05/integrating-latexrender-into-tiddlywiki/</link>
		<comments>http://www.actionshrimp.com/2008/05/integrating-latexrender-into-tiddlywiki/#comments</comments>
		<pubDate>Tue, 13 May 2008 12:17:49 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[TiddlyWiki]]></category>

		<guid isPermaLink="false">http://www.actionshrimp.com/?p=5</guid>
		<description><![CDATA[This post is adapted from my LatexRenderPluginDoc page on my wiki, so might contain a couple of errors on the copy over. If something doesn&#8217;t seem right, refer to that page, and please tell me in a comment below.
This uses LatexRender, my simple TiddlyWiki macro, LatexRenderPlugin, and a custom script I created for the purpose, [...]]]></description>
			<content:encoded><![CDATA[<p>This post is adapted from my <a title="LatexRenderPluginDoc" href="http://www.actionshrimp.com/physiwiki/index.html#LatexRenderPluginDoc" target="_blank">LatexRenderPluginDoc</a> page on my wiki, so might contain a couple of errors on the copy over. If something doesn&#8217;t seem right, refer to that page, and please tell me in a comment below.</p>
<p>This uses <a class="externalLink" title="External link to http://www.mayer.dial.pipex.com/tex.htm" href="http://www.mayer.dial.pipex.com/tex.htm" target="_blank">LatexRender</a>, my simple TiddlyWiki macro, <a href="http://www.actionshrimp.com/physiwiki#LatexRenderPlugin"><span class="tiddlyLink tiddlyLinkExisting">LatexRenderPlugin</span></a>, and a custom script I created for the purpose, render.php, which renders LaTeX fed to it as an argument. You&#8217;ll need imagemagick enabled on your server.</p>
<p><span id="more-5"></span></p>
<p>First you need access to a server with the ability to run LatexRender. Download the <a class="externalLink" title="External link to http://www.mayer.dial.pipex.com/latexrender.zip" href="http://www.mayer.dial.pipex.com/latexrender.zip" target="_blank">latexrender.zip</a>, and extract the &#8220;otherPHP&#8221; directory. Copy the class.latexrender.php, and latex.php files to a folder on your webserver. Set up the directories in each file accordingly. For example, I have my wiki set up like so:</p>
<blockquote><p>webroot/physiwiki/latexrender:<br />
<em>class.latexrender.php</em><br />
<em>latex.php</em></p></blockquote>
<p>and two subdirectories (which the webserver needs write access to, chmod 777):</p>
<blockquote><p>webroot/physiwiki/latexrender/pictures<br />
webroot/physiwiki/latexrender/tmp</p></blockquote>
<p>So in <em>class.latexrender.php</em>, I have:</p>
<pre>var $_picture_path = "/absolue/path/to/physiwiki/latexrender/pictures";
var $_picture_path_httpd = "/physiwiki/latexrender/pictures";
var $_tmp_dir = "/absolute/path/to/physiwiki/latexrender/tmp";</pre>
<p>Also, make sure the paths to <strong>latex</strong>, <strong>dvips</strong>, <strong>convert</strong>, <strong>identify</strong> are setup correctly on the lines below. You can also make changes to the other settings in this file if you want including image format. The default is <strong>gif</strong>, I changed it to <strong>png</strong>.</p>
<p>Now <em>latex.php</em> by default generates the html to show an image, like:</p>
<pre>&lt;img src="blah"&gt;</pre>
<p>We dont want this. So some changes to <em>latex.php</em> are required. First adjust the paths in <em>latex.php</em>:</p>
<pre>$latexrender_path = "/absolute/path/to/physiwiki/latexrender";
$latexrender_path_http = ".";</pre>
<p>The &#8216;.&#8217; is used as <em>latex.php</em> resides in the same directory as class.latexrender.php.<br />
Next, scroll right to the bottom of the file, and you can comment out/delete the last few lines, and change the return value to $url instead of $text as below:</p>
<pre>    $url = $latex-&gt;getFormulaURL($latex_formula);

    /*
    $alt_latex_formula = htmlentities($latex_formula, ENT_QUOTES);
    $alt_latex_formula = ...
    $alt_latex_formula = ..

        if ($url != false) {
            $text = substr_replace($text, "&lt;img src='".$url."' title='".$alt_latex_formula."' alt='".$alt_latex_formula."' align=absmiddle&gt;",$pos,strlen($tex_matches[0][$i]));
        } else {
            $text = substr_replace($text, "[Unparseable or potentially dangerous latex formula. Error $latex-&gt;_errorcode $latex-&gt;_errorextra]",$pos,strlen($tex_matches[0][$i]));
        }
    */
    }
    return $url;
}</pre>
<p>Right, that&#8217;s LatexRender all setup. Now we need to make the <em>render.php</em> file. Put the code in a file and save it in the same directory as <em>class.latexrender.php</em> and <em>latex.php</em>.<br />
<em>render.php</em>:</p>
<pre>&lt;?
header("Content-type: image/png");
include_once('latex.php');

if (isset($_GET['l'])){

        $text = $_GET['l'];
        $text = stripslashes($text);
        $text = "[tex]" . $text . "[/tex]";

        $latex_img_file = latex_content($text);
        $handle = fopen($latex_img_file, "r");
        $contents = fread($handle, filesize($latex_img_file));
        fclose($handle);

        echo $contents;
}
?&gt;</pre>
<p>Obviously change the header function to match the content type you specified in <em>class.render.php</em>. This file accepts LaTeX formula code as an argument render.php?l=&lt;formula&gt;, puts it between [tex] tags so it can be messed around by <em>latex.php</em> and then renders it as the image file.</p>
<p>Now all that is left is to incorporate this into TiddlyWiki, using a simple macro. (Just change the src= section to match the location of your script):</p>
<pre>config.macros.tex = {};
config.macros.tex.handler = function (place,macroName,params,wikifier,paramString,tiddler) {

     var code = encodeURIComponent(params[0]);
     wikify("&lt;html&gt;&lt;img class=\"teximg\" title=\"" + params[0] + "\" src=\"latexrender/render.php?l=" + code + "\"&gt;&lt;/html&gt;", place);

}</pre>
<p>To use this plugin just call it like so:</p>
<pre>&lt;&lt;tex '\int_{-5}^{5} x^2 dx'&gt;&gt;</pre>
<p>For some rendered examples just browse my <a title="PhysiWiki" href="http://www.actionshrimp.com/physiwiki/" target="_blank">wiki</a>!<br />
The macro also gives all equations the &#8220;teximg&#8221; css class, so they can be adjusted to be inline &#8220;nicely&#8221;, using the following CSS in the <span class="tiddlyLink tiddlyLinkExisting">StyleSheet</span> tiddler:</p>
<pre>.viewer {line-height: 2.0 ;} .viewer img.teximg { vertical-align: middle;}</pre>
<p>Hopefully you&#8217;ll now have easy LaTeX macro&#8217;s working on your TiddlyWiki! Any problems just leave me a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionshrimp.com/2008/05/integrating-latexrender-into-tiddlywiki/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Laptop hard drive clicking in Hardy</title>
		<link>http://www.actionshrimp.com/2008/05/laptop-hard-drive-clicking-in-hardy/</link>
		<comments>http://www.actionshrimp.com/2008/05/laptop-hard-drive-clicking-in-hardy/#comments</comments>
		<pubDate>Sat, 03 May 2008 14:09:37 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.actionshrimp.com/wordpress/?p=4</guid>
		<description><![CDATA[Since I installed Hardy a week or so ago, I noticed the hard drive in my laptop was making a strange clicking noise every 5 seconds or so. At first I thought it must be slowly dying, and I was starting to get a bit worried, but then realised it seemed a bit suspicious that [...]]]></description>
			<content:encoded><![CDATA[<p>Since I installed Hardy a week or so ago, I noticed the hard drive in my laptop was making a strange clicking noise every 5 seconds or so. At first I thought it must be slowly dying, and I was starting to get a bit worried, but then realised it seemed a bit suspicious that it coincided with Hardy so closely, so I searched around.</p>
<p><span id="more-4"></span></p>
<p>Turns out I wasn&#8217;t the only one with the problem, and I found a solution <a href="http://ubuntuforums.org/showthread.php?t=531866">here</a>. (Thanks to wieman01 on the Ubuntu forums for this.)</p>
<p>What was happening was Ubuntu&#8217;s power management was a bit over zealous and was making the hard drive spin up and down far too often. By changing the power settings this can be fixed, using the command:</p>
<blockquote><p><code>hdparm -B 254 /dev/xxx</code></p></blockquote>
<p>replacing xxx with your drive name, in my case for my SATA drive it was /dev/sda.</p>
<p><code>254</code> here is the lowest level of power management, and <code>255</code> is off completely. You can try playing with higher values if you like some kind of power management.</p>
<p>To make this run every time the computer starts, add it to a startup script. For example, save a plain text file containing the above line to:</p>
<blockquote><p><code>/etc/init.d/local_settings</code></p></blockquote>
<p>Then:</p>
<blockquote><p><code><br />
cd /etc/init.d<br />
sudo chmod +x local_settings<br />
sudo ln -s local_settings /etc/rc2.d/S99local_settings<br />
</code></p></blockquote>
<p>This makes the file executable, and creates a symbolic link to it in the folder which contains the start-up scripts, giving it priority 99.</p>
<p>Hopefully your clicking noise will now be gone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionshrimp.com/2008/05/laptop-hard-drive-clicking-in-hardy/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Wordpress</title>
		<link>http://www.actionshrimp.com/2008/05/wordpress/</link>
		<comments>http://www.actionshrimp.com/2008/05/wordpress/#comments</comments>
		<pubDate>Thu, 01 May 2008 21:30:54 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
		
		<category><![CDATA[Misc.]]></category>

		<guid isPermaLink="false">http://www.actionshrimp.com/wordpress/?p=3</guid>
		<description><![CDATA[So, I installed WordPress. I guess I&#8217;m just procrastinating from exam revision, but maybe I will actually manage to update this thing occasionally.
]]></description>
			<content:encoded><![CDATA[<p>So, I installed WordPress. I guess I&#8217;m just procrastinating from exam revision, but maybe I will actually manage to update this thing occasionally.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionshrimp.com/2008/05/wordpress/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
