Archives for: January 2009

01/16/09

Permalink 01:45:04 am, by fumanchu Email , 0 words   English (US)
Categories: General, Photography

Work in progress

01/15/09

Permalink 05:53:54 pm, by fumanchu Email , 39 words   English (US)
Categories: IT, Python, General

Looking for work

JJ Behrens is looking for work. Smart guy. You should hire him.

After you hire him, have a look at my resume and hire me too.

01/13/09

Permalink 02:01:10 pm, by fumanchu Email , 334 words   English (US)
Categories: IT, Linnaeus Award

2009 Linnaeus Awards

The Linnaeus Awards

I'm starting a new category here: the Linnaeus Awards. Candidates must be examplars of Linnaean Taxonomy:

The method, the soul of science, designates at first sight any body in nature in such a way that the body in question expresses the name that is proper to it, and that this name recalls all the knowledge that may, in the course of time, have been acquired about the body thus named: so that in the midst of extreme confusion there is revealed the sovereign order of nature.

So, if you encounter a trout in the wild, you don't call it a "trout". You call it an "Oncorhynchus (mykiss) aguabonita masculinus trescenti-septi-squamatic duodecim-annus-natis...", stuffing every conceivable attribute of the object into its name.

Categories

  1. Longest Name. Names which are mashed together because of formalLanguageIdentifierRestrictions or natürlichsprachemodifizierdiarrhöe might get bonus points.
  2. Most Dimensions. Names which incorporate knowledge from varied axes, the more the better.
  3. Most Abstract. Placing the number-of-scales-on-a-fish into its name is fun, but for real "sovereign order" you need to incorporate the vocabulary of the taxonomy itself into the name. For example, a function in a spreadsheet program named, "SpreadsheetProgramAdditionFunction". Bonus points for including terms from ontology, taximetrics, or metaphysics.

Feel free to nominate additional candidates here or email: linnaeus@aminus.org.

Today's nomination:

RequestProcessorFactoryFactory

From org.apache.xmlrpc.server

Factory-factories are not new. But this one goes a step further with some of its "implementing classes":

  • RequestProcessorFactoryFactory.RequestSpecificProcessorFactoryFactory
  • RequestProcessorFactoryFactory.StatelessProcessorFactoryFactory

...and genuflective attributes like:

  • RequestProcessorFactoryFactory.RequestProcessorFactory.getRequestProcessor(XmlRpcRequest)

But it doesn't stop there; the copy nominates itself:

There is nothing magic about the request processor: It may very well be a POJO. The RequestProcessorFactoryFactory is passed to the AbstractReflectiveHandlerMapping at startup...

Passing a factory-factory to an abstract-anything makes this a good candidate. Using the phrase "nothing magic" with a straight face catapults it to the top.

01/09/09

Permalink 12:22:51 pm, by fumanchu Email , 369 words   English (US)
Categories: Python

assertNoDiff

I recently had to test output that consisted of a long list of dicts against an expected set. After too many long debugging sessions with copious print statements and lots of hand-comparison, I finally got smart and switched to using Python's builtin difflib to give me just the parts I was interested in (the wrong parts).

With difflib and a little pprint magic, a failing test now looks like this:

Traceback (most recent call last):
  File "C:\Python25\lib\site-packages\app\test\util.py", line 237, in tearDown
    self.assertNoDiff(a, b, "Expected", "Received")
  File "C:\Python25\lib\site-packages\app\test\util.py", line 382, in failIfDiff
    raise self.failureException, msg
AssertionError:
--- Expected

+++ Received

@@ -13,4 +13,3 @@

 {'call': 'getuser101',
 'output': {'first_name': 'Georg',
            'gender': u'Male',
            'last_name': 'Handel',
            ...}}
 {'call': 'getuser1',
 'output': None}
 {'call': 'getuser101',
 'output': {'first_name': 'Georg',
            'gender': u'Male',
            'last_name': 'Handel',
            ...}}
-{'call': 'getuser101',
 'output': {'first_name': 'Georg',
            'gender': u'Male',
            'last_name': 'Handel',
            ...}}

...and I can now easily see that the "Received" data is missing the last dict in the "Expected" list. Here's the code (not exactly what I committed at work, but I think this is even better):

import difflib
from pprint import pformat


class DiffTestCaseMixin(object):

    def get_diff_msg(self, first, second,
                     fromfile='First', tofile='Second'):
        """Return a unified diff between first and second."""
        # Force inputs to iterables for diffing.
        # use pformat instead of str or repr to output dicts and such
        # in a stable order for comparison.
        if isinstance(first, (tuple, list, dict)):
            first = [pformat(d) for d in first]
        else:
            first = [pformat(first)]

        if isinstance(second, (tuple, list, dict)):
            second = [pformat(d) for d in second]
        else:
            second = [pformat(second)]

        diff = difflib.unified_diff(
            first, second, fromfile=fromfile, tofile=tofile)
        # Add line endings.
        return ''.join([d + '\n' for d in diff])

    def failIfDiff(self, first, second, fromfile='First', tofile='Second'):
        """If not first == second, fail with a unified diff."""
        if not first == second:
            msg = self.get_diff_msg(first, second, fromfile, tofile)
            raise self.failureException, msg

    assertNoDiff = failIfDiff

The get_diff_msg function is broken out to allow a test method to call self.fail(msg), where 'msg' might be the join'ed output of several diffs.

Happy testing!

01/05/09

Permalink 02:09:53 am, by fumanchu Email , 313 words   English (US)
Categories: General

99 Bottles...

1) Copy this list into your blog, with instructions.
2) Bold all the drinks you’ve imbibed.
3) Cross out any items that you won’t touch
4) Post a comment here and link to your results.

OR

If you don’t have a blog, just count the ones you’ve tried and post the number in the comments section.

  1. Manhattan Cocktail
  2. Kopi Luwak (Weasle Coffee)
  3. French / Swiss Absinthe
  4. Rootbeer
  5. Gin Martini
  6. Sauternes
  7. Whole Milk
  8. Tequila (100% Agave)
  9. XO Cognac
  10. Espresso
  11. Spring Water (directly from the spring) Soda water, too!
  12. Gin & Tonic
  13. Mead
  14. Westvleteren 12 (Yellow Cap) Trappist Ale
  15. Chateau d’Yquem
  16. Budweiser
  17. Maraschino Liqueur
  18. Mojito
  19. Orgeat
  20. Grand Marnier
  21. Mai Tai (original)
  22. Ice Wine (Canadian)
  23. Red Bull
  24. Fresh Squeezed Orange Juice Once a week!
  25. Bubble Tea
  26. Tokaji
  27. Chicory
  28. Islay Scotch
  29. Pusser’s Navy Rum shudder
  30. Fernet Branca
  31. Fresh Pressed Apple Cider
  32. Bourbon
  33. Australian Shiraz
  34. Buckley’s Cough Syrup
  35. Orange Bitters
  36. Margarita (classic recipe)
  37. Molasses & Milk
  38. Chimay Blue
  39. Wine of Pines (Tepache)
  40. Green Tea
  41. Daiginjo Sake Of course
  42. From the department of redundancy department: Chai Tea
  43. Vodka (chilled, straight)
  44. Coca-Cola
  45. Zombie (Beachcomber recipe)
  46. Barley Wine
  47. Brewed Chocolate (Xocolatl) Does Abuelita count?
  48. Pisco Sour
  49. Lemonade
  50. Speyside Single Malt
  51. Jamaican Blue Mountain Coffee
  52. Champagne (Vintage)
  53. Rosé (French)
  54. Bellini
  55. Caipirinha
  56. White Zinfandel (Blush)
  57. Coconut Water
  58. Cerveza Corona es lo mejor...
  59. Cafe au Lait
  60. Ice Tea
  61. Pedro Ximenez Sherry
  62. Vintage Port
  63. Hot Chocolate
  64. German Riesling
  65. Pina Colada
  66. El Dorado 15 Year Rum
  67. Chartreuse
  68. Greek Wine
  69. Negroni
  70. Jägermeister
  71. Chicha
  72. Guinness
  73. Rhum Agricole
  74. Palm Wine
  75. Soju
  76. Ceylon Tea (High Grown)
  77. Belgian Lambic
  78. Mongolian Airag
  79. Doogh, Lassi or Ayran
  80. Sugarcane Juice
  81. Ramos Gin Fizz
  82. Singapore Sling
  83. Mint Julep
  84. Old Fashioned
  85. Perique
  86. Jenever (Holland Gin)
  87. Chocolate Milkshake
  88. Traditional Italian Barolo
  89. Pulque
  90. Natural Sparkling Water
  91. Cuban Rum
  92. Asti Spumante
  93. Irish Whiskey
  94. Château Margaux
  95. Two Buck Chuck
  96. Screech
  97. Akvavit
  98. Rye Whisky
  99. German Weissbier
  100. Daiquiri (classic)
    and I'll add:
  101. Rompope
January 2009
Sun Mon Tue Wed Thu Fri Sat
 << < Current> >>
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Search

The requested Blog doesn't exist any more!

XML Feeds

powered by b2evolution