tag:blogger.com,1999:blog-45715021879381315972024-03-12T18:29:38.451-07:00.*Unknownnoreply@blogger.comBlogger102125tag:blogger.com,1999:blog-4571502187938131597.post-37504238247111689622016-02-19T12:30:00.001-08:002016-02-19T12:30:25.541-08:00How much of the human sensorium are we able to record from a free-moving human?
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-66452658824054663182016-02-10T18:36:00.000-08:002016-02-10T18:36:15.195-08:00<div class="separator" style="clear: both; text-align: center;"><a href="https://3.bp.blogspot.com/-rl0qWUfRKH4/VrvyOof1sAI/AAAAAAAAAiM/21LxKfYjnkQ/s1600/on_the_rug-scaled.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://3.bp.blogspot.com/-rl0qWUfRKH4/VrvyOof1sAI/AAAAAAAAAiM/21LxKfYjnkQ/s320/on_the_rug-scaled.jpg" /></a></div>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-2754112399675996792016-02-10T17:35:00.000-08:002016-02-10T17:35:37.978-08:00<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-B9buDCxAXp0/Vrvk6MxMLcI/AAAAAAAAAh4/gcVmt0gn2K4/s1600/meswirl.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://1.bp.blogspot.com/-B9buDCxAXp0/Vrvk6MxMLcI/AAAAAAAAAh4/gcVmt0gn2K4/s320/meswirl.png" /></a></div>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-17257214324353621982016-02-07T15:49:00.000-08:002016-02-07T15:50:26.863-08:00A green blanket<div class="separator" style="clear: both; text-align: center;"><a href="https://1.bp.blogspot.com/-LtBj9j7cXFg/VrfX-6b0xTI/AAAAAAAAAhk/VxRrERaqRpc/s1600/20160207_094402.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://1.bp.blogspot.com/-LtBj9j7cXFg/VrfX-6b0xTI/AAAAAAAAAhk/VxRrERaqRpc/s320/20160207_094402.jpg" /></a></div>
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-30528920464557640022016-02-06T16:31:00.000-08:002016-02-06T16:31:17.234-08:00Sweetgum FruitI was out volunteering at a local math competition and wandered around a bit after the event. I stepped into a little courtyard and found a mess of these little guys and had to take a few photos. I didn't do any editing aside from some minor cropping and rotation -- I usually play around with color and sharp/focus, and go a little crazy with the image filters -- because I really loved the way the colors turned out.
<div class="separator" style="clear: both; text-align: center;"><a href="https://3.bp.blogspot.com/-cDb3Pnhx2II/VraLYgEMJQI/AAAAAAAAAg4/nRcNJHA8pFQ/s1600/20160206_150749_rotated.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://3.bp.blogspot.com/-cDb3Pnhx2II/VraLYgEMJQI/AAAAAAAAAg4/nRcNJHA8pFQ/s320/20160206_150749_rotated.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-46ocjzpqYyA/VraOZXtJIoI/AAAAAAAAAhI/wXB3Fjx9EQA/s1600/20160206_150723_rotated.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-46ocjzpqYyA/VraOZXtJIoI/AAAAAAAAAhI/wXB3Fjx9EQA/s320/20160206_150723_rotated.jpg" /></a></div>
<div class="separator" style="clear: both; text-align: center;"><a href="https://4.bp.blogspot.com/-NawyxzhIInE/VraOoARjRjI/AAAAAAAAAhM/aZTRK6xR8cE/s1600/20160206_150712_rotated.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://4.bp.blogspot.com/-NawyxzhIInE/VraOoARjRjI/AAAAAAAAAhM/aZTRK6xR8cE/s320/20160206_150712_rotated.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;"><a href="https://2.bp.blogspot.com/-1pAx949tQRc/VraOz66xhNI/AAAAAAAAAhQ/iL1f4H7sulQ/s1600/20160206_150808_cropped.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://2.bp.blogspot.com/-1pAx949tQRc/VraOz66xhNI/AAAAAAAAAhQ/iL1f4H7sulQ/s320/20160206_150808_cropped.jpg" /></a></div>
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br />This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-23652380178334379622015-12-27T18:20:00.001-08:002015-12-27T18:20:39.124-08:00<p>We conceive of limits to variation in animal behaviors and morphology. When we deduce something about the constraints acting on the development of an organism and on the evolution of a species we must distinguish between two kinds of <i>observed</i> limits. The first kind is a limit due to actual biological limitations, whether on embryological development, lack of viability (i.e., animals having the variation die before they can reproduce), or lack of fecundity. The second kind is a limit on what we as scientists can actually observe due to lack of a fossil record either for the animal as a whole or for the specific variation in question, or due to limitations in our methods or devices. The upshot of this difference is that the first kind of limit is fit for building our philosophy of nature while the second kind is misleading and has the power to render our predictive tools worthless.
<p>There are, of course, mitigations to the perfidy of the second kind of limit. For instance, we can determine in some cases that a variation, such as a distinctive birdsong sung by an ancient bird, would not be visible to our tools. In addition, constraints determined in one area may depend on constraints in another area which confound limits of the second kind. Ultimately, these ways of thinking lead to the practice of integrating heterogeneous models of living systems into a single model. The hope is that there is a dependence between parts of the system which constrain those variations which cannot be constrained through observation. In the limit, this approach frees us entirely from the "black swans" since it produces an emulation of reality. In the real world, however, where computational limitations prevent perfect copies of reality, there may yet be independent pockets of variability that we will always fail to pick up either in observations or in our models. <p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-17947697597830125112015-12-11T12:25:00.000-08:002015-12-27T18:24:52.056-08:00<div style="text-align: center;">
<a href="http://2.bp.blogspot.com/-XDxx2NXYEGM/Vmsw8BhnUHI/AAAAAAAAAgA/WwCPYocH86I/s1600/primary_square.jpg" imageanchor="1"><img border="0" src="http://2.bp.blogspot.com/-XDxx2NXYEGM/Vmsw8BhnUHI/AAAAAAAAAgA/WwCPYocH86I/s320/primary_square.jpg" /></a><br>
Colored Square.
© 2015, by Mark W.
</div>
~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-79379055187822904242015-07-20T19:14:00.002-07:002015-07-20T19:14:47.460-07:00Kinds of testsThese are my thoughts on software testing terminology. Some of these tests have definitions that float, and I want to get down my definitions, so that I can refer to them and refer people to them if there's any uncertainty about what I mean.
<dl>
<dt>Integration test<dd>A test of the boundary between components. An integration test in project A for components B confirms that the interface A expects of B matches up with the interface that B provides. Such tests make sense whenever component B is not available to A's developer at the time that she writes A.
<dt>Unit test<dd>A test of the primary functionality of a component and of the edge cases and error modes of the component. The component for which a unit test is written should not have untested sub-parts -- in other words, the unit test assumes that below the level of abstraction at which the test is performed, all components perform perfectly. It may be necessary to make "perfect" sub-parts (e.g., "mock" objects) to effectively test at the desired level of abstraction.
<dt>Acceptance test<dd>A test of a component against customer requirements. These are tests which must be passed for <em>acceptance</em> of the component by the customer.
<dt>Formal test<dd>A test of the mathematical abstraction of the software component against known failure modes which can be formally proven to occur, not occur, or possibly occur under a class of inputs.
</dl>
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-82284146238401525492015-07-19T05:06:00.004-07:002015-07-19T05:06:52.458-07:00Human communication protocols. You can't tell what type PDU you deal with sans reading a variable number of headers, the offsets for each header encoded, in prose, by a randomly selected preceding header. Then, when you finally get to the damn payload, too often there's virtually no content. Absurd.
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-45973513701453068222015-06-13T03:43:00.002-07:002015-06-13T03:44:09.405-07:00TV show substitutes for "fuck":
<ul><li>Frell - Farscape
<li>Frak/Frack - Battlestar Galactica (and many, many others)
<li>Rut - Firefly (actually refers to "a recurrent period of sexual excitement and reproductive activity" in modern English. <em>Collins English Dictionary</em>)
</ul>
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-7424913403403387822015-05-09T07:56:00.002-07:002015-05-09T07:56:57.931-07:00Where terrorism is taking usConsider that each attack demands that we become more careful of what we say and of what is published. We fear our fellows and their heritage. Our fundamental freedoms are restricted by the eroding influence of the attackers. Seeing the ways that the freedmoms provoke the terrorists, authority figures say, "We must take precautions around all free expressions which may offend the terrorists." The "may" allows room to expand the presence of protections -- never to contract. The terrorist will not moderate his stance by saying, "Such and such class of action is no longer offensive," but with each additional attack on a previously putatively excluded action, the fear makes a retraction by us, and not the terrorist, most natural. So, an unfettered growth in the presence of free-expression-police seems to be in effect. These police have as their mission to defend those freely and legally expressing their opinions from terrorists. Could these figures, however, be perverted such tthat the police inhibit free expression to pre-empt potential attackers? This danger could manifest in other ways, but in particular I think of the asymmetry of possible attackers to defenders, the definitional foundation of terrorism. That is, an attack will be effective with any success and most mentions of attacks among us, but police cannot continually protect all targets. In the face of this asymmetry, authorities may opt for reducing the number of targets -- restraining liberty. Is there an alternative response to terrorism that prevents a chilling of liberties while still effectively reducing the scale and volume of terrorist attacks?
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-29924163265731082702015-02-28T18:52:00.001-08:002015-02-28T18:58:02.840-08:00<p>Kind of a cool idea: a recorder that allows you to pin back later audio onto an earlier part of a recording. You, an interviewer, are recording an interview, and you hear the interviewee say something interesting about XXX. You hit a button on your audio recorder, the interview goes on to YYY and ZZZ, and then you say, "Can you say a little more about XXX?" You hit the button again and the interviewee expands on XXX. You hit another button. On the first button press, a pin is attached at the point where the interviewee mentioned XXX, when you press the button again a thread is attached to the pin with the audio from that point attached. When you press the other button, the thread is cut. The linear track of audio as spoken is preserved the whole way, but now there's another track where you can attach a single excerpt from later parts in the track to earlier parts.
<p>There are, of course, limitations to the method. You can't attach a thread to either YYY or ZZZ with only the two buttons. You may be able to return to XXX depending on how we set the semantics of that first button, but it makes much more sense for that button to do the same thing as before by either pinning to one of the second-track threads in a sort-of skewed tree:
<pre>
-------------
`---------
`-----
`--
</pre>
or to re-pin on the base track (<tt>p</tt> means pin):
<pre>
--------p----
`---------
</pre>
Maybe it would be better to have a three-button system to set multiple pins with the first button, a second button to attach the thread to the earliest pin, and a third button to cut the current pin.
<p>I'm focusing on a simple button system which can be managed more or less without thinking about what thread you're on since I think that, when I talk, my model of the conversation has this sort of folding linearity that matches with this system. Obviously, a full tablet computer with a display of these threads would allow for great flexibility, but wouldn't that display get in the way of engaging with the interviewee, the focus of your activity? There's also much more applicability for the simple thing than the complicated pretty thing that's all about itself and not about the thing that you're doing with the thing. I might permit a dial of sorts that allows you to move between pins more freely.
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-24067543703865403112015-02-10T10:04:00.000-08:002015-02-10T10:04:54.931-08:00Motion predictionI just thought up this experiment a couple of minutes ago:
<p>
I'm a casual juggler and I'm wondering whether, when I juggle, I'm predicting the parabolic path of the balls as they fall through the air or I'm doing something else, like predicting a linear continuation of the balls' motion from any given point. To test this, I would have myself standing or sitting with my head in a fixed position. I would have a machine for throwing balls in a predictable arc (e.g., a batting cage ball delivery system). I would have the balls thrown with a spread of trajectories that land within the range of my arms for catching. I would have a head-mounted camera recording approximately the visuals that I could see. I would have a set of goggles that could obscure my vision after a specific time-delay from launching the balls. Each trial would consist of the throwing machine throwing a ball and myself attempting to catch. To establish a baseline, I would attempt to catch the balls without my vision being obscured at any point in the ball's arc. Then, I would have my vision obscured before the top of the arc, at the top, and after the top until the next trial. I would have an assistant record the trials on which I caught the ball and the ones on which I did not.
<p>
In order to reject the theory that I was calculating parabolic arcs, my performance when my vision was obscured would have to be close to as-good-as my performance when it was not. We would still expect that when my vision was blocked earlier, my performance would be worse than later. The camera recordings are to explore whether an alternate strategy, linear extrapolation, could be in effect. For the failed trials, we would predict the linear path of the ball from the time, maybe .1s, before my vision was obscured and see if my hand placement was closer to intersecting that path than the parabolic.
<p>
Since I thought of this experiment before consulting any of the literature, I'm going to do a little study. I'm starting with these here:
<ul>
<li><a href="http://www.sciencedirect.com/science/article/pii/S0042698908001946">http://www.sciencedirect.com/science/article/pii/S0042698908001946</a>
<li><a href="http://www.sciencedirect.com/science/article/pii/S0028393204002817">http://www.sciencedirect.com/science/article/pii/S0028393204002817</a>
</ul>
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-29747547971576975362015-02-06T13:34:00.000-08:002015-02-06T13:34:14.448-08:00Custom diff formatsI just discovered this <a href="https://github.com/blog/1772-diffable-more-customizable-maps">gem</a> posted by Github staffer Ben Balter last year.
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-14021202986219515012015-01-20T13:45:00.002-08:002016-04-23T20:54:06.402-07:00Debugging techniquesIn our C.S. classes, we were often shown a picture like this:<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="http://media-cache-ec0.pinimg.com/736x/4e/9c/46/4e9c4695005f99efb66988e2159705e9.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://media-cache-ec0.pinimg.com/736x/4e/9c/46/4e9c4695005f99efb66988e2159705e9.jpg" height="250" width="320" /></a></div>
The memory is allocated from the bottom of the stack and the top of the heap. Now, students had asked the obvious question of "what happens when they meet?" The obvious answer was that there would be an exception of some kind. I don't know if we ever probed into how that exception worked though. It's pretty clear that it couldn't be a segmentation fault. The memory on either side of that gap belongs to the process, so there's no invalid address being accessed.
<p>Recently I read that the collision is handled by marking a memory page set between the stack and heap areas as a guard page. When the page is accessed, this signals an interrupt to the processor similar to what occurs in a page fault and thus allows the operating system to resume control and handle the overflow by, for instance, killing the process. Guard pages can also be used for debugging a process with unknown behavior that is presumed to access a certain portion of memory in a critical part of its operation, and this technique is valuable for software that subverts debugging with soft breakpoints (which temporarily modify program code) by checksumming code-in-execution.
<br />
<br />
~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-75250538888047069112014-12-10T20:22:00.001-08:002014-12-12T17:05:38.514-08:00Owning a Kindle tabletI recently acquired a Kindle Fire tablet. It's been less than a week that I've had it, but I'm already annoyed by the amount of vendor tie-in that comes with the device. I'll be turning this tablet computer into the kind of device that I like over the next few weeks. I've started by looking over a few videos that advise on "rooting" or "jailbreaking" a Kindle Fire. For now, I'm distrustful of these and I'll be sticking to the use of official Android developer tools and a few others that seem useful.
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-88673064637717167732014-12-04T09:35:00.002-08:002014-12-04T09:35:49.028-08:00Lately, I was trying to resolve an issue with an xsl:import statement looking for a document in from the Tomcat servers base directory (/var/lib/tomcat7). Naturally, you have to <i>tell</i> the transformer how to resolve the the URI -- how would it know otherise?
<blockquote>The API provides a way for URIs referenced from within the stylesheet instructions or within the transformation to be resolved by the calling application. This can be done by creating a class that implements the URIResolver interface, with its one method, URIResolver.resolve(java.lang.String, java.lang.String), and use this class to set the URI resolution for the transformation instructions or transformation with TransformerFactory.setURIResolver(javax.xml.transform.URIResolver) or Transformer.setURIResolver(javax.xml.transform.URIResolver). The URIResolver.resolve method takes two String arguments, the URI found in the stylesheet instructions or built as part of the transformation process, and the base URI against which the first argument will be made absolute if the absolute URI is required. The returned Source object must be usable by the transformer, as specified in its implemented features.
</blockquote><p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-52024744869797866272014-11-27T16:32:00.002-08:002014-11-27T16:32:20.199-08:00Essie Mae Washington-WilliamsFrom Wikipedia (with edits):
<blockquote class="tr_bq">
<p>Essie Mae Washington-Williams (October 12, 1925 – February 4, 2013) was an American teacher and writer. She is best known as the oldest natural child of Strom Thurmond, Governor of South Carolina and longtime United States Senator, known for his pro-racial segregation policies. Of mixed race, she was born to Carrie Butler, a 16-year-old black girl who worked as a household servant for Thurmond's parents, and Thurmond, then 22 and unmarried. Washington-Williams grew up in the family of one of her mother's sisters, not learning of her biological parents until 1938 when her mother came for a visit and informed Essie Mae she was her mother. She graduated from college, earned a master's degree, married and had a family, and had a 30-year professional career in education.
<p>Washington-Williams did not reveal her biological father's identity until she was 78 years old, after Thurmond's death in 2003. He had paid for her college education, and took an interest in her and her family all his life. In 2004 she joined the Daughters of the American Revolution and United Daughters of the Confederacy through Thurmond's ancestral lines. <b>She encouraged other African Americans to join such lineage societies, to enlarge the histories they represent.</b> In 2005, she published her autobiography, which was nominated for the National Book Award and a Pulitzer Prize.
</blockquote>
It's not so easy, I think, to not be acknowledged as your father's offspring for years. I'm rather impressed by Mrs. Washington-Williams take on the historical importance of her heritage and the importance for blacks to join in our nation's complex and sometimes unsavory history.
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-84311926998983720632014-11-19T17:34:00.001-08:002014-11-19T17:34:16.182-08:00I just discovered this site <a href="http://genius.com/">genius.com</a>. Haven't explored it, but it looks nice at least.
<p>~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-31411295408151125512014-11-18T19:42:00.002-08:002014-11-19T06:01:10.006-08:00Python3 or BustI decided to transition my library, Yarom (Yet another rdf-object mapper), to Python3. I've resisted using Python3 at all to avoid dealing with the transition/rewrite tools (<tt>six</tt>, <tt>2to3</tt>) and the still un-ported packages. What made me reconsider is the unicode support. Although I don't code in a language that requires special characters, I understand that other people do. Making it more comfortable for them to write code is worth the trouble, I think. Besides that, new core Python development should be happening in Python 3, making it more secure to go with the latest version
<p> In the future, I might post about how the Python 2/3 issues, as well as Ubuntu release cycles and the current Haiku OS discussion on a non-alpha release, have affected my thoughts on software versions.<br/>
~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-29562768444371690242014-11-16T10:42:00.000-08:002014-11-16T10:42:49.532-08:00I just remembered that I once chatted regularly (maybe once a week) with a guy from China. It was early in college. He was a pretty cool dude. He even introduced me to his friend once.<br />
<br />
I don't remember his name though :(<br />
~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-69842172942353224062014-11-08T06:17:00.003-08:002014-11-08T06:17:54.825-08:00Night WitchesHere's <a href="https://badreputation.org.uk/2011/05/27/unsung-heroes-the-night-witches/">an article</a> about the "night witches", Soviet bomber pilots from WWII, and <a href="http://bleaseworld.blogspot.com/2013/03/plane-month-night-witches.html">a blogpost</a> with links to a little more.<br />
~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-47833759406839135352014-11-04T06:13:00.003-08:002014-11-04T06:13:52.429-08:00Sort and replace identifiers in a sentenceI found this <a href="http://www.linuxquestions.org/questions/programming-9/sort-specific-words-within-sentence-4175523501/">post on LinuxQuestions</a> that interested me, so I decided to try my hand at it. What I wrote is slightly more general in that it sorts any identifiers matching a pattern rather than just identifiers with numbers. The program does 3 passes over the sentence: The second substitutes all of the matching identifiers with "{}", a string which can be replaced using Python's string formating function. The first pass extracts the identifiers and sorts them. The third pass is the actual substitution using the string formatter.<br />
<pre>
import re
word_split_regex = re.compile(r"[\W\s]*")
id_regex = re.compile(r"id\d+")
natsort_regex = re.compile('([0-9]+)')
# from http://stackoverflow.com/questions/4836710/
# does-python-have-a-built-in-function-for-string-natural-sort#18415320
def natural_sort_key(s):
return [int(text) if text.isdigit() else text.lower()
for text in re.split(natsort_regex, s)]
def main(s):
b = sorted(id_regex.findall(s), key=natural_sort_key)
x = id_regex.sub("{}", s)
print x.format(*b)
if __name__ == "__main__":
import sys
if len(sys.argv) > 1:
main(sys.argv[1])
</pre>
<br />
~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-7946935196052952302014-11-02T06:17:00.002-08:002014-11-02T07:04:51.543-08:00Disable Checked Exceptions?I recently was frustrated by the necessity of annotating every function in the call chain in order to not handle an exception at the entry point to my code. The module I am working on accepts many different signatures for essentially the same method:<br />
<br />
<pre><b>public static void doTransformation(Transformer t, Source in, Result out)</b>
public static void doTransformation(Transformer t, InputStream in, Result out)
public static void doTransformation(Transformer t, InputStream in, OutputStream out)
public static void doTransformation(String t, InputStream in, OutputStream out)
public static void doTransformation(String xslt, String in, Writer out)
public static void doTransformation(String xslt, String in, OutputStream out)
</pre>
<br />
Only the first actually does the transformation, but this can throw <a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/transform/TransformerException.html">an exception</a> from an <a href="http://docs.oracle.com/javase/7/docs/api/javax/xml/transform/Transformer.html">external library</a>, and all of the others call it directly or indirectly. I didn't want to annotate all of these with a <tt>throws</tt> declaration because I didn't know if I would have to switch out Transformer for something else or add more such methods in the future.<br />
<br />
My first reaction was to leave off and go read a book; so I did that and then went to sleep. This morning I was looking at the code again and I was reminded of the first tool (or maybe second after abstraction) in the programmer's toolbox: indirection. Although a checked exception, if unhandled, can introduce a lot of unnecessary annotations into your code, you aren't obligated to use that exception throughout. All it took was wrapping that exception in my own derived from java's <tt>RuntimeException</tt>, and now it passes through to a place where I can deal with the exception appropriately.<br />
<br />
I should have thought of such a simple solution right away — maybe I'll remember not to be writing code when I'm so tired in the future!<br />
<br/>
<i>I happened upon this excellent <a href="http://howtodoinjava.com/2013/04/04/java-exception-handling-best-practices/">blog post</a> on exceptions in Java. Really, I can only vouch for the headings and the comments, but it's a very good summary.</i>
<br />
~~~~Unknownnoreply@blogger.comtag:blogger.com,1999:blog-4571502187938131597.post-33928027501911481052014-10-30T16:56:00.001-07:002014-11-02T07:01:28.814-08:00<p>
I was watching this <a href="http://new.livestream.com/internetsociety/AfPIF2014Day1">video</a> here and, at the end, the speaker, <a href="http://www.internetsociety.org/afpif-2014/speakers/ghislain-nkeramugaba">Ghislain Nkeramugaba</a>, mentioned that there is an unwritten rule that broadband Internet access is built out with road construction. Hearing this makes me think that the countries which are building out their infrastructure for the first time must be at a great advantage to older nations that had to patch centuries old (or older) infrastructure to bring broadband access. Especially in Europe where various buildings and roads may have been there for a millennium or more, bureaucratic restrictions may slow down build-out regardless of industrial sophistication. That certainly is <b>not</b> to say that countries like Rwanda have no areas which are <a href="http://www.rwandapost.org/2014/02/26/building-preservation-kigali-across-rwanda/">worth protecting</a>; however, I think there is always greater difficulty in tearing up and replacing established infrastructure versus adding something that did not exist before.
<p>What's the upshot of this alleged smaller burden of history? It's really unclear to me as I have no background in the development of infrastructure. I do suspect however, that there are opportunities for innovative plans for building the networks that power developing countries and that these countries will be the laboratories of exciting new Internet technologies.
<br/>~~~~Unknownnoreply@blogger.com