<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<?xml-stylesheet type="text/css" href="http://www.physics.drexel.edu/~wking/blog/styles/feed.css"?>
<title type="html">Programming</title>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog" />
<link rel="self" type="application/atom+xml" href="http://www.physics.drexel.edu/~wking/blog/archives/programming/index-atom.xml" />
<updated>2010-08-27T23:15:17-04:00</updated>
<author>
<name>Trevor</name>
<uri>http://www.physics.drexel.edu/~wking/blog</uri>
</author>
<id>http://www.physics.drexel.edu/~wking/blog/</id>
<generator uri="http://nanoblogger.sourceforge.net" version="3.3">NanoBlogger</generator>
<entry>
<title type="html">SiteCorePy</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2010/06/24/index.html#e2010-06-24T15_52_08.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2010/06/24/index.html#e2010-06-24T15_52_08.txt</id>
<published>2010-06-24T15:52:08-04:00</published>
<updated>2010-06-24T15:52:08-04:00</updated>
<category term="Programming" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>As the Physics webmaster, I'm in charge of transitioning most of the
static department content into SiteCore, as the powers that be get
wise to the ways of version control.  Unfortunately, I'm not the
biggest fan of SiteCore.  Major gripes include:</p>

<ul>
<li>Poorly conceived versioning.  Some things are versioned, some things
aren't.  No tools (that I've found yet) for analyzing history except
on a per-page scope.  Also, can only commit changes at the page
level, which makes a single "I added alt tags to all my images"
commit impossible.</li>
<li>Browser-only interface.  That's right, no scriptable API short of
driving a browser through a script.  This one is so huge, I'm not
really sure what else to say.  Surely people occasionaly want to do
something that the designers hadn't planned for, like, oh, importing
data from a preexisting database.</li>
</ul>

<p>Anyhow, to overcome the major limitation, I'm <a href="http://www.physics.drexel.edu/~wking/code/git/git.php?p=sitecorepy.git">driving my browser
through a
script</a>.
Thanks to the magic of
<a href="http://code.google.com/p/selenium/wiki/GettingStarted">WebDriver/Selenium</a>
for making this possible.</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">Reading IGOR binary waves from Python</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2010/06/04/index.html#e2010-06-04T14_48_46.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2010/06/04/index.html#e2010-06-04T14_48_46.txt</id>
<published>2010-06-04T14:48:46-04:00</published>
<updated>2010-06-04T14:48:46-04:00</updated>
<category term="Programming" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>I finally got around to translating some IBW readers from C to Python.
And so, I present (drumroll :)
<a href="http://www.physics.drexel.edu/~wking/code/hg/hgwebdir.cgi/hooke/file/tip/hooke/driver/igorbinarywave.py">igorbinarywave.py</a>.
Python because it's easy to drop it into my other Python projects (in
this case, <a href="http://code.google.com/p/hooke/">Hooke</a>).  It's also easy
to get a hold of all that useful metadata in a hurry.  No writing
ability yet, but I don't know why you'd want to move data that
direction anyway ;).</p>

<p>Thanks to the folks at <a href="http://www.wavemetrics.com/">WaveMetrics</a> for
publishing some good
<a href="ftp://ftp.wavemetrics.net/IgorPro/Technical_Notes/TN003.zip">documentation</a>,
even if it's in a goofy format.</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">Website unittesting with Selenium</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2009/10/21/index.html#e2009-10-21T10_00_56.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2009/10/21/index.html#e2009-10-21T10_00_56.txt</id>
<published>2009-10-21T10:00:56-04:00</published>
<updated>2009-10-21T10:00:56-04:00</updated>
<category term="Programming" />
<category term="Linux" />
<category term="Fun" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>I just discovered <a href="http://seleniumhq.org/">Selenium</a>, which allows you
to drive browers programmatically.  This allows you to test the
effects of javascript on the browser's internal page representation.
Not very useful for the department website, since we don't use much
javascript, but I like its python interface, so I'm replacing my
traditional spider with a Selenium implementation.</p>

<p>Some bugs I've run into so far:</p>

<ul>
<li><a href="http://jira.openqa.org/browse/SRC-758">start() doesn't take any
args</a>.  Simple fix in
selenium.py.</li>
<li><a href="http://jira.openqa.org/browse/SRC-721">captureNetworkTraffic("xml") returns requestHeaders as
responseHeaders</a>.  Fixed in
source, but you'll need to compile your selenium-server.jar on your
own.  There's a nice, detailed explaination of building Selenium
with <a href="http://maven.apache.org/">Maven</a>
<a href="http://wiki.openqa.org/display/SRC/Developer%27s+Guide">here</a>, but
for the impatient, a simple <code>mvn install</code> in the svn root directory
should do it.</li>
<li><a href="http://jira.openqa.org/browse/SRC-759">captureNetworkTraffic("xml") captures invalid XML in URL's
(ampersand problem)</a>.
Another simple patch, but this one's just posted by me, so you'll
have to apply it by hand and recompile.
You get the feeling that people don't use the captureNetworkTraffic
side of Selenium very often ;).  Ah well, only 3 open bugs in that
area left to bump into ;).</li>
</ul>

<p>To keep the test suite easy to maintain, I build it on the fly using
<a href="http://somethingaboutorange.com/mrl/projects/nose/0.11.1/writing_tests.html#test-generators">nose
generators</a>,
which are awesome :).</p>

<p>More details to come...</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">Elsevier and LaTeX</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2009/10/05/index.html#e2009-10-05T09_01_49.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2009/10/05/index.html#e2009-10-05T09_01_49.txt</id>
<published>2009-10-05T09:01:49-04:00</published>
<updated>2009-10-05T09:01:49-04:00</updated>
<category term="Programming" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>Recently I've been writing up an article for one of the
<a href="http://www.elsevier.com/">Elsevier</a> journals using their
<a href="http://www.elsevier.com/wps/find/authorsview.authors/elsarticle">elsarticle</a>
LaTeX package.  Unfortunately, their BibTeX style file,
elsarticle-num.bst (version 1.1, 2008-10-13), is a bit broken.  With
the help of Nicolas Markey's excellent <a href="http://www.ctan.org/tex-archive/info/bibtex/tamethebeast/">Tame the
BeaST</a>,
I've <a href="/~wking/tools/elsarticle/elsarticle-num.bst">fixed it up</a>, so it
runs without errors (!), works with
<a href="http://www.ctan.org/tex-archive/help/Catalogue/entries/natbib.html">natbib</a>'s
<code>\citet{}</code>, and conforms with the examples posted in the
<a href="http://www.elsevier.com/wps/find/journaldescription.cws_home/525446/authorinstructions#68000">International Journal of Biological Macromolecules' author
guide</a>.</p>

<p>Update: Oct. 6.  Turns out <a href="http://www.elsevier.com/wps/find/authorsview.authors/elsarticle">the code linked from
Elsevier</a>
is out of date.  Rishi over at
<a href="http://www.river-valley.com">River-Valley</a> (writers of the elsarticle
package) pointed me to some <a href="http://support.river-valley.com/wiki/index.php?title=Elsarticle.cls">more up to date documentation and
source</a>.
Version 1.2 fixes most of my problems (with elsarticle-num-names.bst),
but I'm still not sure why it doesn't replace elsarticle-num.bst
entirely...</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">Email interface to bugs everywhere</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2009/07/18/index.html#e2009-07-18T17_25_18.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2009/07/18/index.html#e2009-07-18T17_25_18.txt</id>
<published>2009-07-18T17:25:18-04:00</published>
<updated>2009-07-18T17:25:18-04:00</updated>
<category term="Programming" />
<category term="Linux" />
<category term="Fun" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>I've been amusing myself over the past few days working up an email
interface for the distributed ugtracker <a href="http://bugseverywhere.org">Bugs
Everywhere</a>.  One of the things we've been
struggling with with BE is how end users should submit
bugs/comments/etc, since</p>

<pre><code>$ apt-get install bzr
$ bzr branch http://whatever/remote/repo local_repo
$ cd local_repo
$ be new "The demuxulizer is broken"
Created bug with ID 48f
$ be comment 48f
&lt;Describe bug&gt;
$ bzr send --mail-to "whatever-dev@fancyprojects.com"
</code></pre>

<p>mostly just raises eyebrows among non-devs ;).  My interface replaces
it with</p>

<pre><code>$ cat | mail -s "[be-bug] new" "whatever-dev@fancyprojects.com"
The demuxulizer is broken

&lt;describe bug&gt;
^D
</code></pre>

<p>Which will hopefully be more user friendly.  Of course, most non-devs
I know (and some devs) avoid the command line like the plague, so we
will still want a web-frontend.  Luckily, web frontends seem popular
with other devs, so I don't have to bother with that ;).</p>

<p>Curious parties can branch my public repo:</p>

<pre><code>$ bzr branch http://www.physics.drexel.edu/~wking/code/bzr/be-email be.email
</code></pre>

<p>As a nice side effect of this little project, my
<a href="/~wking/code/python/send_pgp_mime"><code>send_pgp_mime</code></a> is now much more
elegant.</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">inotify</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2009/03/31/index.html#e2009-03-31T18_21_54.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2009/03/31/index.html#e2009-03-31T18_21_54.txt</id>
<published>2009-03-31T18:21:54-04:00</published>
<updated>2009-03-31T18:21:54-04:00</updated>
<category term="Programming" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>I just discovered <code>inotify</code> and it's command-line incarnation
<code>inotifywait</code> (in
<a href="http://packages.debian.org/lenny/inotify-tools">inotify-tools</a> on
Debian).  Now I can watch the data come in from home.  If only I had
the laser- and photodiode-alignment screws motorized...  Anyhow,
checkout <a href="/~wking/code/#monfold">my script</a>.</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">Atomgen</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2009/03/28/index.html#e2009-03-28T01_48_23.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2009/03/28/index.html#e2009-03-28T01_48_23.txt</id>
<published>2009-03-28T01:48:23-04:00</published>
<updated>2009-03-28T01:48:23-04:00</updated>
<category term="Programming" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>I've been using <a href="http://en.wikipedia.org/wiki/Atom_%28standard%29">Atom
feeds</a> to publish
announcements to my course websites recently.  The ‘please check this
page daily for changes’ directives I saw on a few other pages were too
painful to bear ;).  I've written a little PHP script to convert the
atom.xml into XHTML so non-atom students can still read the
announcements online, and I've been using
<a href="http://rss2email.infogami.com/">rss2email</a> in a cron job and a
<a href="http://www.procmail.org/">procmail</a> rule to automatically email the
class any new announcements I post in the feed.  It works rather well
I think, even if noone ends up actually looking at the feed ;).</p>

<p>Anyhow, I wrote up a little command line wrapper around Sylvain
Hellegouarch's <a href="http://pypi.python.org/pypi/atomixlib/">Atomixlib</a>,
which is based on <a href="http://xml3k.org/Amara/">Amara</a> or
<a href="http://pypi.python.org/pypi/elementtree/">ElementTree</a>.  However,
Sylvain seems to be falling behind as ElementTree and Amara continue
to evolve, so I recently rewrote my script to run off
<a href="http://xml3k.org/Amara2">Amara2</a> directly, since Amara's <em>bindery</em>
interface is wonderful (well, for data manipulation anyway.
Attributes, prefixes, and tree construction don't make much sense to
me yet...).</p>

<p>You can grab my script and see some simple usage examples on my <a href="http://www.physics.drexel.edu/~wking/code/#atomgen">code
page</a>.</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">Command line PGP/MIME</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2009/02/04/index.html#e2009-02-04T06_39_37.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2009/02/04/index.html#e2009-02-04T06_39_37.txt</id>
<published>2009-02-04T06:39:37-04:00</published>
<updated>2009-02-04T06:39:37-04:00</updated>
<category term="Programming" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>I've been scripting up a few things recently and my inability to send
nicely formatted PGP/MIME messages was starting to really bug me.  I
had been encrypting my logwatch output with gpg and just emailing the
raw gpg out to myself, but it's annoying to have to ESC-P every time I
want to decrypt a log.  The tipping point came while I was writing up
a script to automatically email grades out to my students (not that
any of the student's care about PGP, but it's the principle of the
thing ;), since there's no way I'm going to send them raw gpg output
(they would die) and there's also no way I'm going to hold Mutt's hand
while it signs the emails.  I dunno why Mutt doesn't have some --batch
mode options to support PGP, but there it is.</p>

<p>So I wrote my own.  Not very complicated really, just implementing the
<a href="http://www.ietf.org/rfc/rfc3156.txt">RFC 3156</a> specs.  There's
obviously room for improvement, but it works well enough to make me
happy at the momemt.  You're welcome to <a href="/~wking/code/python/send_pgp_mime">take a
look</a> and email me with
[encrypted!] feedback.</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">Splittable **kwargs</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2008/12/20/index.html#e2008-12-20T21_40_44.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2008/12/20/index.html#e2008-12-20T21_40_44.txt</id>
<published>2008-12-20T21:40:44-04:00</published>
<updated>2008-12-20T21:40:44-04:00</updated>
<category term="Programming" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>Ah, it has been a while, but I am excited about a new python module I
wrote so I shall post again ;).  Actually, there has been a lot of
Python learning over the past two months.  It started out when I felt
the need to setup a bug-tracker to keep track of all the things going
wrong with my cantilever calibration software :p.  Since I'm using git
for versioning, I naturally wanted a 'distributed bugtracker'.
Luckily there are a number of nice ones out there.  I've been using
<a href="http://bugseverywhere.org/be/show/HomePage">Bugs Everywhere</a>.  My other
favorite is <a href="http://ditz.rubyforge.org/">Ditz</a>, but I like being able to
hack away on BE in my familiar Python.</p>

<p>Besides helping keep track of my bugs, I've enjoyed hacking away at
BE.  In the process I've learned some cool tricks such as <a href="http://www.python.org/dev/peps/pep-0318/">Python
decorators</a> (see <a href="http://adam.gomaa.us/blog/the-python-property-builtin/">this
tutorial</a> for
some really neat examples) and <a href="http://www.debian-administration.org/articles/317">Bash
autocompletion</a>.</p>

<p>Meanwhile, the calibration code developed, and I was getting tired of
keeping assorted keyword arguments default in sync (how many times do
I have to repeat minFreq=500?).  The way to avoid repeating yourself
in this situation is to use <a href="http://docs.python.org/tutorial/controlflow.html#keyword-arguments"><code>*args</code> or
<code>**kwargs</code></a>
(see <a href="http://wiki.wxpython.org/wxPython Style Guide#line-42">wxPython's endorsement</a>).
I don't trust myself to keep my code in sync enough to use <em>args, so
lets focus on *</em>kwargs.  Consider the following example:</p>

<pre><code>&gt;&gt;&gt; def A(a=1):
...     return a
&gt;&gt;&gt; def B(b=2):
...     return b
&gt;&gt;&gt; def C(**kwargs):
...     return A(**kwargs)+B(**kwargs)
&gt;&gt;&gt; C(a=3,b=4)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "&lt;stdin&gt;", line 2, in C
TypeError: A() got an unexpected keyword argument 'b'
</code></pre>

<p>Hmm, how to split the kwargs into those for <code>A</code> and those for <code>B</code>?  So
I wrote the <a href="/~wking/code/#splittable_kwargs">splittable_kwargs
module</a>.  See the docstrings
for some usage examples and more info.  With my module the above
example becomes</p>

<pre><code>&gt;&gt;&gt; from splittable_kwargs import splittableKwargsFunction
&gt;&gt;&gt; @splittableKwargsFunction()
... def A(a=1):
...     return a
&gt;&gt;&gt; @splittableKwargsFunction()
... def B(b=2):
...     return b
&gt;&gt;&gt; @splittableKwargsFunction(A,B)
&gt;&gt;&gt; def C(**kwargs):
...     akw,bkw = C._splitargs(C, kwargs)
...     return A(**bkw)+B(**akw)
&gt;&gt;&gt; C(a=3,b=4)
7
</code></pre>

<p>In other news, my current side project is a MySQL-based, multi-user,
archiving, command-line grade database.  Down with web-forms ;).
More information to come as the project progresses.</p>]]>
</div>
</content>
</entry>
<entry>
<title type="html">PlotPick program</title>
<author>
<name>Trevor</name>
</author>
<link rel="alternate" type="text/html" href="http://www.physics.drexel.edu/~wking/blog/archives/2008/10/01/index.html#e2008-10-01T19_55_03.txt" />
<id>http://www.physics.drexel.edu/~wking/blog/archives/2008/10/01/index.html#e2008-10-01T19_55_03.txt</id>
<published>2008-10-01T19:55:03-04:00</published>
<updated>2008-10-01T19:55:03-04:00</updated>
<category term="Programming" />
<category term="Theory" />
<category term="Linux" />
<content type="xhtml">
<div xmlns="http://www.w3.org/1999/xhtml">
<![CDATA[<p>While calibrating my photodiodes, some of my surface bumps went out of
the linear-response range.  Since I'm not confident in my ability to
set boundaries programmatically at the moment, I thought I'd write up
a little utility to record clicks on key data points, so I could pick
out the “good data”.</p>

<p>Enter
<a href="http://www.physics.drexel.edu/~wking/code/index.shtml#plotpick">plotpick.py</a>,
the raw-data version of
<a href="http://www.physics.drexel.edu/~wking/blog/archives/2008/09/05/index.html#e2008-09-05T20_20_30.txt">clicklock.tk</a>.
Hope you like it :).</p>]]>
</div>
</content>
</entry>
</feed>

