<?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>Random Wisdom &#187; Software</title>
	<atom:link href="http://scrolls.mafgani.net/category/software/feed/" rel="self" type="application/rss+xml" />
	<link>http://scrolls.mafgani.net</link>
	<description>An attempt at organizing my thoughts ...</description>
	<lastBuildDate>Sun, 13 Mar 2011 22:54:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Create links with absolute paths in Linux</title>
		<link>http://scrolls.mafgani.net/2010/01/create-links-with-absolute-paths-in-linux/</link>
		<comments>http://scrolls.mafgani.net/2010/01/create-links-with-absolute-paths-in-linux/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 19:10:18 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[How To ...]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[file processing]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=420</guid>
		<description><![CDATA[The default behaviour of the linking command (ln) is a little strange under certain circumstances. Since it creates the links using the literal value of the target, symbolic links created using relative path structures can often fail. Consider the following: $ ln -s targetfile ../src/targetfile_link Without a doubt, &#8216;targetfile_link&#8217; will be a broken symlink since [...]]]></description>
			<content:encoded><![CDATA[<p>The default behaviour of the linking command (<strong>ln</strong>) is a little strange under certain circumstances. Since it creates the links using the literal value of the target, symbolic links created using relative path structures can often fail. Consider the following:</p>
<pre>$ ln -s targetfile ../src/targetfile_link</pre>
<p>Without a doubt, &#8216;targetfile_link&#8217; will be a broken symlink since it links to a target that it assumes is in the same directory:</p>
<pre>$ cd ../src &amp;&amp; ls -l targetfile_link
lrwxrwxrwx 1 mafgani mafgani 5 2010-01-16 18:19 targetfile_link -&gt; targetfile</pre>
<p>This is quite unfortunate since it clearly clashes with the way that the linking mechanism should work intuitively.</p>
<p>The solution is to force <strong>ln</strong> into automatically appending the absolute path to the target files. This can be achieved by using a simple shell script that acts as a wrapper for the real linking command:</p>
<pre style="color: #99ccff">
#!/bin/sh

# Step through the supplied arguments and append the absolute
# path to targets that exist
for ARG in $@
do
  if [ -e $ARG ]; then
    LNARGS="${LNARGS} ${PWD}/${ARG}";
  else
    LNARGS="${LNARGS} ${ARG}";
  fi
done

# Execute the actual link command with the modified args
exec /bin/ln ${LNARGS};
</pre>
<p>There are two known caveats:</p>
<ul>
<li> The link is &#8216;sub-optimal&#8217; if created from within the destination directory (the absolute path contains &#8216;../&#8217;s). It will still work however.</li>
<li>  The links will always be absolute. If that is undesirable, save the script as &#8216;absln&#8217; or something other than &#8216;ln&#8217;.</li>
</ul>
<p>Using &#8216;absln&#8217; instead of &#8216;ln&#8217; in the previously described scenario now produces a working symlink:</p>
<pre>$ absln -s targetfile ../src/targetfile_link
$ cd ../src/ &#038;&#038; ls -l targetfile_link
lrwxrwxrwx 1 mafgani mafgani 16 2010-01-16 19:13 targetfile_link -> /tmp/files/targetfile</pre>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2010/01/create-links-with-absolute-paths-in-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Graphics format conversion</title>
		<link>http://scrolls.mafgani.net/2009/12/graphics-format-conversion/</link>
		<comments>http://scrolls.mafgani.net/2009/12/graphics-format-conversion/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 01:28:02 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[eps]]></category>
		<category><![CDATA[file processing]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[sam2p]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=408</guid>
		<description><![CDATA[Up until now I have been using the &#8216;convert&#8216; tool that comes with ImageMagick to switch between image formats &#8212; mainly for creating EPS files from JPG/PNG (raster format) files for use with LaTeX. Then I came across sam2p. It is a light-weight utility that does one thing only and it does it well: convert [...]]]></description>
			<content:encoded><![CDATA[<p>Up until now I have been using the &#8216;<strong>convert</strong>&#8216; tool that comes with <a href="http://www.imagemagick.org">ImageMagick</a> to switch between image formats &#8212; mainly for creating EPS files from JPG/PNG (raster format) files for use with LaTeX. Then I came across <a href="http://code.google.com/p/sam2p/">sam2p</a>. </p>
<p>It is a light-weight utility that does one thing only and it does it well: convert between image formats. I&#8217;ve been using it for a while now and find that it can greatly reduce files sizes with minimal drop in quality. I&#8217;ve even used it to process existing EPS files just to get the reduction in file size. Best of all, it is multi-platform &#8212; executables are available for both Windows and Linux on the <a href="http://code.google.com/p/sam2p/">project homepage</a>.</p>
<p>Goodbye <strong>convert</strong> and hello <strong>sam2p</strong>!</p>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2009/12/graphics-format-conversion/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Just Host cPanel cleanup script for Greasemonkey</title>
		<link>http://scrolls.mafgani.net/2009/10/just-host-cpanel-cleanup-script-for-greasemonkey/</link>
		<comments>http://scrolls.mafgani.net/2009/10/just-host-cpanel-cleanup-script-for-greasemonkey/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 22:48:47 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[How To ...]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[adblock]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[extensions]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[userscripts]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=356</guid>
		<description><![CDATA[I finally decided to get my own domain and signed up with Just Host for the registration and hosting. For now I&#8217;m only using it to host this blog that originally started its life on Blogger. The transition was fairly smooth, save for a few minor issues. I&#8217;ll talk more about the steps involved a [...]]]></description>
			<content:encoded><![CDATA[<p>I finally decided to get my own <a href="http://mafgani.net/">domain</a> and signed up with <a href="http://www.justhost.com">Just Host</a> for the registration and hosting. For now I&#8217;m only using it to host this blog that originally started its life on <a href="http://darkknight9.blogspot.com">Blogger</a>. The transition was fairly smooth, save for a few minor issues. I&#8217;ll talk more about the steps involved a future post (a draft is already in the queue) &#8230;</p>
<p>Just Host offers <a href="http://www.cpanel.net/">cPanel</a> as a web frontend for managing and running site related tasks. It&#8217;s quite a nice tool but there is one big problem. The interface is literally littered with a bunch of annoying ads and affiliate links. Even more annoying is the fact that there doesn&#8217;t seem to be any way of permanently moving these offending boxes to the bottom of the screen. This is where <a href="http://www.greasespot.net/">Greasemonkey</a> comes in.</p>
<p>Greasemonkey is a nice little extension for Firefox that allows the execution user scripts to change the way a website looks. <a href="http://userscripts.org/">userscripts.org</a> is a great place for finding scripts that work on major/popular sites on the internet. A search there didn&#8217;t turn up anything useful so I decided to write my own. Install Greasemonkey if you don&#8217;t have it already and then click on <a href="http://mafgani.net/files/justhost_cpanel_cleanup.user.js">this link</a> to get the script installed. I&#8217;ve also put up a <a href="http://userscripts.org/scripts/show/60459">copy</a> on userscripts.org.</p>
<p>The script works by setting the &#8216;display&#8217; style of the offending div boxes to &#8216;none&#8217;. <a href="http://getfirebug.com/">Firebug</a> is another great tool that makes it a breeze to find out the IDs of the divs that need to be blacklisted.</p>
<p><strong>[Update 10-Nov-2009]:</strong> Looks like some sneaky new ads injected using Javascript have shown up on the cPanel sidebar. Unlike the old ad boxes however, these lack div IDs. As a result, it is not possible to simply blacklist them. Fortunately, it also means that it is possible to turn the table around by simply blocking the sidebar divs that have a null ID. The <a href="http://mafgani.net/files/justhost_cpanel_cleanup.user.js">script</a> has been updated.</p>
<p><strong>Before:</strong></p>
<div id="attachment_372" class="wp-caption aligncenter" style="width: 510px"><img class="size-full wp-image-372  " title="Before" src="http://scrolls.mafgani.net/wp-content/uploads/2009/10/before.png" alt="Before applying greasemonkey script" width="500" height="388" /><p class="wp-caption-text">Before applying greasemonkey script</p></div>
<p><strong>After:</strong></p>
<div id="attachment_374" class="wp-caption aligncenter" style="width: 510px"><img class="size-full wp-image-374  " title="After" src="http://scrolls.mafgani.net/wp-content/uploads/2009/10/after.png" alt="After applying greasemonkey script" width="500" height="389" /><p class="wp-caption-text">After applying greasemonkey script</p></div>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2009/10/just-host-cpanel-cleanup-script-for-greasemonkey/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Printing multi-page duplex documents</title>
		<link>http://scrolls.mafgani.net/2009/10/printing-multi-page-duplex-documents/</link>
		<comments>http://scrolls.mafgani.net/2009/10/printing-multi-page-duplex-documents/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 13:04:41 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[How To ...]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[duplex]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[file processing]]></category>
		<category><![CDATA[printing]]></category>
		<category><![CDATA[ps]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=102</guid>
		<description><![CDATA[The psnup tool can be used to place multiple pages on each sheet of a document. E.g., the following command places two pages from the input file into each sheet of the output: $ psnup -l -2 input.ps output.ps While psnup is excellent for quick &#8220;N-up&#8221; conversion jobs, it doesn&#8217;t provide much control over the [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>psnup</strong> tool can be used to place multiple pages on each sheet of a document. E.g., the following command places two pages from the input file into each sheet of the output: </p>
<pre>$ psnup -l -2 input.ps output.ps</pre>
<p>While <strong>psnup</strong> is excellent for quick &#8220;N-up&#8221; conversion jobs, it doesn&#8217;t provide much control over the layout. The <strong>pstops</strong> utility on the other hand allows for fine grained scale, rotation and placement settings for each page that goes into a sheet of the output. The command syntax is a bit more complicated on account of the page specification strings that must now be provided. The following example shows a typical command needed to prepare a document for duplex printing with two pages on each side of a sheet:</p>
<pre>$ pstops -pa4 \
  '4:0L@0.8(21cm,-1cm)+1L@0.8(21cm,12.55cm),2R@0.8(0,29.85cm)+3R@0.8(0,16.25cm)' \
  input.ps output.ps
</pre>
<p>The command is best understood by referring to the relevant section from the <em>manpage</em>:</p>
<pre>
       Pstops rearranges pages from a  PostScript  document,  creating  a  new
       PostScript  file.   The  input  PostScript file should follow the Adobe
       Document Structuring Conventions.  Pstops can  be  used  to  perform  a
       large  number  of  arbitrary  re-arrangements  of  Documents, including
       arranging for printing 2-up, 4-up, booklets, reversing, selecting front
       or back sides of documents, scaling, etc.

       pagespecs follow the syntax:

              pagespecs   = [modulo:]specs

              specs       = spec[+specs][,specs]

              spec        = [-]pageno[L][R][U][@scale][(xoff,yoff)]

       modulo is the number of pages in each block. The value of modulo should
       be greater than 0; the default value is 1.  specs are the page specifi-
       cations  for  the  pages in each block. The value of the pageno in each
       spec should be between 0 (for the first page in the block) and modulo-1
       (for  the  last page in each block) inclusive.  The optional dimensions
       xoff and yoff shift the page by the specified amount.   xoff  and  yoff
       are  in  PostScript’s points, but may be followed by the units cm or in
       to convert to centimetres or inches, or the flag w or h to specify as a
       multiple  of  the width or height.  The optional parameters L, R, and U
       rotate the page left, right, or upside-down.  The optional scale param-
       eter  scales the page by the fraction specified.  If the optional minus
       sign is specified, the page is relative to the  end  of  the  document,
       instead of the start.

       If  page  specs  are  separated  by + the pages will be merged into one
       page; if they are separated by  they will be  on  separate  pages.   If
       there  is only one page specification, with pageno zero, the pageno may
       be omitted.

       The shift, rotation, and scaling are performed in that order regardless
       of which order they appear on the command line.
</pre>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2009/10/printing-multi-page-duplex-documents/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restricting access to SFTP / SCP</title>
		<link>http://scrolls.mafgani.net/2009/10/restricting-access-to-sftp-scp/</link>
		<comments>http://scrolls.mafgani.net/2009/10/restricting-access-to-sftp-scp/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 13:04:40 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[How To ...]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[restrict access]]></category>
		<category><![CDATA[rssh]]></category>
		<category><![CDATA[scp]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[sftp]]></category>
		<category><![CDATA[ssh]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=107</guid>
		<description><![CDATA[rssh is a tool that allows SFTP/SCP for file transfers over SSH but denies shell access &#8212; useful for preventing users from running commands on the system. More details are available on the tool&#8217;s homepage. I first came across it on this page.]]></description>
			<content:encoded><![CDATA[<p><strong>rssh</strong> is a tool that allows SFTP/SCP for file transfers over SSH but denies shell access &#8212; useful for preventing users from running commands on the system. More details are available on the tool&#8217;s <a href="http://www.pizzashack.org/rssh/">homepage</a>.</p>
<p>I first came across it on <a href="http://www.cyberciti.biz/tips/rhel-centos-linux-install-configure-rssh-shell.html">this</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2009/10/restricting-access-to-sftp-scp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Realtime collaborative text editing</title>
		<link>http://scrolls.mafgani.net/2008/11/realtime-collaborative-text-editing/</link>
		<comments>http://scrolls.mafgani.net/2008/11/realtime-collaborative-text-editing/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 18:42:00 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[collaborative]]></category>
		<category><![CDATA[etherpad]]></category>
		<category><![CDATA[gobby]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=104</guid>
		<description><![CDATA[A while ago, I came across Etherpad. It a web based platform that allows multiple users to simultaneously edit a single text file. Since it doesn&#8217;t seem to support any kind of mark-up at the moment, it would seem that it&#8217;s not terribly useful for word processing tasks. Perhaps it&#8217;s good for real-time collaborative coding [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I came across <a href="http://etherpad.com/">Etherpad</a>. It a web based platform that allows multiple users to simultaneously edit a single text file. Since it doesn&#8217;t seem to support any kind of mark-up at the moment, it would seem  that it&#8217;s not terribly useful for word processing tasks. Perhaps it&#8217;s good for real-time collaborative coding and the creation of agenda type lists &#8230;</p>
<p>The software equivalent of Etherpad is <a href="http://gobby.0x539.de/trac/">Gobby</a>. It&#8217;s a multi-platform tool that claims to run on Microsoft Windows, Mac OS X, Linux and other Unix-like platforms &#8212; making it almost as flexible as a web-based service. There are a number of other advantages:</p>
<ul>
<li>Flexibility and security that comes from having absolute control over the sessions.</li>
<li>Syntax highlighting!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2008/11/realtime-collaborative-text-editing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bash process substitution</title>
		<link>http://scrolls.mafgani.net/2008/10/bash-process-substitution/</link>
		<comments>http://scrolls.mafgani.net/2008/10/bash-process-substitution/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 13:09:00 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[processes]]></category>
		<category><![CDATA[redirections]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=101</guid>
		<description><![CDATA[From the Advanced Bash-Scripting Guide: &#8220;Piping the stdout of a command into the stdin of another is a powerful technique. But, what if you need to pipe the stdout of multiple commands? This is where process substitution comes in. Process substitution feeds the output of a process (or processes) into the stdin of another process.&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>From the <a href="http://www.tldp.org/LDP/abs/html/process-sub.html">Advanced Bash-Scripting Guide</a>:</p>
<blockquote><p>
&#8220;Piping the stdout  of a command into the stdin of another is a powerful technique. But, what if you need to pipe the stdout of multiple  commands? This is where process substitution comes in.</p>
<p>Process substitution feeds the output of a process (or processes) into the stdin of another process.&#8221;
</p></blockquote>
<p>The syntax is:</p>
<pre>
 >(cmd_list)
 <(cmd_list)
</pre>
<p><span style="font-weight:bold;">Example:</span> comparing the head of two files using diff</p>
<pre>
$ diff -u <(head -n3 /var/log/dmesg) <(head -n3 /tmp/dmesg)
--- /proc/self/fd/63 2009-05-26 19:52:45.144544140 +0100
+++ /proc/self/fd/62 2009-05-26 19:52:45.149544007 +0100
@@ -1,3 +1,3 @@
-Initializing cgroup subsys cpuset
-Initializing cgroup subsys cpu
-Linux version 2.6.27.21-170.2.56.fc10.i686 (mockbuild@xenbuilder2.fedora.redhat.com)
 (gcc version 4.3.2 20081105 (Red Hat 4.3.2-7) (GCC) )
 #1 SMP Mon Mar 23 23:37:54 EDT 2009
+Linux version 2.6.22.9-61.fc6 (brewbuilder@hs20-bc2-4.build.redhat.com)
 (gcc version 4.1.2 20070626 (Red Hat 4.1.2-13))
 #1 SMP Thu Sep 27 18:48:03 EDT 2007
+BIOS-provided physical RAM map:
+ BIOS-e820: 0000000000000000 - 000000000009f000 (usable)
</pre>
<p>The diff header clearly shows that file descriptors are used as the underlying mechanism.</p>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2008/10/bash-process-substitution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedding fonts in a PDF document</title>
		<link>http://scrolls.mafgani.net/2008/10/embedding-fonts-in-a-pdf-document/</link>
		<comments>http://scrolls.mafgani.net/2008/10/embedding-fonts-in-a-pdf-document/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 13:08:00 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[How To ...]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[embedding]]></category>
		<category><![CDATA[file processing]]></category>
		<category><![CDATA[fonts]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[ps]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=100</guid>
		<description><![CDATA[It is often a good idea (or a requirement) to embed the used font faces in a PDF document. This is easily accomplished using ps2pdf during the final stage of conversion of a document from PS to PDF: $ ps2pdf -sPAPERSIZE=a4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.3 \ -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true \ 'input_file.ps' 'output_file.pdf' An explanation of the command [...]]]></description>
			<content:encoded><![CDATA[<p>It is often a good idea (or a requirement) to embed the used font faces in a PDF document. This is easily accomplished using <span style="font-weight:bold;">ps2pdf</span> during the final stage of conversion of a document from PS to PDF:</p>
<pre>
$ ps2pdf -sPAPERSIZE=a4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.3 \
         -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true \
         'input_file.ps' 'output_file.pdf'
</pre>
<p>An explanation of the command options can be found in the <span style="font-weight:bold;">Ps2pdf.htm</span> file in the Ghostscript documentations (or <a href="http://pages.cs.wisc.edu/~ghost/doc/cvs/Ps2pdf.htm">here</a>).</p>
<p>[<a href="http://www.hamilton.ie/gavinmc/docs/timesinpdfs.html">Source</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2008/10/embedding-fonts-in-a-pdf-document/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Re-encoding MP3 files using LAME</title>
		<link>http://scrolls.mafgani.net/2008/06/re-encoding-mp3-files-using-lame/</link>
		<comments>http://scrolls.mafgani.net/2008/06/re-encoding-mp3-files-using-lame/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 14:41:00 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[How To ...]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[lame]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[transcoding]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=99</guid>
		<description><![CDATA[I have some MP3 files encoded at a constant bitrate of 320kbps that my phone seems to have trouble playing smoothly. So, I looked into LAME. The files I had were named using the following scheme: 01 - Title of track 01.mp3 02 - Title of track 02.mp3 ... I used the BASH for-loop construct [...]]]></description>
			<content:encoded><![CDATA[<p>I have some MP3 files encoded at a constant bitrate of 320kbps that my phone seems to have trouble playing smoothly. So, I looked into <a href="http://en.wikipedia.org/wiki/LAME">LAME</a>.</p>
<p>The files I had were named using the following scheme:</p>
<pre>
01 - Title of track 01.mp3
02 - Title of track 02.mp3
...
</pre>
<p>I used the BASH <span style="font-family: courier new;">for-loop</span> construct to process the files:</p>
<pre>
$ for A in *.mp3;\              # Process one mp3 at a time
  do B=${A%.mp3};\              # Extract track number and title
     C=${B#?? -};\              # Extract the title
     D=${B%% - *};\             # Extract the track number
     lame --vbr-new -V0 -q0\    # Variable-bitrate, high-quality
          --mp3input\           # Inputs are MP3 files
          --tt "$C"\            # ID3v2 tags: title
          --ta 'Artist Name'\   # ID3v2 tags: artist
          --tl 'Album Title'\   # ID3v2 tags: album
          --ty 2007\            # ID3v2 tags: year
          --tn "$D"\            # ID3v2 tags: track no.
          --tg 'GENRE'\         # ID3v2 tags: genre
          "$A" processed/"$A";\ # Keep filename and save in ./processed/
  done
</pre>
<p>Since no bit-rate bounds are explicitly provided, the re-encoded files can contain anything between 32kbps and 320kbps. The LAME man-page provides an extensive list of options and their meanings.</p>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2008/06/re-encoding-mp3-files-using-lame/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing files using &#8216;find&#8217;</title>
		<link>http://scrolls.mafgani.net/2008/03/processing-files-using-find/</link>
		<comments>http://scrolls.mafgani.net/2008/03/processing-files-using-find/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 15:32:00 +0000</pubDate>
		<dc:creator>Mostafa</dc:creator>
				<category><![CDATA[How To ...]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[file processing]]></category>
		<category><![CDATA[find]]></category>

		<guid isPermaLink="false">http://scrolls.mafgani.net/?p=98</guid>
		<description><![CDATA[In its most basic form, find is often used to locate files that are subsequently piped through a complex set of commands for processing. However, this particular method is easily broken by files that contain spaces in their names. This is where the &#8216;exec&#8217; option provided by find comes in handy. From the man-page: -exec [...]]]></description>
			<content:encoded><![CDATA[<p>In its most basic form, <span style="font-weight:bold;">find</span> is often used to locate files that are subsequently piped through a complex set of commands for processing. However, this particular method is easily broken by files that contain spaces in their names.</p>
<p>This is where the <span style="font-style:italic;">&#8216;exec&#8217;</span> option provided by <span style="font-weight:bold;">find</span> comes in handy. From the man-page:</p>
<pre>
-exec command ;
       Execute  command;  true  if 0 status is returned.  All following
       arguments to find are taken to be arguments to the command until
       an  argument  consisting of ‘;’ is encountered.  The string ‘{}’
       is replaced by the current file name being processed  everywhere
       it occurs in the arguments to the command, not just in arguments
       where it is alone, as in some versions of find.  Both  of  these
       constructions might need to be escaped (with a ‘\’) or quoted to
       protect them from expansion by the shell.  See the EXAMPLES sec-
       tion  for examples of the use of the ‘-exec’ option.  The speci-
       fied command is run once for each matched file.  The command  is
       executed  in  the  starting  directory.    There are unavoidable
       security problems surrounding  use  of  the  -exec  option;  you
       should use the -execdir option instead.
</pre>
<p>An example that recursively touches all *.log files from the current directory would be:</p>
<pre>
$ find . -name \*.log -exec touch {} \;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://scrolls.mafgani.net/2008/03/processing-files-using-find/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

