tag:blogger.com,1999:blog-84721772024-03-13T12:37:25.157-07:00Bringing World Peace Through Software EngineeringProgramming is hereditary, parents inherit it from their childrenUnknownnoreply@blogger.comBlogger328125tag:blogger.com,1999:blog-8472177.post-27885605507367009932018-05-01T01:59:00.000-07:002019-08-22T12:34:12.324-07:00Pytest warning: How to fix Pytest plugin warningsIf, like most of the guys I know, you use Pytest for testing, you will at some stage run into different warnings when running your tests. Mine for some reason started issuing a warning like this:<br />
<span style="font-size: x-small;">pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0. Please remove the prefix and use the @pytest.fixture decorator instead.</span><br />
<div>
<br /></div>
<div>
Although, this did not stop the test from passing - it simply changed the colour to yellow instead of green to indicate that your tests passed successfully.</div>
<div>
<br /></div>
<div>
In my case, the issue was due to an outdated version of pytest-cov plugin that was installed as part of the original pytest installation. As it turns out, pytest won't upgrade it even when you upgrade your pytest version. So, you are left to not only figure out what the issue is, but how to fix it.</div>
<div>
<br /></div>
<div>
In most cases where similar warnings are shown, it can easily be fixed by first identifying which of the plugins is causing the issue rather than suppressing it; and attempt to upgrade it separately. This should hopefully fix it.</div>
<div>
<br /></div>
<div>
Again, in my case a simple command like this:<br />
<span style="font-size: x-small;">pip install --upgrade pytest-cov</span><br />
<span style="font-size: x-small;"><br /></span></div>
<div>
helped to fix the issues and returned my test results to green.</div>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-16462095359125670582018-01-07T12:06:00.001-08:002018-01-07T12:39:13.926-08:00Sorting Python Dictionary By ValuesFirst, I would like to say happy new year to you and hope you had a great 2017 and looking forward to a more rewarding and better year ahead. My 2017 started not very well, but ended on a high. I changed jobs. I will write about it later.<br />
<br />
For now I just wanted to document something I hope will be useful to others as much as it has been for me.<br />
<br />
There are times when something quite seemingly quite simple can be nothing but. In MySQL, it's simple to group by a field but didn't think I could do the same thing in Python. A quick search led to this example that I quickly adapted to fit my need. Hence this post... not only to share but to also document it just in case the original link disappears like some sites do these days.<br />
<br />
<pre class="programlisting" style="background: rgb(251, 251, 251); border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-image: initial; border-left-color: initial; border-left-style: initial; border-right-color: initial; border-right-style: initial; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-width: 1px 0px; box-sizing: border-box; color: #4a3c31; font-family: "Droid Sans Mono", Courier, monospace; font-kerning: normal; font-size: 12.8px; hyphens: none; line-height: 1.5em; margin-bottom: 1.5em; outline: 0px; overflow-x: auto; overflow-y: hidden; padding: 1em 2em; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline; word-break: keep-all; word-wrap: initial;"><code class="kn" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">from</code> <code class="nn" style="background: transparent; border: 0px; box-sizing: border-box; color: #00ccff; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">operator</code> <code class="kn" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">import</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">itemgetter</code>
<code class="kn" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">from</code> <code class="nn" style="background: transparent; border: 0px; box-sizing: border-box; color: #00ccff; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">itertools</code> <code class="kn" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">import</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">groupby</code>
</pre>
<pre class="programlisting" style="background: rgb(251, 251, 251); border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-image: initial; border-left-color: initial; border-left-style: initial; border-right-color: initial; border-right-style: initial; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-width: 1px 0px; box-sizing: border-box; color: #4a3c31; font-family: "Droid Sans Mono", Courier, monospace; font-kerning: normal; font-size: 12.8px; hyphens: none; line-height: 1.5em; margin-bottom: 1.5em; outline: 0px; overflow-x: auto; overflow-y: hidden; padding: 1em 2em; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline; word-break: keep-all; word-wrap: initial;"><pre class="programlisting" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-bottom-color: rgb(221, 221, 221); border-bottom-style: solid; border-image: initial; border-left-color: initial; border-left-style: initial; border-right-color: initial; border-right-style: initial; border-top-color: rgb(221, 221, 221); border-top-style: solid; border-width: 1px 0px; box-sizing: border-box; font-family: "Droid Sans Mono", Courier, monospace; font-kerning: normal; font-size: 12.8px; hyphens: none; line-height: 1.5em; margin-bottom: 1.5em; outline: 0px; overflow-x: auto; overflow-y: hidden; padding: 1em 2em; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline; word-break: keep-all; word-wrap: initial;"><code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">rows</code> <code class="o" style="background: transparent; border: 0px; box-sizing: border-box; color: #555555; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">=</code> <code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">[</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'5412 N CLARK'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/01/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'5148 N CLARK'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/04/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'5800 E 58TH'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/02/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'2122 N CLARK'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/03/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'5645 N RAVENSWOOD'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/02/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'1060 W ADDISON'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/02/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'4801 N BROADWAY'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/01/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">{</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'address'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'1039 W GRANVILLE'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code> <code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'07/04/2012'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">},</code>
<code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">]</code></pre>
<code class="c" style="background: transparent; border: 0px; box-sizing: border-box; color: #0099ff; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-style: italic; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;"># Sort by the desired field first</code>
<code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">rows</code><code class="o" style="background: transparent; border: 0px; box-sizing: border-box; color: #555555; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">.</code><code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">sort</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">(</code><code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">key</code><code class="o" style="background: transparent; border: 0px; box-sizing: border-box; color: #555555; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">=</code><code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">itemgetter</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">(</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">))</code>
<code class="c" style="background: transparent; border: 0px; box-sizing: border-box; color: #0099ff; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-style: italic; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;"># Iterate in groups</code>
<code class="k" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">for</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">date</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">items</code> <code class="ow" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">in</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">groupby</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">(</code><code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">rows</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">key</code><code class="o" style="background: transparent; border: 0px; box-sizing: border-box; color: #555555; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">=</code><code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">itemgetter</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">(</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">'date'</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">)):</code>
<code class="k" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">print</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">(</code><code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">date</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">)</code>
<code class="k" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">for</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">i</code> <code class="ow" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">in</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">items</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">:</code>
<code class="k" style="background: transparent; border: 0px; box-sizing: border-box; color: #006699; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; font-weight: bold; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">print</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">(</code><code class="s" style="background: transparent; border: 0px; box-sizing: border-box; color: #cc3300; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">' '</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">,</code> <code class="n" style="background: transparent; border: 0px; box-sizing: border-box; color: #000088; font-family: "Ubuntu Mono", monospace; font-kerning: normal; font-size: inherit; margin: 0px; outline: 0px; padding: 0px; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">i</code><code class="p" style="background: transparent; border: 0px; box-sizing: border-box; color: black; font-family: inherit !important; font-kerning: normal; font-size: inherit; line-height: 1.5em !important; margin: 0.75em 0px 1.25em !important; outline: 0px; padding: 0px; text-align: inherit; text-rendering: optimizeLegibility; text-size-adjust: 100%; vertical-align: baseline;">)</code></pre>
<pre class="programlisting" style="background: rgb(251, 251, 251); border-bottom: 1px solid rgb(221, 221, 221); border-left-width: 0px; border-right-width: 0px; border-top: 1px solid rgb(221, 221, 221); box-sizing: border-box; font-size: 12.8px; line-height: 1.5em; margin-bottom: 1.5em; outline: 0px; overflow-x: auto; overflow-y: hidden; padding: 1em 2em; vertical-align: baseline; word-break: keep-all;">Then: https://stackoverflow.com/questions/9198334/how-to-build-up-a-html-table-with-a-simple-for-loop-in-jinja2</pre>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-73057810335150666302017-04-20T06:31:00.002-07:002017-04-20T06:31:28.947-07:00Learning RA few years ago I was a very active Java developer and advocate. I loved it, helped to organise meetup events and even spent many nights answering questions in the now-defunct Java forum. I'm sure some old time Java developers here will still remember those days.<br />It used to be quite fun; I learnt a lot myself just by researching and helping people with their issues. You can't provide a solution if you haven't compiled and ran the code yourself - which is a great way to learn.<br /> <br />But sometime in 2009, I discovered Python by share chance. In one of the many forums online, someone was asking about open source anti-virus software - and if they were any good compared to paid software. <br />A few people suggested that Clamwin was quite good and it was open source. This got my thinking that it would be nice to see how real-world open source applications were developed.<br /> <br />Downloaded the code and studied just about every file in the project folder. That was my very first exposure to Python and it was surprisingly easy to understand the code. The C code on the other hand was bit trickier and somewhat confusing to say the least :)<br />This led to me learning Python and eventually getting a job as a developer using the language; and slowly using less of Java. <br /><br />However, in the last 6 months or so, I have started messing about with R and I'm blown away at how quickly you can knock things together especially when it comes to data.<br /><br />I will be adding more R code here as time goes on - this is mainly for me to document my progress and to share something that others can hopefully find useful.<br />Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-13111171062469284392015-07-01T06:26:00.001-07:002015-07-01T06:26:35.268-07:00Parsing JSON With PythonOk, in the last couple of weeks I've been working with Google Geocoding
but realised how easy it is to parse the return JSON in Python. In fact,
I was parsing the JSON result with Javascript - which does a very nice
job, but i needed or rather prefered to have better control than what
Javascript provides.<br /> <br />And this is where Python comes in. If you
have been working with Python for a while, you will have noticed that
JSON is nothing more than a Python Dictionary. This makes accessing the
key/<span class="IL_AD" id="IL_AD8">value</span> quite effortless.
To give you a simple example, here's an output of a simple <span class="IL_AD" id="IL_AD12">address</span> query using Google's Geocoding API:
http://maps.googleapis.com/maps/api/geocode/json?address=8-10%20Broadway,%20London%20SW1H%200BG,%20United%20Kingdom&sensor=false<br />
<br />
<pre>{
"results" : [
{
"address_components" : [
{
"long_name" : "8-10",
"short_name" : "8-10",
"types" : [ "street_number" ]
},
{
"long_name" : "Broadway",
"short_name" : "Broadway",
"types" : [ "route" ]
},
{
"long_name" : "Westminster",
"short_name" : "Westminster",
"types" : [ "sublocality", "political" ]
},
{
"long_name" : "London",
"short_name" : "London",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Greater London",
"short_name" : "Gt Lon",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "United Kingdom",
"short_name" : "GB",
"types" : [ "country", "political" ]
},
{
"long_name" : "SW1H 0BG",
"short_name" : "SW1H 0BG",
"types" : [ "postal_code" ]
},
{
"long_name" : "London",
"short_name" : "London",
"types" : [ "postal_town" ]
}
],
"formatted_address" : "8-10 Broadway, Westminster, London, Greater London SW1H 0BG, UK",
"geometry" : {
"location" : {
"lat" : 51.49873430,
"lng" : -0.13312210
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 51.50008328029150,
"lng" : -0.1317731197084980
},
"southwest" : {
"lat" : 51.49738531970850,
"lng" : -0.1344710802915020
}
}
},
"types" : [ "street_address" ]
}
],
"status" : "OK"
} </pre>
<pre> </pre>
<pre>What is displayed above is the result of the URL we supplied to Google's
Geocoding API. Of course, we couldn't display that to our users - that
would be daft. Most of the time you'd want to parse this info and use
the <span class="IL_AD" id="IL_AD9">values</span> in <span class="IL_AD" id="IL_AD1">your application</span>.
In our case we had to extract the Lat and Long for our application.
There was no need to display the JSON - Python makes this a breeze and
all we need is to use Python's urllib2 module to open up the URL and
read the result.
So, to parse that and display the full address in human-readable format, it's as simple as doing something list this:
>>> import json
>>> import urllib2
>>> j = urllib2.urlopen('http://maps.googleapis.com/maps/api/geocode/json?address=8-10%20Broadway,%20London%20SW1H%200BG,%20United%20Kingdom&sensor=false')
>>> js = json.load(j)
Please note that we used load() instead of loads(). You would typically
use loads() for strings, but load() is designed for resources such as
files and - and in our example - a URL.
Now to display the address, we simply loop through our dictionary like so:
>>> ourResult = js['results'][0]['address_components']
>>> for rs in ourResult:
... print rs['long_name']
...
8-10
Broadway
Westminster
London
Greater London
United Kingdom
SW1H 0BG
London
>>>
With that out of the way, what about our main focus which is to print the coordinate of a particular address? Well, it turns out that that is even a lot simpler.
This time we just navigate our way down until we find what we're after. Which in this case is the <span class="IL_AD" id="IL_AD6">latitude and longitude</span>.
>>> ourResult = js['results'][0]['geometry']['location']
>>> print ourResult['lat'], ourResult['lng']
51.4987343 -0.1331221
>>>
One other cool thing about parsing JSON with Python is that you can
quickly and easily map the results into your Django Model and do
anything dangoey with it. Here's an example:
objs = json.loads(request.POST)
# Iterate through the stuff in the list
for o in objs:
# <span class="IL_AD" id="IL_AD7">Do something</span> Djangoey with o's name and message, like
record = myDjangoModel(name = o.name, message = o.message)
record.save()
Now, if you are looking to mix Python, JSON and Django together - it is as simple what we've just shown above.
</pre>
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-29178585603074691412015-01-25T11:57:00.001-08:002015-01-25T11:58:18.427-08:00Testing Python: Applying Unit Testing, TDD, BDD and Acceptance TestingThis is a long overdue book. Python has been steadily growing in popularity in multiple industry verticals over the past decade and the different sub-cultures have brought a variety of programming styles and methodologies to the language. As more and more Python code is powering today's production and mission-critical systems it becomes essential to ensure quality and reliability while maintaining efficient and agile development practices.<br />
<br />
There has been a flurry of literature written in recent years about the overall benefits of agile methodologies and test-driven development. To a large extent, however, individual developers and teams have been left on their own to figure out how to put this philosophy to practice and extract maximum benefit from it in their trade.<br />
<br />
David Sale's book alleviates this issue for Python developers by providing extremely pragmatic, timely and well-organized guidelines as well as many specific examples on how to approach the development and testing of complex systems in a way that amounts to building better software.This is not an academic work - it focuses exclusively on practical solutions to real-world industry problems.<br />
<br />
Fairly short and to the point, the book mixes equal portions of justification and tutorial-style examples to work through.<br />
<br />
The author has picked some of the best Python tools that are currently available for the various tasks at hand, but the reader will be well equipped to make their own choices once they understand the basic concepts.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-68409505875858755242014-07-24T09:08:00.002-07:002014-07-24T09:32:05.969-07:00Working with Peewee ORMWow, it's been a long while since I last posted something here. As always work and family have been taking a huge chunk of my free time - making it almost impossible to drop by to update this blog.<br />
<br />
That said, I have been playing around with Peewee. It is a very small ORM (Object Relational Mapping) framework for working with your database. It is fits very well with things like Flask or Bottle Python frameworks. If you've spent time developing in Django you will feel very much at home. All the models and queries are basically the same except a few that make the Peewee stand out.<br />
<br />
It currently supports PostgreSQL, MySQL and SQLite. Installation is a breeze - just use pip at a command prompt like so:<br />
<br />
$pip install peewee<br />
<br />
Here is a sample application that defines our models, creates the tables, inserts the data and prints them all out again.<br />
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;">################### Example of using the Peewee ORM ########################
from peewee import *
db = SqliteDatabase(app.db)</pre>
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;">class BaseModel(Model):
class Meta:
database = db
class Person(BaseModel):
name = CharField(max_length=100, index=True)
class StatusUpdate(BaseModel):
person = ForeignKeyField(Person, related_name='statuses')
status = TextField()
timestamp = DateTimeField(default=datetime.datetime.now, index=True)
Person.create_table()
StatusUpdate.create_table()
#------ Inserting into our new tables --------
huey = Person(name='Nkem')
huey.save()
#or
charlie = Person.create(name='Charlie')
StatusUpdate.create(charlie, status='First status')
#----- querying -----
people = Person.select().order_by(Person.name)
for person in people:print person.name
print person.name </pre>
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;"> for status in person.statuses.order_by(StatusUpdate.timestamp):
print '*', status.status
</pre>
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;"> </pre>
For those who like to take control of their SQL, Peewee also allows you to run raw SQL commands. Here is an example of it:<br />
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;"><span class="n">db</span> <span class="o">=</span> <span class="n">SqliteDatabase</span><span class="p">(</span><span class="s">':memory:'</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">Person</span><span class="p">(</span><span class="n">Model</span><span class="p">):</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">CharField</span><span class="p">()</span>
<span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
<span class="n">database</span> <span class="o">=</span> <span class="n">db</span>
<span class="c"># let's pretend we want to do an "upsert", something that SQLite can</span>
<span class="c"># do, but peewee cannot.</span>
<span class="k">for</span> <span class="n">name</span> <span class="ow">in</span> <span class="p">(</span><span class="s">'charlie'</span><span class="p">,</span> <span class="s">'mickey'</span><span class="p">,</span> <span class="s">'huey'</span><span class="p">):</span>
<span class="n">db</span><span class="o">.</span><span class="n">execute_sql</span><span class="p">(</span><span class="s">'REPLACE INTO person (name) VALUES (?)'</span><span class="p">,</span> <span class="p">(</span><span class="n">name</span><span class="p">,))</span>
<span class="c"># now let's iterate over the people using our own query.</span>
<span class="k">for</span> <span class="n">person</span> <span class="ow">in</span> <span class="n">Person</span><span class="o">.</span><span class="n">raw</span><span class="p">(</span><span class="s">'select * from person'</span><span class="p">):</span>
<span class="k">print</span> <span class="n">person</span><span class="o">.</span><span class="n">name</span> <span class="c"># .raw() will return model instances.</span></pre>
I find it quite interesting mixing it with Flask. There are a few ideas I have and will explore them over the weekend and post the result here.
There are tons of things you can do with this little framework - so go explore and see what you come up with.
Good luck!
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-83977493768841635482014-03-22T03:57:00.002-07:002014-03-22T03:59:13.990-07:00The New Speaking JavaScriptI bought this book despite having other general-purpose Javascript references because I've always really liked Dr. Rauschmeyer's precise writing style on his blog. This book does not disappoint. It's a clear, complete, and unambiguous reference to an sometimes misunderstood and often confusing language.<br />
<br />
This is an authoritative guide to the language that doesn't complain or split hairs. There's a tremendous amount of information here presented by a subject matter expert who's adept at explaining sometimes difficult and nuanced concepts with remarkable clarity and terseness. He doesn't gloss over anything or make assumptions; he simply tells it like it is.<br />
<br />
This isn't a difficult book to read, in fact it's refreshingly easy, but it's probably not going to be great for novices. It assumes a certain capability on the part of the reader. If you're starting from ground zero, I'd recommend something more conversational or introductory. But if you're looking for a brilliantly organized and researched in-depth reference, you won't be disappointed with Speaking Javascript. Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-35171800612705537042013-12-31T05:10:00.000-08:002013-12-31T05:13:41.194-08:00How I combined simple #Python list comprehension and JSON parsingThere are lots of very interesting things to discover in Python - <span class="IL_AD" id="IL_AD5">especially</span> if you've been working with <span class="IL_AD" id="IL_AD2">Java</span> or any other programming <span class="IL_AD" id="IL_AD6">language</span> for some time. <span class="IL_AD" id="IL_AD4">For example</span> this simple <span class="IL_AD" id="IL_AD8">piece</span>
of code demonstrates how you can quite easily convert a list of of
Strings of integers separated by comma - into a list of integers.
What I particularly like about this small code is that it uses what
Python developers refer to list comprehension.
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;">string1 = "020783, 503553, 555204"
mylist = [int(n) for n in string1.split(',')]
>>>>>> mylist
>>> [020783, 503553, 555204]
</pre>
Now, that piece of code was all I needed to get the API <span class="IL_AD" id="IL_AD3">application</span> I was working on to <span class="IL_AD" id="IL_AD1">generate</span> a nested list of integers. As it turns out, Python makes things really easy.
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;">def parse_points(self, json_response):
try:
result = json.loads(json_response)
if result.has_key('points'):
the_points = result['points']['code']
mylist = [int(n) for n in the_points.split(',')]
return mylist
else:
return result
except ValueError, e:
raise PlottingError('JSON Parsing Error: ' + e)
</pre>
....
Further down <span class="IL_AD" id="IL_AD7">the code</span>, that returned value is eventually used to as an array of list:
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;"> "waypoints":[020783,
503553,
555204]
</pre>
This would not make much sense to a lot of people out there - that is deliberate because I don't want to show the code in full. Protecting the real code is vital here. However, the aim for this small code is to demonstrate <span class="IL_AD" id="IL_AD9">how to</span>
parse a list of integers in string separated by comma. With time I will
post a full blog with a complete working code on how this works.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-30231799961458762662013-12-02T04:32:00.001-08:002013-12-02T05:35:35.270-08:00Python 3 Object Oriented Programming - The ReviewPrior to reading Python 3 Object Oriented Programming I was already familiar with advanced OOP
concepts and Python 2 in particular; as well as with Java and other languages. So, I expected the book to enforce my
thinking and help me to understand new features provided by Python 3 as
compared to version 2. I think the book managed to do this in an
excellent manner.<br />
<br />
I think the approach used by the book is well
suited for a wide range of readers. It explains enough theory and
provides useful examples that help to understand how to apply OOP in
practice. People new to Python and/or OOP have a lot to gain from reading <a href="http://www.amazon.com/gp/product/B005O9OFWQ?tag=3322-20">Python 3 Object Oriented Programming</a>. More experienced users of the language may find the book ideal as
reference material.<br />
<br />
It's important to note that the book focuses
on OOP particularly in the context of Python. Don't expect any history
lessons or theory on various OOP approaches (prototypes vs. classes,
ie.) beyond the one (class based approach) used in Python. Despite this
the book provides excellent value. I do recommend checking out several
other languages (Java, Lua, JavaScript, Smalltalk) and paradigms (AOP,
traits) for further inspiration.<br />
<br />
You can get a <a href="http://www.amazon.com/gp/product/B005O9OFWQ?tag=3322-20">copy here >></a>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-39753258726317150022013-01-08T06:09:00.002-08:002013-01-08T06:11:38.563-08:00Gray Hat Python for Windows<a href="http://www.amazon.com/Gray-Hat-Python-Programming-Engineers/product-reviews/1593271921?tag=3322-20" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="200" src="http://akamaicovers.oreilly.com/images/9781593271923/cat.gif" width="151" /></a>In my career, Python was the first programming language that I have
learned. I then learned programming in Java and C++. I looked back to
Python for it's simplicity and versatility. That is why I decided to
pick up <a href="http://www.amazon.com/Gray-Hat-Python-Programming-Engineers/product-reviews/1593271921?tag=3322-20">Gray Hat Python for Windows</a> to learn what Python can do in hacking and reverse
engineering since that is something I am interested in.<br />
<br />
The
author's writing style is clear, direct, and mature. The format of the
book is clean and well structured which makes it easier to maneuver.
The problem I had with the book was that the code in the book is
unreliable. The code in the book and the code in the website do not
match. Also, the book is Windows oriented which may be a disappointment
for some people.<br />
<br />
Overall, there was an abundance of valuable
information in the book that grabbed my attention such as fuzzing and
the debugging. The book covers a lot of subjects such as debugging,
hooking, code injection, and more. The author does a very good job with
consolidating the information in the book.
Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-63582579984748716722012-12-09T10:24:00.001-08:002012-12-09T14:55:36.509-08:00Running a Script in a Loop without CronThere are times when using cron is an over kill for a small task so it makes sense to whip up a small script and use one of the many system commands to repeatedly call it in a loop. BTW, if you have a better way of accomplishing this, I would like you to share it.<br />
<br />
That said, here's is an example. I wanted to perform a copy task every 12 minutes whilst working on a sample project. One quick option is to use the watch command - but if you find yourself requiring more cycle then a while loop would also help. But for now, this seems to get the job done. Not the best... hey, but it did what I required <br />
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;">while [ 1 ]
do
cp source dest
sleep 12
done
</pre>
Surprisingly, this worked quite well allowing me to take control of the script an its execution without resorting to the cron system. Nice and handy tip.<br />
<br />
Now over to you - how would you run a script every specified minutes without using cron. Please post your thoughts in the comments.<br />
<br />
On a totally different topic: I just finished my second Twitter app for another client. That brings together a total of 5 custom apps I've developed for private clients in the last 2 years. <br />
<br />
This last one took me less than a day to finish it. They wanted a specific feature which was the only thing that took me a bit of backwards and forward to finally finish. So, this weekend I did quite a bit more than I wanted, and I'm pleased with myself.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-24566058664344151082012-11-09T01:30:00.001-08:002013-01-12T11:15:20.362-08:00oDesk Making Freelancing EasierWe all like it when companies pay you for doing what you do everyday. This is what <a href="http://odesk.com/python" onmousedown="this.href2 = this.href;
this.href = 'http://javawug.org';" onmouseout="if(this.href2) this.href = this.href2;">oDesk</a>.
is doing lately. They have changed the way their freelancing process works - which means you can now pick more than 5 jobs at a time. These are good paying tasks that any self-respecting software person out there can do.<br />
<br />
The even have videos to show you how to get started. I thought I should post it here because in the last couple of weeks, I've been seeing lots of traffic to this blog - all looking for information on getting started with <a href="http://odesk.com/python" onmousedown="this.href2 = this.href;
this.href = 'http://javawug.org';" onmouseout="if(this.href2) this.href = this.href2;">oDesk</a>.<br />
<br />
If however, you already know how their new system works, you may also want to <a href="http://hubpages.com/_gxctwh0owmn4/">check out Hubpages</a> as well. I've only spent a few months on and off getting to know the site well.<br />
<br />
Which ever works for you, please leave a comment below and would like to know your thoughts.<br />
<br />
Anyway, I recently got a notification that 21st Century C has been released. As a former C programmer, I thought I should get a copy.<br />
<br />
This book is ok, it does not present any thing new other than talk about different approach you could take today to solve the problems you had decades ago. C has not changed, but programming techniques, technology and design patterns have evolved - so that's basically what this book is all about. One thing though that this book has going for it is the POSIX standard that its used through out.<br />
<br />
So, if you are looking to brush up your C experience, you might find this book quite useful. And writing C code that is portable across many different platforms will not be an issue because this book focuses on standard C.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-73435749427178520132012-11-04T13:25:00.003-08:002012-11-06T05:48:36.835-08:00Simple XML Processing with DOM and SAXIt's been a while since I last had any need to process XML on the browser. Most of my processing of late has been on the server side which takes care of all the necessary work.<br />
<br />
So, this evening, it was nice when I one of the Django application I have been working on required a fair amount of XML processing. In an effort to move some of the load to the client, I have decided that some of the job should only be performed when the require it.<br />
<br />
What the application does is that it uses Geo and IP-mapping to detect where the visitor is and then provide them with the appropriate XML. The next stage is to process that XML. So, to give you a very simple of how that XML is processed, I have included here both the XML and the DOM script for it.<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;"> var doc = null;
function loadXML() {
doc = document.getElementById("XMLIsland")
}
function DoIt() {
var output = ""
var records = doc.documentElement.childNodes;
for ( var i = 0; i < records.length; i++ ) {
townName = records.item(i).firstChild.firstChild.nodeValue;
tempValue = records.item(i).lastChild.firstChild.nodeValue;
output += "
Temperature in " + townName + " is " + tempValue;
}
document.getElementById("output").innerHTML = output;
}</pre>
I'm not sure why blogger is deciding to strip out all the formatting in my code above. But will fix it and try to show the code in full.
It would be nice to show how you too could move some of your backend processing to the client.<br />
<br />
As it turned out, the stripping of HTML tags is also happening o my JRoller page as well - where I originally attempted to post this blog.<br />
<br />
Will update it when I find a solution.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-16552612449267051962012-08-19T12:23:00.005-07:002013-01-26T04:12:23.250-08:00Updated My Twitter Script Today To Run In PythonSunday evening and not much to watch on the telly, so I thought I should go back to a few of the Java programs I wrote years ago and bring them into the 21st century. Wel, if you are not currently programming in Python or Django, I consider that as someone who is still hiding in a cave in the 20th century :-)<br />
<br />
So, what better way to bring them up to date than to give then a full rewrite in Python. For me, the flexibility, syntax and power of Python is what really made me rewrite it. I love Python - having used it on many projects in the last few years, it's quite easy for me to introduce new developers into programming with Python.<br />
<br />
However, today, the Java program I rewrote today was a Twitter program that ran from a shell. Taking search input from the user, connects to remotely to Twitter website, and collect the 10 most recent tweets containing the terms. It then goes ahead and prints the time, user name, the tweet containing our search term.<br />
<br />
Today I added a few more features. It's now possible to configure it run continuously using your keyword, when a new tweet comes in containing the keyword, it can either send them a reply tweet, send you an SMS, email you or simply log all the tweets into a database which you can later analyse.<br />
<br />
The cool thing about the latest script is that everything is run from a shell. Supply the necessary parameters and away you go. I got these ideas from <a href="http://odesk.com/java" onmousedown="this.href2 = this.href;
this.href = 'http://javawug.org';" onmouseout="if(this.href2) this.href = this.href2;">oDesk</a> when I used to take on on the side programming gig there. So, if you have a few hours in the evenings and on weekends, check them out for some cool and exciting <a href="http://odesk.com/python" onmousedown="this.href2 = this.href;
this.href = 'http://javawug.org';" onmouseout="if(this.href2) this.href = this.href2;">quick programming task</a>.<br />
<br />
If anyone wants to poke around the code and probably help in polishing is a bit more or add new features, please let me know.<br />
<br />
Now, I'm going for a Sunday evening bike ride I've been indoors since Friday night.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-68209406317604158232012-08-05T09:53:00.005-07:002017-04-13T01:44:35.949-07:00How To Check Your Django Version In UbuntuIf you have been working with Django for sometime, you will have noticed how fast the framework development has been going. So, once in a while you need to check that you are not using a very old version.<br />
<br />
It is quite easy to upgrade, but believe me, some people never bother at all. There are different reason for not upgrading, - either you have some production code that rely on specific packages in that version - and upgrading means that you will need to rewrite all those code, or you are simply just too lazy to do it.<br />
<br />
But if however, you want to know what version is running on your server, simply running this command should do the trick.<br />
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;">helen@helen-server:~$ python
Python 2.7.3 (default, Apr 20 2012, 22:44:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.4'
>>></pre>
<br />
As you can see from the output above, our current version is <b>1.4</b>, which at the time of this blog post was the latest version.<br />
<br />
If you see that your version is a bit older, then simply upgrade by using this command.<br />
This is best simply because it is short and easy to remember for beginners out there.<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;">% sudo apt-get upgrade django<span class="com" style="background-color: transparent; border: 0px; color: #880000; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;"></span></pre>
<br />
<br />
Enter your root password and the upgrade will commence.<br />
<br />
<b>On a different note though:</b><br />
<br />
This is for starters - but if you are interested, then see the Free GitHub <a href="http://fiveholiday55.blogspot.com/2012/05/free-github-tutorial-videos.html">Tutorial Videos</a> here. But please mind the photos of the naked ladies :) You might also want to check oDesk as for freelancing opportunity if you have free time and would like to earn yourself some income in the process.<br />
<br />
You may want to make some cool cash right now as a developer on oDesk simply by helping people with the programming problems. If Java is not your thing, then check out Python or any other programming languages.<br />
<br />
<b>Update: </b>it is interesting that since 2012 when this post was first published here, a number of people have found it useful enough that the amount of traffic to this post is fourth on the list of the highest read post on this blog. It goes to show that even a small tip on how to accomplish something can be quite useful.<br />
<br />
I guess you can also check the version of your installed Django on any platform with the command above - it doesn't necessarily have to only be on Ubuntu. I was primarily working on Ubuntu back then when this post was written so simply checking your Django version on any platform should work regardless.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-3147428676005340732012-07-01T10:37:00.005-07:002012-07-01T12:39:06.969-07:00How to Discover Your Linux ConfigurationOk, it has been a while since I posted something here. Been busy with stuff that I will be writing about later, they are mostly programming related stuff. All those weekend projects and small time affiliate marketing stints.<br />
<br />
I have also written <a href="http://hhelen.hubpages.com/_gxctwh0owmn4/hub/4-Guaranteed-Ways-to-Make-Money-Online">my response to this post</a> for which I will post later this evening. But until then, I just wanted to show you a small Linux tip for those who use Linux for hosting for as their desktop.<br />
<br />
This particular tip is quite handy if you've ever wanted to know more about the version and configuration of your Linux server.<br />
<br />
There are a lot more commands that can do the same thing, but this very tip from Hazem Saleh is one of the best simply because it short and easy to remember for beginners out there.<br />
<br />
<pre class="wp-code-highlight prettyprint" style="background-color: #f4f4f4; border-bottom-left-radius: 3px; border-bottom-right-radius: 3px; border-top-left-radius: 3px; border-top-right-radius: 3px; border: 1px solid rgb(204, 204, 204); color: #555555; font-size: 12px; line-height: 16px; margin-bottom: 6px; margin-top: 6px; outline: 0px; overflow: auto; padding: 2px 7px; vertical-align: baseline; width: 576px;"><span class="pln" style="background-color: transparent; border: 0px; color: black; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">cat </span><span class="pun" style="background-color: transparent; border: 0px; color: #666600; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">/</span><span class="pln" style="background-color: transparent; border: 0px; color: black; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">etc</span><span class="com" style="background-color: transparent; border: 0px; color: #880000; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">/*-release</span></pre><br />
Just fire up a terminal and enter this simple command:<br />
<br />
This will print out your server specification. Give it a try now.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-22556552433726287362012-05-03T06:38:00.010-07:002012-05-12T04:27:27.189-07:00Free GitHub Tutorial VideosI know this is a little late, but I was going through some of the videos I saved on my iPad and thought I should post the links here. By the way I'm writing this on my shiny new iPad to see how it works with Blogger. Will leave a full blog post on that till some other time. If you are interested, please see some of the links to the right on some reviews posted by my boyfriend.<br />
<br />
Anyway, here's the links - <a href="https://github.com/training/free" rel="nofollow" target="_blank">save or bookmark</a> it for any upcoming events. A lot of people attended that last Webinar which was a great fun. <br />
<br />
If you are new to Git and Github, you've been missing a lot. Github is the home of the world's most popular distributed revisioning system.<br />
<br />
<b>Update</b><br />
Sorry, the link is broken so had to be removed - will fix shortly.<br />
In the mean time you can check out <a href="http://amazon.com/git"
onmousedown="this.href2 = this.href;
this.href = 'http://www.anylabs.com';"
onmouseout="if(this.href2) this.href = this.href2;">these books</a> on Git.<br />
<br />
<br />
You can still find some videos over <!--<a href="http://vimeo.com/35539203" rel="nofollow" target="_blank">here</a> and <a href="http://vimeo.com/34273537" rel="nofollow" target="_blank">here</a>-->.<br />
Until next time,<br />
happy programming!Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-64484114781124021772012-03-17T16:36:00.000-07:002012-03-17T16:36:52.175-07:00Cracking the Coding Interview: 150 Programming Questions and Solutions - Great for prepping for CS StudentsCracking the Coding Interview: 150 Programming Questions and Solutions is NOT a coding review. However, as a Computer Engineering student, I found that it offered really awesome concept review.<br />
<br />
I'm looking forward to getting some money together and ordering it from Amazon; a friend of mine lent me a copy of it, and I just absolutely LOVE it. I'm currently in my second round of interviews for my dream job - and honestly, this book really gave me the confidence to pull it off.<br />
<br />
Even if you have to borrow a copy to "try" it, I seriously recommend it to all of my friends/classmates who are currently in the interview process.<br />
<br />
My Breakdown:<br />
<br />
Pros: Great general concept review! If you haven't coded in a while, or (like my university) you found that you didn't get much of an overview for a certain concept, then this book will show you algorithms and solutions to questions that you Need To Know. Very practical and otherwise easy to navigate.<br />
<br />
Cons: I think it needs some sort of reference section. I realize that it isn't a reference book, but seeing as it appears to be more of an overview for what you Need To Know, I found that most of my review came from looking at the solutions in the back of the book to brush up on concepts I hadn't formally been introduced to or that I'd forgotten.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-85319344387382078102012-02-18T02:03:00.004-08:002012-05-12T14:37:01.849-07:00The Start-up of You: Adapt to the Future, Invest in Yourself, and Transform Your CareerSteve Jobs once called Apple the "biggest start-up on the planet". Because of its success at systemizing disruptive innovation, it is the most scrutinized company in the world, especially by its competitors. As secretive as Apple is, there are plenty of books and articles that examine Apple's culture in great detail. So why are most companies -- especially large, established corporations -- incapable of applying these principles themselves?<br />
<br />
I bring up this question because the first time I read this book, I was disappointed. So many of the strategies seemed so intuitive, so obvious, that I didn't feel like I had gleaned as much insight as I had hoped. But as I looked over my highlights, I realized that, like Apple's competitors, I'd missed the point.<br />
<br />
What you need to adapt to the changing world of work aren't cheap tactics and off-the-wall ideas and quick fixes to hack your career. Often, the best ideas *do* seem obvious and familiar. But what is less obvious and less familiar and, thus, is arguably more important and more useful, is a framework or blueprint or system that makes it easier to build the habits required to consistently and sustainably implement those ideas with every decision you make, day in and day out.<br />
<br />
The framework this book offers is this: you must think and act like you're running a start-up.<br />
<br />
But what does that mean? Here's an example. One deceptively simple philosophy in the book is the idea of helping first -- that you should find ways to create value for others before seeking value for yourself. It's so simple and obvious that it's easy to gloss over it, and yet, it is fundamental to every successful entrepreneur or start-up in the world, because you'll never get a single customer until you solve a problem for someone.<br />
<br />
So how does one apply this philosophy? Here's what Reid does: whenever he gets the chance, he asks a simple question again and again and again: "How can I help?" Think about it: It sounds simple, and yet most people don't approach their careers or their relationships with this empathetic mindset. How often do you find ways to solve problems for the people around you? And if it isn't often, how do you change that? What habits does Reid have that you need to do this, too?<br />
<br />
"The Start-up of You" will give you Reid Hoffman's -- and Silicon Valley's -- secret sauce, but it's not enough to know it, just like it isn't enough for Apple's competitors to know its philosophies. You have to understand that an entrepreneurial mindset requires different habits of thought and action. This is what the authors mean when they say you have to think and act like you're running a start-up. If you were running a start-up, how would you create a culture that instills the habits of thought and action you want your people to have?<br />
<br />
Well, it turns out you *are* running a start-up: your career. How do you train yourself to have the habits of thought and action you need to thrive in the 21st century?<br />
<br />
Or, put another way, what would an entrepreneur do?Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-87547498006015382722012-02-13T23:20:00.002-08:002012-02-13T23:20:46.738-08:00Coding Bundle (jQuery, JavaScript, CSS)This bundle includes three eBooks that will help you master the various areas of CSS, JavaScript and jQuery. Get the full hang of CSS: be it layouts, !important declarations, advanced CSS selectors, CSS specificity and inheritance, media queries or experimental CSS properties. The CSS eBook is a full compendium of advanced CSS techniques for professional Web developers.<br />
<br />
Improve your JavaScript knowledge with valuable lessons from practice and learn your way around the new jQuery techniques. Of course, all three eBooks are available in PDF, EPUB and MobiPocket formats.<br />
<br />
“Mastering CSS” (eBook, 365 pages)<br />
Are you stumped by the rather sophisticated nature of CSS? Getting a grip on this still dewy technology isn’t quite as hard as you might think. Connecting the dots is easier when you have all the vital facts within reach. And that’s what “Mastering CSS” is all about. This eBook offers 15 hand-picked articles that overflow with professional advice and that reflect the deep experience of the Smashing Magazine authors you trust — authors who know exactly what they’re writing about.<br />
<br />
Stop hiding behind cross-browser compatibility issues, and launch a counterstrike. Tame those advanced CSS selectors; learn your way around CSS3 media queries; pioneer the field of CSS3 keyframe animations. Get in the game, and learn how to use advanced CSS typography, CSS3 pseudo-classes and modern CSS layouts, while devising back-up solutions for older browsers.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-22801735199587697422011-12-06T13:47:00.000-08:002011-12-26T01:55:37.613-08:00Pagination in PHPAs a developer, once in a while you come across a requirement in a project that requires you to go that extra mile. I recently moved from desktop development to web applications and have been enjoying the experience.<br />
<br />
However, there are a few things we are used to on the desktops that are not available on web applications - like pagination, tabbing, portability and ease of development.<br />
<br />
Whilst there are tons of examples of PHP Pagination online, only a few of them have a complete example that demonstrate how it actually works. The rest just show a little piece of code and tells you to figure out the rest yourself...nothing of real substance that you can adapt to fit your need. <br />
<br />
That said, I came across a nice jQuery version which does almost what I needed - problem is that I would need to learn to use jQuery to use this example. So, what this means is that I need to learn a new framework to learn to use another. Hmm, that's online tutorial for you.<br />
<br />
If you know of any good example of PHP Pagination, please leave a comment below and share it with us all.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-75142851454100004442011-11-20T10:53:00.002-08:002012-05-12T14:46:14.695-07:00You Should Get Yourself One of These Amazon Kindle FireAfter spending a few days with the Kindle Fire I have been very impressed. I don't think it will ever replace my e-ink kindle but it is a great little deice. I have owned multiple Kindles including the 2nd, 3rd, and 4th generation devices. I have also read on android Smartphones, an iPod touch, kindle for pc, and the cloud reader.<br />
<br />
PHYSICAL: I love the size of the Fire, it can be held with one hand although after a while the weight forces some positioning adjustments. It is about the size of the past (non DX) kindles and around the size of a DVD case. The power button seems to be poorly placed in the center of the bottom of the device; Right where I want to put my hands. I frequently hit/hold the power button unintentionally. The speakers are surprisingly good for a device of this size although the max output could be louder. I miss the physical page forward/backward buttons of the earlier kindles and volume up/down buttons would make a nice addition. Overall, none of these problems are great enough to cause me to down-rate the device.<br />
<br />
SOFTWARE: The carousel on the home screen is interesting. It is a good idea but can be too sensitive and spin when I intend to select an item. The favorites on the home screen remain stationary and are easier to navigate than the carousel for frequently accessed items. I currently have my favorite apps and the books I am currently reading as well as those on the top of my list.<br />
<br />
NEWSSTAND: The pages of magazines are a little scrunched on the Fire's screen but zooming in helps a lot. I found that nearly half of my favorite magazines aren't available at all (yet). I don't tend to read magazines as much as I read books so this isn't a huge problem but for people looking at the Fire for magazine reading should check availability first.<br />
<br />
BOOKS: The functionality of the reading is more like reading on a cell phone than reading on a kindle. The biggest missing feature seen on e-ink kindles and missing here are collections. There is very little ability to organize your books here. You can view all books you own (Cloud) or all books on the device. You can sort these listings by title, author, or most recently viewed. Kindle.amazon.com has a way rating books, listing books as want to read/reading/read/abandoned. It would be great if the Fire accessed this data and allowed for better user management of the list. My list contains just under 200 books and over time that number will only grow. Once you find the book you are looking for (I keep the ones I am currently reading and plan to read next in my favorites) reading is a simple and pleasant experience. The title of the current book is written at the top of the screen and other than that the only thing displayed during reading is text. A single tap in the center of the screen brings up the time, battery, network status, how far you have read, and various other buttons. The display color, margins, spacing, font size, and typeface can be changed through the menu. Font size cannot be changed by pinching.<br />
<br />
MUSIC: The music plays well and can be organized into playlists. The music features are most useful if your music is on the amazon cloud drive. But music, and everything else in the cloud, can't be accessed when outside of wireless. <br />
<br />
VIDEO: Watching free and purchased videos is a great experience on the Fire. Keeping track of the free Prime videos I want to watch is much more difficult. There is no queue or to watch list so every time you want to watch you have to search around for what you are looking for. <br />
<br />
APPS: What's not to love about a free app every day? Some great android apps are still missing here but there are a lot of great options available and hopefully the list will grow.<br />
<br />
Overall the Fire is a great product at a great price. A 3G options would be very nice.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-40510520857718104652011-11-20T06:10:00.001-08:002012-05-27T07:18:21.353-07:00Boomerang: Travels in the New Third WorldBoomerang: Travels in the New Third World - Michael Lewis spins an entertaining yarn, traveling about the world and joking about the personality traits that led to the varying economic disasters of 2008. One can learn a certain amount about what transpired in each country, but the strictly factual material in this book could probably be spelled out in less than ten pages.<br />
<br />
The bulk of the book is composed of amusing vignettes and Lewis's attempts to define each country's travails in terms of broad cultural stereotypes. The Icelandic crash, for example, follows from the that that Icelandic men think they are Vikings and don't listen to women.<br />
<br />
The Greek crash results from their inability to trust each other. The German problem comes from their trust in process and their fascination with fecal matter (I am not making that up).<br />
<br />
I don't know that my understanding of the world has been advanced by this book, though the book is an enjoyable, quick read.Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-8472177.post-88020140647216516682011-10-29T03:42:00.002-07:002012-05-27T07:20:18.575-07:00My Review of Steve Jobs by Walter IsaacsonI just finished reading Steve Jobs. Wow! I must say I'm breathless (once again). With the number of reviews already published, I'll focus on a few key points that made an impression.<br />
<br />
1. Walter Isaacson tells a very engaging story. His narrative captivated me from the get-go. He elegantly wove the various angles of Jobs's work through the time-line, which wasn't an easy task when you consider all the projects that were developed concurrently. It's a magnificent read.<br />
<br />
2. I found it interesting to read "Jobs in his own words." It was hilarious to discover how much he and Bill Gates cursed - something I could have guessed but was never made explicit in other works about him. <br />
<br />
3. There wasn't all that much new information. I don't know if it's because of my interest in Steve over the past few years, but I already knew most of the content presented in the book. There were not that many "Damn, I was wondering about that!" moments during my read.<br />
<br />
4. The book lacked a lot in terms of Jobs's personal life. I expected to read a lot more about it, given that Isaacson was an "authorized" biographer. I believed I would find more extensive interviews with the children and his wife. They appear to be completely peripheral to Jobs's life, although the book doesn't allow me to conclude that at 100%.<br />
<br />
In summary, it's a great book on Steve Jobs. If you want to know more about the showmanship of Steve, there will be more interesting options on the market. I give it 5 stars because it is truly a fantastic read.Unknownnoreply@blogger.com2tag:blogger.com,1999:blog-8472177.post-7322320154872482482011-10-27T12:56:00.000-07:002011-10-27T12:56:40.276-07:00Clean Code: A Handbook of Agile Software CraftsmanshipThere is nothing particularly new in this book. It just discusses how to write "clean code" -- the code that is really easy to understand and maintain. Nevertheless this book is worth reading just to remind you another time how important "clean code" is!<br />
<br />
This book provides lots of concrete advice how to make your code "cleaner". It discusses importance of proper naming, code formatting and testing. It stresses importance of constant refactoring and provides several extended refactoring examples. But the most important advice the book gives is to always commit better code then you have checked out.<br />
<br />
Some advices given in the book can be disputed. Some chapters are weaker (in particular chapters on concurrent programming are quite superficial). Still overall book is definitely worth time spent reading it.Unknownnoreply@blogger.com0