Archive for August, 2007

Laptops

Friday, August 31st, 2007

The always-worth-reading Rands on laptops in meetings

The solution here is simple. If you’re in a meeting where you have no role such that you’re tempted to stare at your laptop: stop going. If you’re running a meeting infested with laptops and, after repeated gentle reminders about your no-laptop policy, there are still laptops: remove the laptop offenders from the meeting.

This brute force approach strikes me as being a violation of the Rands “Don’t be a prick” policy, but frequent readers know that not being a prick is always trumped by the even more important policy of “Don’t waste my time”. Besides, being a prick is going to have some interesting side effects.

It’s worth noting that “don’t waste my time” is a proper subset of “don’t be a prick.”

Miss Teen South Carolina

Tuesday, August 28th, 2007

Oh my. I thought this was a joke when I started getting the email about it….

Hipster Olympics

Saturday, August 25th, 2007

My money is on the winners from the Silverlake regional to take it all.

Haskell Unit Tests with HUnit

Thursday, August 23rd, 2007

I read an OnLamp article today called A Beautiful Regex Matcher… In Haskell. Interesting little piece of code, but there was a (silly little) bug in it. This struck me as a fine opportunity to figure out how HUnit — one of Haskell’s unit testing frameworks — works. Here’s what I came up with:

import Test.HUnit
import Regex

tests = TestList [ TestLabel (makeLabel x) (makeTest x) | x <- test_data ]
    where makeTest  tup@(reg, str, bool) = 
              TestCase $ assertEqual (makeLabel tup) bool (match reg str)
          makeLabel (reg, str, bool) | True == bool  = reg ++ " =~ " ++ str
                                     | False == bool = reg ++ " !~ " ++ str
          test_data = [ ("foo",  "foo",     True),
                        ("foo",  "bar",     False),
                        ("",     "foo",     True),
                        (".",    "Foo",     True),
                        (".*",   "Foo",     True),
                        ("F.",   "Foo",     True),
                        ("F.*",  "Foo",     True),
                        ("Fo*",  "Foo",     True),
                        ("Fo*d", "foo",     False),
                        ("Fo*d", "Foooood", True) ]

main = runTestTT tests

As mentioned in the article’s comments, the case where “.*” (”match anything”) is supposed to match “Foo” fails. Here’s the test output for the original code:

% runhaskell TestRegex.hs
### Error in:   4:.* =~ Foo                
user error (HUnit:.* =~ Foo
expected: True
 but got: False)
### Error in:   6:F.* =~ Foo               
user error (HUnit:F.* =~ Foo
expected: True
 but got: False)
 Cases: 10  Tried: 10  Errors: 2  Failures: 0
Counts {cases = 10, tried = 10, errors = 2, failures = 0}
% 

Easy enough. Finding out which cases fail makes tracking the problem down relatively straightforward. Turns out that the “matchstar” method doesn’t deal properly with periods at the end of the match. The original code:

matchstar c [] (y:ys) = c == y

Replace it with the following:

matchstar c [] (y:ys) = if c == '.' then True else c == y

And you get the following out of the unit tests:

% runhaskell TestRegex.hs
Cases: 10  Tried: 10  Errors: 0  Failures: 0
Counts {cases = 10, tried = 10, errors = 0, failures = 0}
% 

Horray!

New in Python 2.6: ORM made easy

Sunday, August 19th, 2007

From the What’s New in Python 2.6 page:

A new data type in the collections module: NamedTuple(typename, fieldnames) is a factory function that creates subclasses of the standard tuple whose fields are accessible by name as well as index. For example:

var_type = collections.NamedTuple(’variable’, ‘id name type size’)

var = var_type(1, ‘frequency’, ‘int’, 4)

print var[0], var.id # Equivalent

print var[2], var.type # Equivalent

Neat! It all exists in libraryspace, so it’s not a groundbreaking change to the language. Still, this has to save time. Without this creating the same sort of class would have taken something like:

class variable(object):
    def __init__(self, id, name, typ, size):
      self.id, self.name, self.type, self.size = id, name, typ, size

Not too much typing, but certainly more, and you can’t even access it as a tuple without additional work. I wonder if the various Python ORM libraries use techniques like this?

Nigh? What the hell is nigh?

Sunday, August 19th, 2007

A quote on the Wikipedia page for Fermat’s last therom made me chuckle:

Fermat’s last theorem is one of the most famous theorems in the history of mathematics, familiar to nigh every mathematician, and had achieved a recognizable status in popular culture prior to its proof.

You’ll not find copy like this in Britannica, that’s for damn sure.

Happy Bukday (Belated)

Friday, August 17th, 2007
gamblers all
     
      sometimes you climb out of bed in the morning and you think,
I’m not going to make it, but you laugh inside
remembering all the times you’ve felt that way, and
you walk to the bathroom, do your toilet, see that face
in the mirror, oh my oh my oh my, but you comb your hair anyway,
get into your street clothes, feed the cats, fetch the
newspaper of horror, place it on the coffee table, kiss your
wife goodbye, and then you are backing the car out into life itself,
like millions of others you enter the arena once more.

you are on the freeway threading through traffic now,
moving both towards something and towards nothing at all as you punch
the radio on and get Mozart, which is something, and you will somehow
get through the slow days and the busy days and the dull
days and the hateful days and the rare days, all both so delightful
and so disappointing because
we are all so alike and so different.

you find the turn-off, drive through the most dangerous
part of town, feel momentarily wonderful as Mozart works
his way into your brain and slides down along your bones and
out through your shoes.

it’s been a tough fight worth fighting
as we all drive along
betting on another day.

Charles Bukowski

Big ups to Dreamhost for being down last night such that I couldn’t post this on Buk’s actual birthday

Comment spam is awesome

Monday, August 13th, 2007

I’ve gotten the same comment spam three times recently. What’s interesting is that it made it past Akismet’s filter each time.

It’s always from the same IP address and same email address, and the content has the same form every time:

I have to say, that I could not agree with you in 100% regarding White on black or black on white?, but it’s just my opinion, which could be wrong :)

I have to say, that I could not agree with you in 100% regarding AFI Top 100 Films List, but it’s just my opinion, which could be wrong :)

I have to say, that I could not agree with you in 100% regarding t!, but it’s just my opinion, which could be wrong :)

And then from the same guy

I couldn’t understand some parts of this article t!, but I guess I just need to check some more resources regarding this, because it sounds interesting.

And with each post a link to some dumb link farming page with poorly-targeted ads on it. I wonder why Akismet doesn’t catch it. I guess with content like that it’s pretty hard to tell whether or not it’s really spam. (It’s reads pretty typical Ham rather than Spam.) Best of luck, I guess, to the young gentleman on the bad guy end of things. I hope he enjoys making the internet worse for everybody.

OMG! Open Source Software causes hedge fund failures!

Monday, August 13th, 2007

This is, without question, the best/worst article on copylefted software that I’ve ever read.

“The expectation of most people running a hedge fund is that their programmers are writing 100% original code, and in most cases that’s probably true,” attorney Bert Wells of the law firm Covington & Burling told Lipper HedgeWorld, but adding that under pressure to develop a program and within a given timeframe, they may “borrow portions of freely available software” – without anyone at the firm, including the tech types, aware that open-source played a part. Such disclosure of enhancements could be disastrous to a hedge fund. Attorney David Lerner of the law firm Morrison Cohen said, in a Lipper HedgeWorld interview, that the “saving grace” of the policy is that according to General Public License, the developer “isn’t required…to disclose the source code, it’s permitted to,” so if the customer doesn’t want it shared, it may be able to keep its secret in-house, but it could never be sure that the developer won’t share the enhancements anyway.

Hear that, developers? If you use any open source software, you can go ahead and give your employer’s code away without fear of repercussion. It’s true! There’s nothing they can do about it! (Except fire you and probably press charges.)

P + Optics = NP? (Apparently? Maybe? Huh?)

Tuesday, August 7th, 2007

I’m sure that when you all got your latest issue of Optics Express you were as taken aback by An Optical Solution For The Traveling Salesman Problem as I was.

We introduce an optical method based on white light interferometry in order to solve the well-known NP–complete traveling salesman problem. To our knowledge it is the first time that a method for the reduction of non–polynomial time to quadratic time has been proposed. We will show that this achievement is limited by the number of available photons for solving the problem. It will turn out that this number of photons is proportional to NN for a traveling salesman problem with N cities and that for large numbers of cities the method in practice therefore is limited by the signal–to–noise ratio. The proposed method is meant purely as a gedankenexperiment.

So is the “Gedankenexperiment” (”thought experiment”) whether or not it can be done or whether or not people buy in to the premise of the paper? Anybody want to give a go at reading this, not glazing over, and giving an informed $0.02?


This is a free Wordpress template provided by Mathew Browne | Web Design | SEO