<?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>bojan.blog &#187; Tips &amp; Tricks</title>
	<atom:link href="http://bojand.org/blog/category/tips-tricks/feed" rel="self" type="application/rss+xml" />
	<link>http://bojand.org/blog</link>
	<description></description>
	<lastBuildDate>Sun, 11 Apr 2010 04:03:46 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Create a symmetric matrix in Mathematica</title>
		<link>http://bojand.org/blog/112.html</link>
		<comments>http://bojand.org/blog/112.html#comments</comments>
		<pubDate>Wed, 18 Nov 2009 19:03:20 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Scientific Computing]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[mathematica]]></category>

		<guid isPermaLink="false">http://bojan.info/blog/?p=112</guid>
		<description><![CDATA[Here is a quick way to create a symmetric matrix in Mathematica. The code below creates a generic 6&#215;6 matrix (line 1), then mirrors the above-diagonal elements to their below-diagonal counterparts (substitution in lines 3-5).

am = Array[Subscript[a,##] &#38;, {6,6}];
am = am /.
  Flatten[Table[
    Subscript[a,i,j] -&#62; Subscript[a,j,i],
    {i,2,6}, {j,1,i-1}]]

]]></description>
			<content:encoded><![CDATA[<p>Here is a quick way to create a symmetric matrix in Mathematica. The code below creates a generic 6&#215;6 matrix (line 1), then mirrors the above-diagonal elements to their below-diagonal counterparts (substitution in lines 3-5).</p>
<pre class="brush: mathematica;">
am = Array[Subscript[a,##] &amp;, {6,6}];
am = am /.
  Flatten[Table[
    Subscript[a,i,j] -&gt; Subscript[a,j,i],
    {i,2,6}, {j,1,i-1}]]
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/112.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ezproxy redirect bookmarklet</title>
		<link>http://bojand.org/blog/81.html</link>
		<comments>http://bojand.org/blog/81.html#comments</comments>
		<pubDate>Tue, 10 Nov 2009 15:17:02 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Papers]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[bookmarklet]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://bojan.info/blog/?p=81</guid>
		<description><![CDATA[A while ago I wrote a Google Toolbar button for redirecting the current page to the same page accessed through an EZproxy server. As I was missing this functionality in browsers without Google Toolbar (it&#8217;s still not available in Google Chrome), I realized that it&#8217;s a very simple thing to do with a bookmarklet. Here [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I wrote a <a href="http://bojand.org/tools/ezproxy/">Google Toolbar button for redirecting the current page to the same page accessed through an EZproxy server</a>. As I was missing this functionality in browsers without Google Toolbar (it&#8217;s still not available in Google Chrome), I realized that it&#8217;s a very simple thing to do with a <a href="http://en.wikipedia.org/wiki/Bookmarklet">bookmarklet</a>. Here is the code:</p>
<pre class="brush: jscript; gutter: false;">
javascript:window.location=location.protocol+'//'+location.hostname+'.ezproxy1.library.arizona.edu'+location.pathname+location.search+location.hash;
</pre>
<p><span id="more-81"></span></p>
<p>To make it work, copy the above code, and paste it as the URL in a bookmark. In all modern browsers, alternatively, you can just drag this link to the bookmarks bar:</p>
<ul>
<li><strong><a href="javascript:window.location=location.protocol+'//'+location.hostname+'.ezproxy1.library.arizona.edu'+location.pathname+location.search+location.hash;" rel="nofollow">ez</a></strong></li>
</ul>
<p>In either case, make sure you edit the javascript code and replace <kbd>ezproxy1.library.arizona.edu</kbd> by your EZproxy server.</p>
<p>Once &quot;ez&quot; is in your bookmarks, clicking on the bookmark will have the same effect as clicking the <a href="http://bojand.org/tools/ezproxy/">ezproxy Google Toolbar button</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/81.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XML parsing with Perl using XPath</title>
		<link>http://bojand.org/blog/68.html</link>
		<comments>http://bojand.org/blog/68.html#comments</comments>
		<pubDate>Mon, 21 Aug 2006 22:01:43 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Data Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xpath]]></category>

		<guid isPermaLink="false">http://bojan.info/blog/?p=68</guid>
		<description><![CDATA[
use strict;
use XML::LibXML;

# data source
my $xml_filename = &#34;xml/data.xml&#34;;

my $parser = XML::LibXML-&#62;new;
my $doc = $parser-&#62;parse_file($xml_filename);

my $xpath = &#34;//word/entry[\@src=\&#34;pr\&#34;]/..&#34;;
my @words = $doc-&#62;findnodes($xpath);

foreach my $word (@words) {
	print $word-&#62;findvalue(&#34;\@id&#34;);
	print &#34;\n&#34;;
}

]]></description>
			<content:encoded><![CDATA[<pre class="brush: perl;">
use strict;
use XML::LibXML;

# data source
my $xml_filename = &quot;xml/data.xml&quot;;

my $parser = XML::LibXML-&gt;new;
my $doc = $parser-&gt;parse_file($xml_filename);

my $xpath = &quot;//word/entry[\@src=\&quot;pr\&quot;]/..&quot;;
my @words = $doc-&gt;findnodes($xpath);

foreach my $word (@words) {
	print $word-&gt;findvalue(&quot;\@id&quot;);
	print &quot;\n&quot;;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/68.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>File modified timestamp with Perl</title>
		<link>http://bojand.org/blog/63.html</link>
		<comments>http://bojand.org/blog/63.html#comments</comments>
		<pubDate>Mon, 21 Aug 2006 21:43:29 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://bojan.info/blog/63.html</guid>
		<description><![CDATA[This is how to quickly get the timestamp of when the file was last modified in Perl:

$lastmod = (stat($filename))[9];

]]></description>
			<content:encoded><![CDATA[<p>This is how to quickly get the timestamp of when the file was last modified in Perl:</p>
<pre class="brush: perl; gutter: false;">
$lastmod = (stat($filename))[9];
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/63.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XSLT transform with Perl</title>
		<link>http://bojand.org/blog/53.html</link>
		<comments>http://bojand.org/blog/53.html#comments</comments>
		<pubDate>Mon, 21 Aug 2006 21:27:11 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Data Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://bojan.info/blog/?p=53</guid>
		<description><![CDATA[Here is a Perl snippet that transforms an XML file with XSLT:

use strict;
use XML::XSLT::Wrapper;

my $xml_input_filename = &#34;xml/data.xml&#34;;
my $xml_output_filename = &#34;xml/out.xml&#34;;
my $xsl_filename = &#34;xml/transform.xslt&#34;;

my $xslt = XML::XSLT::Wrapper-&#62;new(
		ProcessorList =&#62; [
			'libxslt',
			'sablotron',
			'xslt'
		],
	);
my $result = $xslt-&#62;transform(
		OutFile =&#62; $xml_output_filename,
		xml =&#62; $xml_input_filename,
		xsl =&#62; $xsl_filename,
	);
$xslt-&#62;dispose();


Values given to [code]]czo2OlwieG1sID0+XCI7e1smKiZdfQ==[[/code] and [code]]czo2OlwieHNsID0+XCI7e1smKiZdfQ==[[/code] can be either file names, or xml/xslt code passed as a string.
If [code]]czo3OlwiT3V0RmlsZVwiO3tbJiomXX0=[[/code] [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a Perl snippet that transforms an XML file with XSLT:</p>
<pre class="brush: perl;">
use strict;
use XML::XSLT::Wrapper;

my $xml_input_filename = &quot;xml/data.xml&quot;;
my $xml_output_filename = &quot;xml/out.xml&quot;;
my $xsl_filename = &quot;xml/transform.xslt&quot;;

my $xslt = XML::XSLT::Wrapper-&gt;new(
		ProcessorList =&gt; [
			'libxslt',
			'sablotron',
			'xslt'
		],
	);
my $result = $xslt-&gt;transform(
		OutFile =&gt; $xml_output_filename,
		xml =&gt; $xml_input_filename,
		xsl =&gt; $xsl_filename,
	);
$xslt-&gt;dispose();
</pre>
<p><span id="more-53"></span></p>
<p>Values given to [code]]czo2OlwieG1sID0+XCI7e1smKiZdfQ==[[/code] and [code]]czo2OlwieHNsID0+XCI7e1smKiZdfQ==[[/code] can be either file names, or xml/xslt code passed as a string.</p>
<p>If [code]]czo3OlwiT3V0RmlsZVwiO3tbJiomXX0=[[/code] is ommited, then the result of the transformation is returned to the variable [code]]czo3OlwiJHJlc3VsdFwiO3tbJiomXX0=[[/code].</p>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/53.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sitemap generator configuration for Blogger</title>
		<link>http://bojand.org/blog/32.html</link>
		<comments>http://bojand.org/blog/32.html#comments</comments>
		<pubDate>Tue, 08 Aug 2006 20:28:00 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[blogger]]></category>
		<category><![CDATA[sitemap]]></category>

		<guid isPermaLink="false">http://blog.bojan.info/?p=32</guid>
		<description><![CDATA[If you are using Google&#8217;s sitemap generator [code]]czoxNDpcInNpdGVtYXBfZ2VuLnB5XCI7e1smKiZdfQ==[[/code] to generate a sitemap of your Blogger blog , here are the configuration lines to add to the config.xml file:


&#60;filter action=&#34;drop&#34; type=&#34;wildcard&#34;
    pattern=&#34;*.py&#34; /&#62;
&#60;filter action=&#34;drop&#34; type=&#34;wildcard&#34;
    pattern=&#34;*.txt&#34; /&#62;
&#60;filter action=&#34;drop&#34; type=&#34;regexp&#34;
    pattern=&#34;/google\w+\.html&#34; /&#62;
&#60;filter action=&#34;drop&#34; type=&#34;regexp&#34;
    pattern=&#34;/\d+/(\d+/)?$&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using <a href="http://sourceforge.net/projects/goog-sitemapgen">Google&#8217;s sitemap generator</a> [code]]czoxNDpcInNpdGVtYXBfZ2VuLnB5XCI7e1smKiZdfQ==[[/code] to generate a sitemap of your Blogger blog , here are the configuration lines to add to the config.xml file:</p>
<p><span id="more-32"></span></p>
<pre class="brush: xml;">
&lt;filter action=&quot;drop&quot; type=&quot;wildcard&quot;
    pattern=&quot;*.py&quot; /&gt;
&lt;filter action=&quot;drop&quot; type=&quot;wildcard&quot;
    pattern=&quot;*.txt&quot; /&gt;
&lt;filter action=&quot;drop&quot; type=&quot;regexp&quot;
    pattern=&quot;/google\w+\.html&quot; /&gt;
&lt;filter action=&quot;drop&quot; type=&quot;regexp&quot;
    pattern=&quot;/\d+/(\d+/)?$&quot; /&gt;

&lt;filter action=&quot;drop&quot; type=&quot;regexp&quot;
    pattern=&quot;/archive/$&quot; /&gt;
&lt;filter action=&quot;drop&quot; type=&quot;regexp&quot;
    pattern=&quot;/uploaded_files/$&quot; /&gt;
&lt;filter action=&quot;drop&quot; type=&quot;regexp&quot;
    pattern=&quot;/uploaded_images/$&quot; /&gt;
</pre>
<p>In this way, void URLs will not be included in the sitemap.xml output.</p>
<p>If you're wondering "Why would I be running the sitemap generator on my blog?", it's because Googlebot does not handle well the posts where the time &amp; date has been altered.</p>
<p>If you don't know what the sitemap generator is, see <a href="http://www.google.com/webmasters/sitemaps/docs/en/sitemap-generator.html">Google Sitemaps Help</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/32.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Function call counting in Matlab</title>
		<link>http://bojand.org/blog/29.html</link>
		<comments>http://bojand.org/blog/29.html#comments</comments>
		<pubDate>Thu, 23 Mar 2006 13:38:15 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[Scientific Computing]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[matlab]]></category>

		<guid isPermaLink="false">http://blog.bojan.info/?p=29</guid>
		<description><![CDATA[Here&#8217;s a neat way to keep track of the cost, i.e. number of function calls in Matlab: rather than using a counter variable and increment it each time a function is called, use the internal Matlab counters, accessible through the FunctionTable struct array. 
The loop below is necessary only to get the index of the [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a neat way to keep track of the cost, i.e. number of function calls in Matlab: rather than using a counter variable and increment it each time a function is called, use the internal Matlab counters, accessible through the <kbd>FunctionTable</kbd> struct array. </p>
<p>The loop below is necessary only to get the index of the desired function in the struct array (If you know a better way of looking up a function in <kbd>FunctionTable</kbd>, let me know!).</p>
<p>Replace the function name <kbd>ftest</kbd> if needed.</p>
<pre class="brush: matlab;">
profile on

% your code comes here
% (cost is counted from &quot;profile on&quot; to &quot;profile off&quot;)

p = profile('info');
for i = 1:size(p.FunctionTable,1)
    if strcmp(p.FunctionTable(i).FunctionName,'ftest')
        break
    end
end
cost = p.FunctionTable(i).NumCalls;
profile off
</pre>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/29.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Images in LaTeX</title>
		<link>http://bojand.org/blog/20.html</link>
		<comments>http://bojand.org/blog/20.html#comments</comments>
		<pubDate>Thu, 08 Dec 2005 19:16:49 +0000</pubDate>
		<dc:creator>Bojan</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://blog.bojan.info/?p=20</guid>
		<description><![CDATA[
Problem:
you can&#8217;t get those images to appear in a typeset document.
Cause:
[code]]czo4OlwicGRmbGF0ZXhcIjt7WyYqJl19[[/code] and [code]]czo1OlwibGF0ZXhcIjt7WyYqJl19[[/code] have virtually no graphic drivers in common. For instance, [code]]czo4OlwicGRmbGF0ZXhcIjt7WyYqJl19[[/code] can't handle eps files.
Solution:
I converted my eps files to pdf using a thing called [code]]czo4OlwiZXBzdG9wZGZcIjt7WyYqJl19[[/code], which is included in latex distributions, and [code]]czo4OlwicGRmbGF0ZXhcIjt7WyYqJl19[[/code] handled those pdf graphs perfectly, so that the output [...]]]></description>
			<content:encoded><![CDATA[<dl>
<dt>Problem:</dt>
<dd>you can&#8217;t get those images to appear in a typeset document.</dd>
<dt>Cause:</dt>
<dd>[code]]czo4OlwicGRmbGF0ZXhcIjt7WyYqJl19[[/code] and [code]]czo1OlwibGF0ZXhcIjt7WyYqJl19[[/code] have virtually no graphic drivers in common. For instance, [code]]czo4OlwicGRmbGF0ZXhcIjt7WyYqJl19[[/code] can't handle eps files.</dd>
<dt>Solution:</dt>
<dd>I converted my eps files to pdf using a thing called [code]]czo4OlwiZXBzdG9wZGZcIjt7WyYqJl19[[/code], which is included in latex distributions, and [code]]czo4OlwicGRmbGF0ZXhcIjt7WyYqJl19[[/code] handled those pdf graphs perfectly, so that the output was identical to that of eps with [code]]czo1OlwibGF0ZXhcIjt7WyYqJl19[[/code].</dd>
</dl>
]]></content:encoded>
			<wfw:commentRss>http://bojand.org/blog/20.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
