<?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>2of1</title>
	<atom:link href="http://blog.2of1.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.2of1.org</link>
	<description>half a nibble of another</description>
	<lastBuildDate>Wed, 09 May 2012 08:35:20 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sony Bravia Escapades #1: The teardown</title>
		<link>http://blog.2of1.org/2012/04/23/sony-bravia-escapades-1-the-teardown/</link>
		<comments>http://blog.2of1.org/2012/04/23/sony-bravia-escapades-1-the-teardown/#comments</comments>
		<pubDate>Sun, 22 Apr 2012 21:21:24 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Reverse engineering]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=649</guid>
		<description><![CDATA[I&#8217;ve decided to take a look at my Sony Bravia 32EX520 to see whether I can find anything interesting.
I haven&#8217;t done anything exciting yet; but here are a few snaps of the innards of the beast.

SoC:

RAM:

FLASH??:
I haven&#8217;t managed to identify this part. If you have any infos, please please please send them to me!!!

Common Interface [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to take a look at my Sony Bravia 32EX520 to see whether I can find anything interesting.</p>
<p>I haven&#8217;t done anything exciting yet; but here are a few snaps of the innards of the beast.</p>
<p><a href="http://www.2of1.org/bravia/board.jpg"><img src="http://www.2of1.org/bravia/board.jpg" alt="" /></a></p>
<p><strong>SoC:</strong><br />
<img src="http://www.2of1.org/bravia/SoC.jpg" alt="" /></p>
<p><strong>RAM:</strong><br />
<img src="http://www.2of1.org/bravia/ram.jpg" alt="" /></p>
<p><strong>FLASH??:</strong><br />
I haven&#8217;t managed to identify this part. If you have any infos, please please please send them to me!!!<br />
<img src="http://www.2of1.org/bravia/flash.jpg" alt="" /></p>
<p><strong>Common Interface slot + USB controller:</strong><br />
<img src="http://www.2of1.org/bravia/ci.jpg" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2012/04/23/sony-bravia-escapades-1-the-teardown/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cracking WiFi: Israeli Provider fail</title>
		<link>http://blog.2of1.org/2012/04/19/cracking-wifi-in-israel-1-provider-fail/</link>
		<comments>http://blog.2of1.org/2012/04/19/cracking-wifi-in-israel-1-provider-fail/#comments</comments>
		<pubDate>Thu, 19 Apr 2012 14:19:54 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Other stuffs]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=641</guid>
		<description><![CDATA[There&#8217;s something that has worried me greatly ever since my ISP came to install my router upgrade.
I won&#8217;t mention names, but it seems certain providers seem to favour setting the WPA-PSK passphrase to the phone number of the customer by default.
I have noticed that the ESSID is sometimes a form of the customer surname too.
This [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s something that has worried me greatly ever since my ISP came to install my router upgrade.</p>
<p>I won&#8217;t mention names, but it seems certain providers seem to favour setting the WPA-PSK passphrase to the phone number of the customer by default.<br />
I have noticed that the ESSID is sometimes a form of the customer surname too.</p>
<p>This is of course dismal security-wise.<br />
Firstly, if I can somehow get the target&#8217;s phone number (e.g. looking it up in the phonebook DUH), I can probably just guess the passphrase.</p>
<p>Secondly, even if I have no idea what the phone number is, by using this &#8216;convention&#8217; for passphrases, the providers have GREATLY reduced the keyspace &#8211; making brute force attacks not only possible but practical too.</p>
<p>Let&#8217;s take a look at HOT for example. Their phone number-space is 077-XXX-XXXX.<br />
That&#8217;s only 10,000,000 possible keys!</p>
<p>The following benchmarks from the <a href="http://code.google.com/p/pyrit/">Pyrit </a>project paint a pretty bleak picture:<br />
<img src="http://pyrit.googlecode.com/svn/tags/opt/pyritperfaa3.png"/></p>
<p>Now I haven&#8217;t benchmarked my home system yet, but lets conservatively say that my Radeon HD 5670 can pull a modest 5k PMKs/s I could cover the entire keyspace in 2000s. Statistically speaking, I&#8217;d likely hit the key in under 17 minutes!</p>
<p>Pretty practical I&#8217;d say.</p>
<p>So basically, providers; please stop doing stupid things like this!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2012/04/19/cracking-wifi-in-israel-1-provider-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Razer Naga open source Linux driver</title>
		<link>http://blog.2of1.org/2012/04/15/razer-naga-open-source-linux-driver/</link>
		<comments>http://blog.2of1.org/2012/04/15/razer-naga-open-source-linux-driver/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 15:56:27 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Drivers]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Linux kernel]]></category>
		<category><![CDATA[Open source]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=628</guid>
		<description><![CDATA[I&#8217;ve written a basic kernel driver for the Razer Naga gaming mouse (can be extended for other Razer HIDs).
Basically it allows for mapping of the 12 keys to any other (single) keys from userspace.
The module is a bit dirty (and probably buggy), please feel free to improve it!
You can pull it off the GitHub repo: [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve written a basic kernel driver for the Razer Naga gaming mouse (can be extended for other Razer HIDs).</p>
<p>Basically it allows for mapping of the 12 keys to any other (single) keys from userspace.</p>
<p>The module is a bit dirty (and probably buggy), please feel free to improve it!</p>
<p>You can pull it off the GitHub repo: <a href="http://github.com/2of1/razer-drivers">http://github.com/2of1/razer-drivers</a>.</p>
<p>Once you&#8217;ve compiled the module you can insert it into a running kernel with &#8217;sudo insmod hid-razer.ko&#8217;.</p>
<p>Before the kernel will load the module code when you plug in the device, you&#8217;ll need to compile a custom version of the hid module.<br />
You basically need to add an exception for the Naga device to hid-core.c to cause the module to load the driver instead of defaulting to the regular HID code.</p>
<p>I simply added (on line 1290 of Ubuntu&#8217;s 3.0.0 kernel sources):</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">static</span> <span style="color: #993333;">const</span> <span style="color: #993333;">struct</span> hid_device_id hid_have_special_driver<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#123;</span> HID_USB_DEVICE<span style="color: #009900;">&#40;</span><span style="color: #208080;">0x1532</span><span style="color: #339933;">,</span> <span style="color: #208080;">0x0015</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    .
    .
    .
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To change the key mappings from userspace, you can change the values of key1-key12 in the sysfs driver tree:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tree</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>bus<span style="color: #000000; font-weight: bold;">/</span>hid<span style="color: #000000; font-weight: bold;">/</span>drivers<span style="color: #000000; font-weight: bold;">/</span>razer<span style="color: #000000; font-weight: bold;">/</span>0003\:<span style="color: #000000;">1532</span>\:<span style="color: #000000;">0015.0004</span></pre></div></div>

<p>You need to use key values as they appear in the kernel input device header <<a href="http://lxr.free-electrons.com/source/include/linux/input.h#L172">linux/input.h</a>>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2012/04/15/razer-naga-open-source-linux-driver/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ARM long branch</title>
		<link>http://blog.2of1.org/2012/01/29/arm-long-branch/</link>
		<comments>http://blog.2of1.org/2012/01/29/arm-long-branch/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 09:33:05 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[ARM]]></category>
		<category><![CDATA[Assembly]]></category>
		<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=618</guid>
		<description><![CDATA[[From the ARM Architecture Reference Manual by David Seal]
A good way to branch to any location in the address space:

add lr, pc, #4
ldr pc, &#91;pc, #-4&#93;
dcd &#60;function_address&#62;

]]></description>
			<content:encoded><![CDATA[<p>[From the <em>ARM Architecture Reference Manual by David Seal</em>]</p>
<p>A good way to branch to any location in the address space:</p>

<div class="wp_syntax"><div class="code"><pre class="asm" style="font-family:monospace;"><span style="color: #00007f; font-weight: bold;">add</span> lr<span style="color: #339933;">,</span> pc<span style="color: #339933;">,</span> #<span style="color: #0000ff;">4</span>
ldr pc<span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">&#91;</span>pc<span style="color: #339933;">,</span> #<span style="color: #339933;">-</span><span style="color: #0000ff;">4</span><span style="color: #009900; font-weight: bold;">&#93;</span>
dcd &lt;function_address&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2012/01/29/arm-long-branch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mini-Namco #3: (Almost) Finished</title>
		<link>http://blog.2of1.org/2011/09/01/mini-namco-3-almost-finished/</link>
		<comments>http://blog.2of1.org/2011/09/01/mini-namco-3-almost-finished/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 17:57:20 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[Open source]]></category>
		<category><![CDATA[Other stuffs]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=612</guid>
		<description><![CDATA[And the (almost) finished machine running Namco Museum&#8217;s Ms. Pacman&#8230;

(Sorry for the grainy 3.2MP mobile-phone pic)
]]></description>
			<content:encoded><![CDATA[<p>And the (almost) finished machine running Namco Museum&#8217;s Ms. Pacman&#8230;</p>
<p><img src="http://www.2of1.org/dropbox/mini-namco-final.jpg"/></p>
<p>(Sorry for the grainy 3.2MP mobile-phone pic)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2011/09/01/mini-namco-3-almost-finished/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mini-Namco #2: Unit construction</title>
		<link>http://blog.2of1.org/2011/08/31/mini-namco-2-unit-construction/</link>
		<comments>http://blog.2of1.org/2011/08/31/mini-namco-2-unit-construction/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 21:11:34 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[Open source]]></category>
		<category><![CDATA[Other stuffs]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=602</guid>
		<description><![CDATA[Ok, so I constructed the unit over the past two evenings.
I stupidly didn&#8217;t take photos during the construction and seriously messed up the paint job.

But anyway this is what it currently looks like without the electronics:

You can see the scale of it (that thing on the right is the gas stove).
]]></description>
			<content:encoded><![CDATA[<p>Ok, so I constructed the unit over the past two evenings.<br />
I stupidly didn&#8217;t take photos during the construction and seriously messed up the paint job.<br />
<span id="more-602"></span><br />
But anyway this is what it currently looks like without the electronics:<br />
<img src="http://www.2of1.org/dropbox/mini-namco-box.jpg"/></p>
<p>You can see the scale of it (that thing on the right is the gas stove).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2011/08/31/mini-namco-2-unit-construction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mini-Namco #1: Design</title>
		<link>http://blog.2of1.org/2011/08/02/mini-namco-1-design/</link>
		<comments>http://blog.2of1.org/2011/08/02/mini-namco-1-design/#comments</comments>
		<pubDate>Tue, 02 Aug 2011 11:43:28 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[Open source]]></category>
		<category><![CDATA[Other stuffs]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=587</guid>
		<description><![CDATA[After being inactive for a long while on my fullsize Mame cabinet project (put on hold indefinitely until I get some perspex/stop being lazy), I was inspired by Victor Coleiro&#8217;s &#8220;Worlds Smallest Space Invaders&#8221; project to do something similar myself.

After contacting Victor for some pointers (he&#8217;s extremely helpful), I&#8217;ve started the design for my Namco [...]]]></description>
			<content:encoded><![CDATA[<p>After being inactive for a long while on my fullsize Mame cabinet project (put on hold indefinitely until I get some perspex/stop being lazy), I was inspired by Victor Coleiro&#8217;s &#8220;<a href="http://www.youtube.com/watch?v=BiO08w9Y558">Worlds Smallest Space Invaders</a>&#8221; project to do something similar myself.<br />
<span id="more-587"></span><br />
After contacting Victor for some pointers (he&#8217;s extremely helpful), I&#8217;ve started the design for my Namco arcade machine (basically a GBA SP running &#8216;Namco Museum&#8217; in a fancy housing).</p>
<p>It&#8217;s to be constructed out of 6mm MDF. I&#8217;ll need to send it in somewhere (probably a company the UK) for routing as I don&#8217;t have a CNC (does anyone know anywhere in Israel that can do this at a reasonable cost including the wood?).</p>
<p>I&#8217;ve already got the buttons, etc. and will post a few pics and specs in my next post.</p>
<p>Quite a few scrunched-up pieces of paper later, and here&#8217;s what I&#8217;ve got so far for the housing.</p>
<p><strong>All the pieces for the housing</strong><br />
<a href="http://www.2of1.org/dropbox/pieces.png"><img src="http://www.2of1.org/dropbox/pieces_small.png"></a><br />
<br/><br />
<strong>Control panel (joystick + controller buttons)</strong><br />
<a href="http://www.2of1.org/dropbox/controlpanel.png"><img src="http://www.2of1.org/dropbox/controlpanel_small.png"></a><br />
<br/><br />
<strong>&#8216;Coin door&#8217; panel (select and start buttons)</strong><br />
<a href="http://www.2of1.org/dropbox/coinpanel.png"><img src="http://www.2of1.org/dropbox/coinpanel_small.png"></a><br />
<br/><br />
<strong>Back panel (power and screen backlight buttons)</strong><br />
<a href="http://www.2of1.org/dropbox/backpanel.png"><img src="http://www.2of1.org/dropbox/backpanel_small.png"></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2011/08/02/mini-namco-1-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple C hashtable code</title>
		<link>http://blog.2of1.org/2011/07/11/simple-c-hashtable-code/</link>
		<comments>http://blog.2of1.org/2011/07/11/simple-c-hashtable-code/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 08:25:38 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Open source]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=575</guid>
		<description><![CDATA[Here&#8217;s some code for a simple C hashtable.

The hashtable uses char * for keys, allows any type of data to be stored, allows for an arbitrary size and uses linked-lists for collision handling.
hash.h
(Download here)

/* simple hashtable
 * David Kaplan &#60;david[at]2of1.org&#62;, 2011
 *
 * mem = (16 + 8 * size + 24 * entries) bytes [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s some code for a simple C hashtable.<br />
<span id="more-575"></span><br />
The hashtable uses <em>char *</em> for keys, allows any type of data to be stored, allows for an arbitrary size and uses linked-lists for collision handling.</p>
<p><strong>hash.h</strong><br />
(<a href="http://www.2of1.org/dropbox/hash.h">Download here</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* simple hashtable
 * David Kaplan &lt;david[at]2of1.org&gt;, 2011
 *
 * mem = (16 + 8 * size + 24 * entries) bytes [64-bit]
 * mem = (8 + 4 * size + 12 * entries) bytes [32-bit]
 *
 * some sizes for reference [64-bit]
 * 2^8  = 16K [probably too small - depending on use]
 * 2^16 = 512K [even bigger would be better]
 * 2^24 = 128MB [probably a bit too much]
 * 2^32 = 32GB [whooooa! watch that heap space!]
 *
 * the hashtable uses basic linked-lists for handling collisions
 */</span>
&nbsp;
<span style="color: #339933;">#define HT_MAX_KEYLEN 50</span>
&nbsp;
<span style="color: #993333;">struct</span> ht_node <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>val<span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #339933;">;</span>
  <span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">*</span>nxt<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">typedef</span> <span style="color: #993333;">struct</span> ht <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">**</span>tbl<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> size<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> HT<span style="color: #339933;">;</span>
&nbsp;
HT <span style="color: #339933;">*</span>ht_create<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                    <span style="color: #808080; font-style: italic;">/* allocate hashtable mem */</span>
<span style="color: #993333;">void</span> ht_destroy<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>                    <span style="color: #808080; font-style: italic;">/* free hashtable mem */</span>
<span style="color: #993333;">void</span> <span style="color: #339933;">*</span>ht_get<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>            <span style="color: #808080; font-style: italic;">/* retrieve entry */</span>
<span style="color: #993333;">void</span> ht_put<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #808080; font-style: italic;">/* store entry */</span>
<span style="color: #993333;">void</span> ht_remove<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>          <span style="color: #808080; font-style: italic;">/* remove entry */</span></pre></div></div>

<p><strong>hash.c</strong><br />
(<a href="http://www.2of1.org/dropbox/hash.c">Download here</a>)</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;stdint.h&gt;</span>
<span style="color: #339933;">#include &lt;malloc.h&gt;</span>
<span style="color: #339933;">#include &lt;string.h&gt;</span>
&nbsp;
<span style="color: #339933;">#include &quot;hash.h&quot;</span>
&nbsp;
<span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> _hash<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #808080; font-style: italic;">/* djb2 */</span>
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> hash <span style="color: #339933;">=</span> <span style="color: #0000dd;">5381</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> c<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">=</span> <span style="color: #339933;">*</span>key<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
    hash <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>hash <span style="color: #339933;">&lt;&lt;</span> <span style="color: #0000dd;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> hash<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> c<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> hash<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
HT <span style="color: #339933;">*</span>ht_create<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> size<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  HT <span style="color: #339933;">*</span>ht <span style="color: #339933;">=</span> malloc<span style="color: #009900;">&#40;</span><span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>HT<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  ht<span style="color: #339933;">-&gt;</span>size <span style="color: #339933;">=</span> size<span style="color: #339933;">;</span>
&nbsp;
  ht<span style="color: #339933;">-&gt;</span>tbl <span style="color: #339933;">=</span> calloc<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> size <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> ht<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> ht_destroy<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ht<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> ht<span style="color: #339933;">-&gt;</span>size<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">*</span>n <span style="color: #339933;">=</span> ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">*</span>n_old <span style="color: #339933;">=</span> n<span style="color: #339933;">;</span>
&nbsp;
      n <span style="color: #339933;">=</span> n<span style="color: #339933;">-&gt;</span>nxt<span style="color: #339933;">;</span>
&nbsp;
      free<span style="color: #009900;">&#40;</span>n_old<span style="color: #339933;">-&gt;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      n_old<span style="color: #339933;">-&gt;</span>key <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
      free<span style="color: #009900;">&#40;</span>n_old<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      n_old <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  free<span style="color: #009900;">&#40;</span>ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  free<span style="color: #009900;">&#40;</span>ht<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  ht <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> <span style="color: #339933;">*</span>ht_get<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ht<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> idx <span style="color: #339933;">=</span> _hash<span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> ht<span style="color: #339933;">-&gt;</span>size<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">*</span>n <span style="color: #339933;">=</span> ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>strncmp<span style="color: #009900;">&#40;</span>key<span style="color: #339933;">,</span> n<span style="color: #339933;">-&gt;</span>key<span style="color: #339933;">,</span> HT_MAX_KEYLEN<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
      <span style="color: #b1b100;">return</span> n<span style="color: #339933;">-&gt;</span>val<span style="color: #339933;">;</span>
&nbsp;
    n <span style="color: #339933;">=</span> n<span style="color: #339933;">-&gt;</span>nxt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> ht_put<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>val<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ht<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> idx <span style="color: #339933;">=</span> _hash<span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> ht<span style="color: #339933;">-&gt;</span>size<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">*</span>n_new <span style="color: #339933;">=</span> calloc<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> ht_node<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  n_new<span style="color: #339933;">-&gt;</span>val <span style="color: #339933;">=</span> val<span style="color: #339933;">;</span>
  n_new<span style="color: #339933;">-&gt;</span>key <span style="color: #339933;">=</span> calloc<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> strnlen<span style="color: #009900;">&#40;</span>key<span style="color: #339933;">,</span> HT_MAX_KEYLEN<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  strcpy<span style="color: #009900;">&#40;</span>n_new<span style="color: #339933;">-&gt;</span>key<span style="color: #339933;">,</span> key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  n_new<span style="color: #339933;">-&gt;</span>nxt <span style="color: #339933;">=</span> ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> n_new<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> ht_remove<span style="color: #009900;">&#40;</span>HT <span style="color: #339933;">*</span>ht<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ht<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">unsigned</span> <span style="color: #993333;">long</span> idx <span style="color: #339933;">=</span> _hash<span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> ht<span style="color: #339933;">-&gt;</span>size<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">struct</span> ht_node <span style="color: #339933;">*</span>p <span style="color: #339933;">=</span> NULL<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>n <span style="color: #339933;">=</span> ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>strncmp<span style="color: #009900;">&#40;</span>key<span style="color: #339933;">,</span> n<span style="color: #339933;">-&gt;</span>key<span style="color: #339933;">,</span> HT_MAX_KEYLEN<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span>
        p<span style="color: #339933;">-&gt;</span>nxt <span style="color: #339933;">=</span> n<span style="color: #339933;">-&gt;</span>nxt<span style="color: #339933;">;</span>
&nbsp;
      free <span style="color: #009900;">&#40;</span>n<span style="color: #339933;">-&gt;</span>key<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      n<span style="color: #339933;">-&gt;</span>key <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> n<span style="color: #009900;">&#41;</span>
        ht<span style="color: #339933;">-&gt;</span>tbl<span style="color: #009900;">&#91;</span>idx<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
&nbsp;
      free <span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      n <span style="color: #339933;">=</span> NULL<span style="color: #339933;">;</span>
&nbsp;
      <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    p <span style="color: #339933;">=</span> n<span style="color: #339933;">;</span>
    n <span style="color: #339933;">=</span> n<span style="color: #339933;">-&gt;</span>nxt<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2011/07/11/simple-c-hashtable-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>My Xmonad setup</title>
		<link>http://blog.2of1.org/2011/07/10/my-xmonad-setup/</link>
		<comments>http://blog.2of1.org/2011/07/10/my-xmonad-setup/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 11:59:50 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Tips & tricks]]></category>
		<category><![CDATA[Xmonad]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=562</guid>
		<description><![CDATA[Recently my WM of choice has been xmonad.
Configuring the desktop to my specification has been fun yet sometimes quite tedious as i messed around with the Haskell config (my knowledge of haskell == NULL), dzen2, conky, etc.
Here&#8217;s a screenshot from my main xinerama screen:

If anyone wants some inspiration for their setup, here are the relevant [...]]]></description>
			<content:encoded><![CDATA[<p>Recently my WM of choice has been xmonad.</p>
<p>Configuring the desktop to my specification has been fun yet sometimes quite tedious as i messed around with the Haskell config (my knowledge of haskell == NULL), dzen2, conky, etc.</p>
<p>Here&#8217;s a screenshot from my main xinerama screen:<br />
<a href="http://www.2of1.org/dropbox/xmonad_screen1.png" width="20%" height="20%"><img src="http://www.2of1.org/dropbox/xmonad_screen1.png"></a></p>
<p>If anyone wants some inspiration for their setup, here are the relevant config files / scripts:</p>
<p><strong>xmonad.hs</strong></p>

<div class="wp_syntax"><div class="code"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">import</span> XMonad
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Hooks<span style="color: #339933; font-weight: bold;">.</span>DynamicLog
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Hooks<span style="color: #339933; font-weight: bold;">.</span>ManageDocks
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Hooks<span style="color: #339933; font-weight: bold;">.</span>XPropManage
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Hooks<span style="color: #339933; font-weight: bold;">.</span>FadeInactive
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Util<span style="color: #339933; font-weight: bold;">.</span>Run<span style="color: green;">&#40;</span>spawnPipe<span style="color: green;">&#41;</span>
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Util<span style="color: #339933; font-weight: bold;">.</span>EZConfig<span style="color: green;">&#40;</span>additionalKeys<span style="color: green;">&#41;</span>
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Prompt
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Prompt<span style="color: #339933; font-weight: bold;">.</span>RunOrRaise
<span style="color: #06c; font-weight: bold;">import</span> System<span style="color: #339933; font-weight: bold;">.</span><span style="color: #cccc00; font-weight: bold;">IO</span>
<span style="color: #06c; font-weight: bold;">import</span> <span style="color: #06c; font-weight: bold;">qualified</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>StackSet <span style="color: #06c; font-weight: bold;">as</span> W
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>StackSet<span style="color: green;">&#40;</span>stack<span style="color: green;">&#41;</span>
<span style="color: #06c; font-weight: bold;">import</span> XMonad<span style="color: #339933; font-weight: bold;">.</span>Actions<span style="color: #339933; font-weight: bold;">.</span>TagWindows
&nbsp;
main <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span>
  workspaceBarPipe <span style="color: #339933; font-weight: bold;">&lt;-</span> spawnPipe myStatusBar
  spawn myConkyBar
  xmonad <span style="color: #339933; font-weight: bold;">$</span> defaultConfig
    <span style="color: green;">&#123;</span> manageHook <span style="color: #339933; font-weight: bold;">=</span> manageDocks <span style="color: #339933; font-weight: bold;">&lt;+&gt;</span> manageHook defaultConfig <span style="color: #339933; font-weight: bold;">&lt;+&gt;</span> myManageHook
    <span style="color: #339933; font-weight: bold;">,</span> layoutHook <span style="color: #339933; font-weight: bold;">=</span> avoidStruts <span style="color: #339933; font-weight: bold;">$</span> layoutHook defaultConfig
    <span style="color: #339933; font-weight: bold;">,</span> terminal <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;urxvt&quot;</span>
    <span style="color: #339933; font-weight: bold;">,</span> workspaces <span style="color: #339933; font-weight: bold;">=</span> myWorkspaces
    <span style="color: #339933; font-weight: bold;">,</span> startupHook <span style="color: #339933; font-weight: bold;">=</span> myStartupHook
    <span style="color: #339933; font-weight: bold;">,</span> logHook <span style="color: #339933; font-weight: bold;">=</span> myLogHook workspaceBarPipe <span style="color: #339933; font-weight: bold;">&gt;&gt;</span> fadeInactiveLogHook 0xdddddddd
    <span style="color: #339933; font-weight: bold;">,</span> modMask <span style="color: #339933; font-weight: bold;">=</span> mod4Mask
    <span style="color: green;">&#125;</span> `additionalKeys`
    <span style="color: green;">&#91;</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>mod4Mask <span style="color: #339933; font-weight: bold;">.|.</span> shiftMask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>z<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> spawn <span style="background-color: #3cb371;">&quot;xscreensaver-command -lock&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>controlMask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>Print<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> spawn <span style="background-color: #3cb371;">&quot;sleep 0.2; scrot -s&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span><span style="color: red;">0</span><span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>Print<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> spawn <span style="background-color: #3cb371;">&quot;scrot&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>mod4Mask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>x<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> runOrRaisePrompt defaultXPConfig<span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>mod4Mask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>m<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> focusUpTaggedGlobal <span style="background-color: #3cb371;">&quot;mail&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>mod4Mask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>i<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> focusUpTaggedGlobal <span style="background-color: #3cb371;">&quot;irc&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>mod4Mask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>c<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> focusUpTaggedGlobal <span style="background-color: #3cb371;">&quot;chat&quot;</span> <span style="color: #339933; font-weight: bold;">&gt;&gt;</span> spawn <span style="background-color: #3cb371;">&quot;cat /dev/null &gt; /tmp/centerim.msgs&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>mod4Mask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>b<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> focusUpTaggedGlobal <span style="background-color: #3cb371;">&quot;web&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#40;</span>mod4Mask<span style="color: #339933; font-weight: bold;">,</span> xK<span style="color: #339933; font-weight: bold;">_</span>d<span style="color: green;">&#41;</span><span style="color: #339933; font-weight: bold;">,</span> focusUpTaggedGlobal <span style="background-color: #3cb371;">&quot;dev&quot;</span><span style="color: green;">&#41;</span>
    <span style="color: green;">&#93;</span>
&nbsp;
ws<span style="color: #339933; font-weight: bold;">_</span>term <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;1:term&quot;</span>
ws<span style="color: #339933; font-weight: bold;">_</span>web <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;2:web&quot;</span>
ws<span style="color: #339933; font-weight: bold;">_</span>dev <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;3:dev&quot;</span>
ws<span style="color: #339933; font-weight: bold;">_</span>comms <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;4:comms&quot;</span>
ws<span style="color: #339933; font-weight: bold;">_</span>rce <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;5:rce&quot;</span>
ws<span style="color: #339933; font-weight: bold;">_</span>vms <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;6:vms&quot;</span>
ws<span style="color: #339933; font-weight: bold;">_</span>stats <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;7:stats&quot;</span>
&nbsp;
myStatusBar <span style="color: #339933; font-weight: bold;">::</span> <span style="color: #cccc00; font-weight: bold;">String</span>
myStatusBar <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;dzen2 -fn '-*-terminus-bold-r-normal-*-10-*-*-*-*-*-*-*' -bg '#000000' -fg '#444444' -h 22 -sa c -x 0 -y 0 -e '' -ta l -xs 1&quot;</span>
&nbsp;
myConkyBar <span style="color: #339933; font-weight: bold;">::</span> <span style="color: #cccc00; font-weight: bold;">String</span>
myConkyBar <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot;sleep 1 &amp;&amp; conky -c ~/.conkyrc | dzen2 -fn '-*-terminus-bold-r-normal-*-10-*-*-*-*-*-*-*' -bg black -fg green -h 22 -sa c -x 1000 -y 0 -e '' -ta r -xs 1&quot;</span>
&nbsp;
myLogHook <span style="color: #339933; font-weight: bold;">::</span> Handle <span style="color: #339933; font-weight: bold;">-&gt;</span> X <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span>
myLogHook h <span style="color: #339933; font-weight: bold;">=</span> dynamicLogWithPP <span style="color: #339933; font-weight: bold;">$</span> defaultPP
      <span style="color: green;">&#123;</span>   ppCurrent	<span style="color: #339933; font-weight: bold;">=</span> dzenColor <span style="background-color: #3cb371;">&quot;black&quot;</span> <span style="background-color: #3cb371;">&quot;green&quot;</span> <span style="color: #339933; font-weight: bold;">.</span> pad
	<span style="color: #339933; font-weight: bold;">,</span> ppVisible	<span style="color: #339933; font-weight: bold;">=</span> dzenColor <span style="background-color: #3cb371;">&quot;black&quot;</span> <span style="background-color: #3cb371;">&quot;lightgreen&quot;</span> <span style="color: #339933; font-weight: bold;">.</span> pad
	<span style="color: #339933; font-weight: bold;">,</span> ppHidden	<span style="color: #339933; font-weight: bold;">=</span> dzenColor <span style="background-color: #3cb371;">&quot;#cccccc&quot;</span> <span style="background-color: #3cb371;">&quot;&quot;</span> <span style="color: #339933; font-weight: bold;">.</span> pad
	<span style="color: #339933; font-weight: bold;">,</span> ppHiddenNoWindows <span style="color: #339933; font-weight: bold;">=</span> dzenColor <span style="background-color: #3cb371;">&quot;#444444&quot;</span>  <span style="background-color: #3cb371;">&quot;&quot;</span> <span style="color: #339933; font-weight: bold;">.</span> pad
	<span style="color: #339933; font-weight: bold;">,</span> ppUrgent	<span style="color: #339933; font-weight: bold;">=</span> dzenColor <span style="background-color: #3cb371;">&quot;&quot;</span> <span style="background-color: #3cb371;">&quot;red&quot;</span>
	<span style="color: #339933; font-weight: bold;">,</span> ppWsSep    <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot; &quot;</span>
	<span style="color: #339933; font-weight: bold;">,</span> ppSep      <span style="color: #339933; font-weight: bold;">=</span> <span style="background-color: #3cb371;">&quot; | &quot;</span>
	<span style="color: #339933; font-weight: bold;">,</span> ppTitle    <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot; &quot;</span> <span style="color: #339933; font-weight: bold;">++</span><span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">.</span> dzenColor <span style="background-color: #3cb371;">&quot;green&quot;</span> <span style="background-color: #3cb371;">&quot;&quot;</span> <span style="color: #339933; font-weight: bold;">.</span> dzenEscape
	<span style="color: #339933; font-weight: bold;">,</span> ppOutput   <span style="color: #339933; font-weight: bold;">=</span> hPutStrLn h
&nbsp;
      <span style="color: green;">&#125;</span>
&nbsp;
myWorkspaces <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#91;</span> ws<span style="color: #339933; font-weight: bold;">_</span>term<span style="color: #339933; font-weight: bold;">,</span>ws<span style="color: #339933; font-weight: bold;">_</span>web<span style="color: #339933; font-weight: bold;">,</span>ws<span style="color: #339933; font-weight: bold;">_</span>dev<span style="color: #339933; font-weight: bold;">,</span>ws<span style="color: #339933; font-weight: bold;">_</span>comms<span style="color: #339933; font-weight: bold;">,</span>ws<span style="color: #339933; font-weight: bold;">_</span>rce<span style="color: #339933; font-weight: bold;">,</span>ws<span style="color: #339933; font-weight: bold;">_</span>vms<span style="color: #339933; font-weight: bold;">,</span>ws<span style="color: #339933; font-weight: bold;">_</span>stats <span style="color: green;">&#93;</span>
&nbsp;
myManageHook <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span> composeAll
    <span style="color: green;">&#91;</span> appName <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;mutt&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>comms
    <span style="color: #339933; font-weight: bold;">,</span> appName <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;irssi&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>comms
    <span style="color: #339933; font-weight: bold;">,</span> appName <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;centerim&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>comms
    <span style="color: #339933; font-weight: bold;">,</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Chromium&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>web
    <span style="color: #339933; font-weight: bold;">,</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Eclipse&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>dev
    <span style="color: #339933; font-weight: bold;">,</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Vmware&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>vms
    <span style="color: #339933; font-weight: bold;">,</span> className <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;Idaq&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>rce
    <span style="color: #339933; font-weight: bold;">,</span> appName <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;htop&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>stats
    <span style="color: #339933; font-weight: bold;">,</span> appName <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;feh&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>stats
    <span style="color: #339933; font-weight: bold;">,</span> appName <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;dev1&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>dev
    <span style="color: #339933; font-weight: bold;">,</span> appName <span style="color: #339933; font-weight: bold;">=?</span> <span style="background-color: #3cb371;">&quot;dev2&quot;</span> <span style="color: #339933; font-weight: bold;">--&gt;</span> doShift ws<span style="color: #339933; font-weight: bold;">_</span>dev
    <span style="color: green;">&#93;</span> <span style="color: green;">&#41;</span> <span style="color: #339933; font-weight: bold;">&lt;+&gt;</span> xPropManageHook xPropMatches
&nbsp;
myStartupHook <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt -title mutt -name mutt -e mutt&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt -title irssi -name irssi -e irssi&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt -title centerim -name centerim -e centerim&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt -title htop -name htop -e htop&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt -title feh -name feh -e feh ~/pictures/&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;chromium&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt -title dev1 -name dev1&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;urxvt -title dev2 -name dev2&quot;</span> <span style="color: #339933; font-weight: bold;">&gt;&gt;</span> sendMessage NextWorkspace
  spawn <span style="background-color: #3cb371;">&quot;eclipse&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;vmware&quot;</span>
  spawn <span style="background-color: #3cb371;">&quot;schroot -p /home/dk/tools/ida/idaq&quot;</span>
&nbsp;
xPropMatches <span style="color: #339933; font-weight: bold;">::</span> <span style="color: green;">&#91;</span>XPropMatch<span style="color: green;">&#93;</span>
xPropMatches <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#91;</span> <span style="color: green;">&#40;</span><span style="color: green;">&#91;</span><span style="color: green;">&#40;</span>wM<span style="color: #339933; font-weight: bold;">_</span>CLASS<span style="color: #339933; font-weight: bold;">,</span> <span style="font-weight: bold;">any</span> <span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot;mutt&quot;</span><span style="color: #339933; font-weight: bold;">==</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span> pmX<span style="color: green;">&#40;</span>addTag <span style="background-color: #3cb371;">&quot;mail&quot;</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
               <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#91;</span><span style="color: green;">&#40;</span>wM<span style="color: #339933; font-weight: bold;">_</span>CLASS<span style="color: #339933; font-weight: bold;">,</span> <span style="font-weight: bold;">any</span> <span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot;irssi&quot;</span><span style="color: #339933; font-weight: bold;">==</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span> pmX<span style="color: green;">&#40;</span>addTag <span style="background-color: #3cb371;">&quot;irc&quot;</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
               <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#91;</span><span style="color: green;">&#40;</span>wM<span style="color: #339933; font-weight: bold;">_</span>CLASS<span style="color: #339933; font-weight: bold;">,</span> <span style="font-weight: bold;">any</span> <span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot;centerim&quot;</span><span style="color: #339933; font-weight: bold;">==</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span> pmX<span style="color: green;">&#40;</span>addTag <span style="background-color: #3cb371;">&quot;chat&quot;</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
               <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#91;</span><span style="color: green;">&#40;</span>wM<span style="color: #339933; font-weight: bold;">_</span>CLASS<span style="color: #339933; font-weight: bold;">,</span> <span style="font-weight: bold;">any</span> <span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot;chromium&quot;</span><span style="color: #339933; font-weight: bold;">==</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span> pmX<span style="color: green;">&#40;</span>addTag <span style="background-color: #3cb371;">&quot;web&quot;</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
               <span style="color: #339933; font-weight: bold;">,</span> <span style="color: green;">&#40;</span><span style="color: green;">&#91;</span><span style="color: green;">&#40;</span>wM<span style="color: #339933; font-weight: bold;">_</span>CLASS<span style="color: #339933; font-weight: bold;">,</span> <span style="font-weight: bold;">any</span> <span style="color: green;">&#40;</span><span style="background-color: #3cb371;">&quot;Eclipse&quot;</span><span style="color: #339933; font-weight: bold;">==</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#93;</span><span style="color: #339933; font-weight: bold;">,</span> pmX<span style="color: green;">&#40;</span>addTag <span style="background-color: #3cb371;">&quot;dev&quot;</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
               <span style="color: green;">&#93;</span></pre></div></div>

<p><strong>.centerim/external</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">%action nnotification
event msg
proto all
status all
options nowait
&nbsp;
%exec
#!/bin/bash
nick=$(head -n 1 $CONTACT_INFODIR/info)
echo $nick $EVENT_TYPE &gt;&gt; /tmp/centerim.msgs</pre></div></div>

<p><strong>centerim-notify.sh</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">TEMPFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>centerim.msgs
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$TEMPFILE</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #007800;">MSGS</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">wc</span> <span style="color: #660033;">-l</span> <span style="color: #800000;">${TEMPFILE}</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{ print $1 }'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #007800;">MSGS</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$MSGS</span>&quot;</span> <span style="color: #660033;">-lt</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">'^fg(green)'</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">'^bg(black)'</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">'^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/pacman.xbm) ^fg(#cccccc)'</span><span style="color: #800000;">${MSGS}</span><span style="color: #ff0000;">' ^bg(black)'</span>
<span style="color: #000000; font-weight: bold;">else</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">'^fg(black)'</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">'^bg(red)'</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> $<span style="color: #ff0000;">' ^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/pacman.xbm) '</span><span style="color: #800000;">${MSGS}</span><span style="color: #ff0000;">' ^bg(black) '</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p><strong>check-gmail.pl</strong><br />
(I pulled this off the net from somewhere and hacked it for my needs)</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">use</span> Switch<span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">use</span> Text<span style="color: #339933;">::</span><span style="color: #006600;">Wrap</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$what</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$ARGV</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">$user</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;user&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#username for gmail account</span>
<span style="color: #0000ff;">$pass</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;pass&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#password for gmail account</span>
<span style="color: #0000ff;">$file</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;/tmp/gmail.html&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#temporary file to store gmail</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#wrap format for subject</span>
<span style="color: #0000ff;">$Text</span><span style="color: #339933;">::</span><span style="color: #006600;">Wrap</span><span style="color: #339933;">::</span><span style="color: #006600;">columns</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">45</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#Number of columns to wrap subject at</span>
<span style="color: #0000ff;">$initial_tab</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#Tab for first line of subject</span>
<span style="color: #0000ff;">$subsequent_tab</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#tab for wrapped lines</span>
<span style="color: #0000ff;">$quote</span><span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#put quotes around subject</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#limit the number of emails to be displayed</span>
<span style="color: #0000ff;">$emails</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#if -1 display all emails</span>
&nbsp;
<span style="color: #0000ff;">&amp;passwd</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#give password the proper url character encoding</span>
&nbsp;
switch<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$what</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">#determine what the user wants</span>
    <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;n&quot;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #0000ff;">&amp;gmail</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$new</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;^fg(green) ^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/mail.xbm) ^fg(#cccccc)0&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;^fg(black)^bg(red) ^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/mail.xbm) $new ^bg(black)&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">#print number of new emails</span>
    <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;s&quot;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">#print $from and $subj for new email</span>
        <span style="color: #0000ff;">&amp;gmail</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$new</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$size</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@from</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$emails</span><span style="color: #339933;">!=-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$size</span><span style="color: #339933;">&gt;</span><span style="color: #0000ff;">$emails</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$size</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$emails</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">#limit number of emails displayed</span>
            <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #0000ff;">$size</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #0000ff;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;From: $from[$i]<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#print from line</span>
                <span style="color: #0000ff;">$text</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$quote</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$subj</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$quote</span><span style="color: #339933;">.</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">print</span> wrap<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$initial_tab</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$subsequent_tab</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#print subject with word wrap</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$size</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@from</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$emails</span><span style="color: #339933;">!=-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">&gt;</span><span style="color: #0000ff;">$emails</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$emails out of $size new emails displayed<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>     
    <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">&quot;e&quot;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">#print number of new emails, $from, and $subj</span>
        <span style="color: #0000ff;">&amp;gmail</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$new</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;You have no new emails.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;You have $new new email(s).<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$size</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@from</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$emails</span><span style="color: #339933;">!=-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$size</span><span style="color: #339933;">&gt;</span><span style="color: #0000ff;">$emails</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$size</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$emails</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">#limit number of emails displayed</span>
            <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">&lt;</span><span style="color: #0000ff;">$size</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span><span style="color: #0000ff;">$i</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;From: $from[$i]<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#print from line</span>
                <span style="color: #0000ff;">$text</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$quote</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$subj</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">$quote</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">print</span> wrap<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$initial_tab</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$subsequent_tab</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$text</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#print subject with word wrap</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #0000ff;">$size</span><span style="color: #339933;">=</span><span style="color: #0000ff;">@from</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$emails</span><span style="color: #339933;">!=-</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #0000ff;">$size</span> <span style="color: #339933;">&gt;</span><span style="color: #0000ff;">$emails</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;$emails out of $size new emails displayed<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Usage Error: gmail.pl &lt;option&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>n displays number of new emails<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>s displays from line and subject line for each new email.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span>e displays the number of new emails and from line plus <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\t</span><span style="color: #000099; font-weight: bold;">\t</span>subject line for each new email.<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">#didn't give proper option</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> gmail<span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>e <span style="color: #0000ff;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">#create file if it does not exists</span>
        <span style="color: #ff0000;">`touch $file`</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    <span style="color: #666666; font-style: italic;">#get new emails</span>
    <span style="color: #ff0000;">`wget -O - https://mail.google.com/a/2of1/feed/atom --user=$user --password=$pass --no-check-certificate&gt; $file`</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>IN<span style="color: #339933;">,</span> <span style="color: #0000ff;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#open $file</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#initialize count</span>
    <span style="color: #0000ff;">$new</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#initialize new emails to 0</span>
&nbsp;
    <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$flag</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009999;">&lt;IN&gt;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">#cycle through $file</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&lt;entry&gt;/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$flag</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #b1b100;">elsif</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&lt;fullcount&gt;(\d+)&lt;\/fullcount&gt;/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">$new</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$1</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">#grab number of new emails</span>
        <span style="color: #b1b100;">elsif</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$flag</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
            <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&lt;title&gt;.+&lt;\/title&gt;/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@subj</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&amp;msg</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">#grab new email titles</span>
            <span style="color: #b1b100;">elsif</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/&lt;name&gt;(.+)&lt;\/name&gt;/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@from</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">$1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #0000ff;">$flag</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #666666; font-style: italic;">#grab new email from lines</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span>IN<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#close $file</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> passwd<span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">#change to url escape codes in password</span>
    <span style="color: #666666; font-style: italic;">#URL ESCAPE CODES</span>
    <span style="color: #0000ff;">$_</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$pass</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\%/\%25/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\#/\%23/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\$/\%24/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;/\%26/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\//\%2F/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\:/\%3A/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\;/\%3B/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\&lt;/\%3C/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\=/\%3D/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\&gt;/\%3E/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\?/\%3F/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\@/\%40/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\[/\%5B/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\\/\%5C/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\]/\%5D/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\^/\%5E/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\`/\%60/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\{/\%7B/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\|/\%7C/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\}/\%7D/g</span><span style="color: #339933;">;</span>
    <span style="color: #009966; font-style: italic;">s/\~/\%7E/g</span><span style="color: #339933;">;</span>
    <span style="color: #0000ff;">$pass</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">sub</span> msg<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">#THE HTML CODED CHARACTER SET [ISO-8859-1]</span>
    <span style="color: #000066;">chomp</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/&lt;title&gt;(.+)&lt;\/title&gt;/$1/</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">#get just the subject</span>
    <span style="color: #666666; font-style: italic;">#now replace any special characters</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#33\;/!/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Exclamation mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#34\;/&quot;/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;quot\;/&quot;/g</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">#Quotation mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#35\;/#/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Number sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#36\;/\$/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Dollar sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#37\;/%/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Percent sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#38\;/&amp;/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;amp\;/&amp;/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Ampersand</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#39\;/'/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Apostrophe</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#40\;/(/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Left parenthesis</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#41\;/)/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Right parenthesis</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#42\;/*/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Asterisk</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#43\;/+/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Plus sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#44\;/,/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Comma</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#45\;/-/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Hyphen</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#46\;/./g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Period (fullstop)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#47\;/\//g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Solidus (slash)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#58\;/:/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Colon</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#59\;/\;/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Semi-colon</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#60\;/&lt;/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;lt\;/&lt;/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Less than</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#61\;/=/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Equals sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#62\;/&gt;/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;gt\;/&gt;/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Greater than</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#63\;/\?/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Question mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#64\;/\@/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Commercial at</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#91\;/\[/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Left square bracket</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#92\;/\\/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Reverse solidus (backslash)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#93\;/\]/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Right square bracket</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#94\;/\^/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Caret</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#95\;/_/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Horizontal bar (underscore)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#96\;/\`/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#123\;/\{/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Left curly brace</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#124\;/|/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Vertical bar</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#125\;/\}/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Right curly brace</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#126\;/~/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Tilde</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#161\;/¡/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Inverted exclamation</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#162\;/¢/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Cent sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#163\;/£/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Pound sterling</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#164\;/¤/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#General currency sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#165\;/¥/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Yen sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#166\;/¦/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Broken vertical bar</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#167\;/§/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Section sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#168\;/¨/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Umlaut (dieresis)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#169\;/©/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;copy\;/©/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Copyright</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#170\;/ª/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Feminine ordinal</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#171\;/«/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Left angle quote, guillemotleft</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#172\;/¬/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Not sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#174\;/®/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Registered trademark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#175\;/¯/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Macron accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#176\;/°/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Degree sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#177\;/±/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Plus or minus</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#178\;/²/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Superscript two</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#179\;/³/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Superscript three</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#180\;/´/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#181\;/µ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Micro sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#182\;/¶/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Paragraph sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#183\;/·/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Middle dot</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#184\;/¸/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Cedilla</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#185\;/¹/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Superscript one</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#186\;/º/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Masculine ordinal</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#187\;/»/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Right angle quote, guillemotright</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#188\;/¼/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;frac14\;/¼/g</span><span style="color: #339933;">;</span>       <span style="color: #666666; font-style: italic;"># Fraction one-fourth</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#189\;/½/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;frac12\;/½/g</span><span style="color: #339933;">;</span>       <span style="color: #666666; font-style: italic;"># Fraction one-half</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#190\;/¾/g</span><span style="color: #339933;">;</span> <span style="color: #009966; font-style: italic;">s/\&amp;frac34\;/¾/g</span><span style="color: #339933;">;</span>       <span style="color: #666666; font-style: italic;"># Fraction three-fourths</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#191\;/¿/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Inverted question mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#192\;/À/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital A, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#193\;/Á/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital A, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#194\;/Â/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital A, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#195\;/Ã/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital A, tilde</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#196\;/Ä/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital A, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#197\;/Å/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital A, ring</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#198\;/Æ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital AE dipthong (ligature)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#199\;/Ç/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital C, cedilla</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#200\;/È/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital E, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#201\;/É/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital E, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#202\;/Ê/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital E, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#203\;/Ë/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital E, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#204\;/Ì/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital I, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#205\;/Í/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital I, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#206\;/Î/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital I, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#207\;/Ï/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital I, dieresis or umlaut mark   </span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#208\;/Ð/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital Eth, Icelandic</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#209\;/Ñ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital N, tilde</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#210\;/Ò/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital O, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#211\;/Ó/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital O, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#212\;/Ô/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital O, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#213\;/Õ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital O, tilde</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#214\;/Ö/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital O, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#215\;/×/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Multiply sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#216\;/Ø/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital O, slash</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#217\;/Ù/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital U, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#218\;/Ú/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital U, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#219\;/Û/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital U, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#220\;/Ü/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital U, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#221\;/Ý/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital Y, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#222\;/Þ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Capital THORN, Icelandic</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#223\;/ß/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small sharp s, German (sz ligature)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#224\;/à/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small a, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#225\;/á/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small a, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#226\;/â/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small a, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#227\;/ã/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small a, tilde</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#228\;/ä/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small a, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#229\;/å/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small a, ring</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#230\;/æ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small ae dipthong (ligature)</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#231\;/ç/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small c, cedilla</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#232\;/è/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small e, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#233\;/é/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small e, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#234\;/ê/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small e, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#235\;/ë/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small e, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#236\;/ì/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small i, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#237\;/í/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small i, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#238\;/î/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small i, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#239\;/ï/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small i, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#240\;/ð/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small eth, Icelandic</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#241\;/ñ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small n, tilde</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#242\;/ò/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small o, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#243\;/ó/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small o, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#244\;/ô/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small o, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#245\;/õ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small o, tilde</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#246\;/ö/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small o, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#247\;/÷/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Division sign</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#248\;/ø/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small o, slash</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#249\;/ù/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small u, grave accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#250\;/ú/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small u, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#251\;/û/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small u, circumflex accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#252\;/ü/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small u, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#253\;/ý/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small y, acute accent</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#254\;/þ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small thorn, Icelandic</span>
    <span style="color: #009966; font-style: italic;">s/\&amp;\#255\;/ÿ/g</span><span style="color: #339933;">;</span>        <span style="color: #666666; font-style: italic;">#Small y, dieresis or umlaut mark</span>
    <span style="color: #009966; font-style: italic;">s/^\s+//</span><span style="color: #339933;">;</span>
    <span style="color: #000066;">return</span> <span style="color: #0000ff;">$_</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>.conkyrc</strong></p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">background yes
out_to_console yes
update_interval 1.0
no_buffers yes
text_buffer_size 512
&nbsp;
&nbsp;
TEXT
^fg(\#444444)| ^fg(green)^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/cpu.xbm) ^fg(\#cccccc)${cpu cpu0}% ^fg(\#444444)| ^fg(green)^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/mem.xbm) ^fg(\#cccccc)$mem ^fg(\#444444)| ^fg(green)^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/net_down_03.xbm)^fg(\#cccccc)${downspeed eth0} ^fg(green)^i(/home/dk/.xmonad/dzen2/icons/sm4tik/xbm8x8/net_up_03.xbm)^fg(\#cccccc)${upspeed eth0} ^fg(\#444444)| ^fg(\white)${execi 3 /home/dk/.xmonad/dzen2/scripts/centerim-notify} ^fg(\#444444)| ^fg(\white)${execi 30 /home/dk/.xmonad/dzen2/scripts/check-gmail-davkaplan.pl n 2&gt;&gt;/dev/null} ^fg(\#444444)^fn(-*-*-normal-*-*-*-9-*-*-*-*-*-*-*)[dk]^fn(-*-*-bold-*-*-*-10-*-*-*-*-*-*-*) | ^fg(\white)${execi 30 /home/dk/.xmonad/dzen2/scripts/check-gmail-2of1.pl n 2&gt;&gt;/dev/null} ^fg(\#444444)^fn(-*-*-normal-*-*-*-9-*-*-*-*-*-*-*)[2of1]^fn(-*-*-bold-*-*-*-10-*-*-*-*-*-*-*) | ^fg(green)${time %d-%m-%y %l:%M%p}</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2011/07/10/my-xmonad-setup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing IDA Pro (32-bit) on 64-bit Arch Linux</title>
		<link>http://blog.2of1.org/2011/07/07/installing-ida-pro-32-bit-on-64-bit-arch-linux/</link>
		<comments>http://blog.2of1.org/2011/07/07/installing-ida-pro-32-bit-on-64-bit-arch-linux/#comments</comments>
		<pubDate>Thu, 07 Jul 2011 09:24:27 +0000</pubDate>
		<dc:creator>2of1</dc:creator>
				<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Reverse engineering]]></category>

		<guid isPermaLink="false">http://blog.2of1.org/?p=550</guid>
		<description><![CDATA[Installing IDA Pro on a 64-bit flavour of Linux is a bit of a business &#8211; mostly because there is no 64-bit version of IDA (yet).

Now of course you can install it in a VM, but what&#8217;s the point? A x86_64 can natively run 32-bit instructions can&#8217;t it?!
Getting IDA Pro up and running involves quite [...]]]></description>
			<content:encoded><![CDATA[<p>Installing IDA Pro on a 64-bit flavour of Linux is a bit of a business &#8211; mostly because there is no 64-bit version of IDA (yet).<br />
<span id="more-550"></span><br />
Now of course you can install it in a VM, but what&#8217;s the point? A x86_64 can natively run 32-bit instructions can&#8217;t it?!</p>
<p>Getting IDA Pro up and running involves quite a few steps. Here&#8217;s how it&#8217;s done on Arch Linux.</p>
<p><strong>32-bit chroot environment</strong><br />
This first thing to do is get a minimal 32-bit chroot environment going.<br />
There are a number of ways of doing this (in fact, there are a number of ways of doing almost everything in this post).<br />
The easiest is probably by installing the arch32-light package from the AUR:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">pak -S arch32-light
sudo arch32initialize
sudo pacman32  -Sy bash coreutils filesystem grep gzip licenses sed
sudo pacman -S schroot</pre></div></div>

<p>(NOTE: I use paktahn to install Arch Linux packages as to includes support for all repositories &#8211; including AUR &#8211; and has a &#8216;pacman&#8217;-esque command format feel to it; but please feel free to use whatever method/frontend you want)</p>
<p>You should now have a fancy, albeit minimal, 32-bit chroot environment set up.</p>
<p><strong>Installing IDA Pro</strong><br />
Now you can go ahead and copy IDA Pro somewhere.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">mkdir ~/tools/ida
tar xvf ida_XXXXXXXXXXXXX* -C ~/tools/ida</pre></div></div>

<p><strong>Getting IDA to execute using</strong><br />
We now need to install a number of 32-bit dependencies for IDA (./idaq) to run:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo pacman32 -S glib2 freetype2 ttf-dejavu libsm libxrender fontconfig libxext</pre></div></div>

<p>IDA needs to connect to the host (64-bit) X-Windows server.<br />
Access control is enabled by default, so simply give access to local clients:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">xhost +local:</pre></div></div>

<p><strong>Give it a go!</strong><br />
You should now be able to take you IDA install for a spin:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">schroot -p ./tools/ida/idaq</pre></div></div>

<p>What you&#8217;ll notice is that idapython can&#8217;t dlopen() libpython2.6. Simply installing python2.7 in the chroot environment (with pacman32) or even installing python 2.6 from the AUR doesn&#8217;t seem to work (creating a symbolic link from 2.7 -> 2.6 is a no go either).<br />
You can either compile a 32-bit, python2.7 version of idapython or ask/wait for one to be released.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.2of1.org/2011/07/07/installing-ida-pro-32-bit-on-64-bit-arch-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced

Served from: blog.2of1.org @ 2012-05-20 18:26:41 -->
