Categories
Misc

Testing Some Something

This post is so I can exercise my blogclient. The following piece of writing:

Is a blockquoted section with code and lists.

This is a nested blockquote.

  • This is list item 1 in the nested bq
  • This is list item 2 in the nested bq
  • This is list item 3 in the nested bq

Back to original blockquote

  1. This is an order list in the bq
  2. This is item 2 of the ordered list in the bq
  3. This is item 3 of the ordered list in the bq

That should be a pretty good test. I expect most of these will fail for the time being. I’ll work out those kinks in good time.

While I’m at it:

  1. Ordered list item 1 in a p-tag

    This is a second paragraph under item 1.

  2. Ordered list item 2 in a p-tag

    This is a second paragraphc under item 2.

  3. Orderes list item 3 in a p-tag

That should be enough for now.

Categories
Computers Programming Python

Python Unicode

I’ve been working on a piece of code to convert a blogpost into Markdown text. Yes, I’m aware of the html2text.py module (mine is html2md, so nyeah!) All I’ll say is how the heck does one learn anything if they keep relying on other people’s work?

Anyway, I’ve got a naive implementation working now (won’t handle more complicated nestings like lists in blockquotes) when I ran into a snag involving unicode. Upon retrieval of a particular post, I got the following error:

UnicodeEncodeError: ‘ascii’ codec can’t encode character u’xa0′ in position 174: ordinal not in range(128)

It came up in the context of passing a string to the iterparse function of the cElementTree module. The character in question is a ‘non-breaking space.’ Frankly, I wasn’t sure how it got there, but I verified it’s presence in the string and then set to figuring a way to deal with it. I believe this is an instance of mixing strings and unicode together, rather than dealing solely in one or the other.

I found the unicodedata module for a solution. There is a function call normalize which will map unicode characters to the local encoding. In this case, ASCII. Now this solution is far from perfect, since special characters (say, from the Russian alphabet or characters with tildes above them) are just converted to rough ASCII equivalents.

The following code additions fixed my problem:

import unicodedata as ud
    .
    .
    .
uthml = ud.normalize('NFKD', unicode(html))

Where html is a string of html directly from the website. I can then pass uhtml to the iterparse function and the error is gone (because the u’xa0′ characters are translated to ASCII space characters) and the rest of the program is able to do it’s thing.

I don’t know if this will be the final solution, but it allows me to continue with the development I had been originally interested in. I was aware of the potential for unicode issues, but had hoped they wouldn’t crop up. This gives me a simple 2 line way to deal with it for the now.

Categories
Family

Just When You Think You Know Them

We’ve signed the kids up for a YMCA sponsored soccer camp. It’s six-weeks long and started yesterday. I figure there is no better way for them to learn the inferiority of the game than to actually play and learn it. Once they get exposed to a real sport, they’ll never have any question as to why they never went back to soccer. (No, I won’t define “real sport”- where’s the sport in that?)

So last night was the first night for the camp and the kids were having a grand ol’ time kicking balls around with the other kids prior to the start of class.Then the class started and the instructor had all the kids gather in the middle of the gym floor, followed by a quick jog around the outside of the gym.

The lass made it 3/4 of the way around the lap, before diverting off in tears and running to the Wife. She steadfastly refused to get back involved.

The boy, on the other hand, was having the time of his life. This, in spite of earlier comments, when told what they’d be doing for the evening. that he already knew how to play soccer and hated it.

Categories
Computers Programming Python

Learned Something New

I’m in the process of learning how to use lxml- a fast, powerful XML parser for python that relies on libxml2. I don’t know much in the way of details regarding xml so I got stuck as soon as I got started.

I was passing straight markdown generated XHTML into the various xml parser methods and objects for lxml. All of them were dying with the same error. The only parser that worked was the HTML parser.

The xml parsers kept coughing up the following error:

lxml.etree.XMLSyntaxError: Extra content at the end of the document, line 1, column 222

I really had know clue as to what this might mean. Since the output was from markdown, I reasoned there was little likelihood of malformed XHTML or some such. Besides, I knew that it rendered fine on web pages. Liekly, there was some significant detail I was missing. Unfortunately, my lack of xml knowledge meant I didn’t have anything to fallback on for solving the problem.

Finally, I turned up a comment thread where I learned that xml documents require a “root element.” I had seen the term “root” but only had a vague notion of what it meant. Now, I know exactly what is meant.

Prior to passing the markdown string to the parser, I performed the following operation:

rootedhtml = "<post>%s</post>" % html

Where html was the markdown output. I then passed rootedhtml to the parser and it no longer chokes.

Now I can get back to solving my original problem.

Categories
Misc

Did You Know…

It’s impossible to sneeze with your eyes open?

Go ahead, try it.

Categories
Computers Programming Python

Python-markdown Strike

I’ve incorporated markdown into my blog client and in the course of doing so, I saw that it could be extended. So I thought I’d give it a go and see if I could add a ‘strike’ extension to the markdown module.

It turned out to be almost trivially simple thanks to the documentation. I chose to use a double hyphen around a word to create the strike. I looked elsewhere and double tildes seems to be another nice way to do it. The code below shows it for the double hyphen but the code would be identical in either case except for the RE definition.

Here’s the code:

import re

import markdown
from markdown import etree

STRIKE_RE = r'(-{2})(.+?)\2'

class StrikeExtension(markdown.Extension):
    def extendMarkdown(self, md, md_globals):
        md.inlinePatterns.add('strike', markdown.inlinepatterns.SimpleTagPattern(STRIKE_RE, 'strike'), '>strong')

def makeExtension(configs = None):
    return StrikeExtension(configs = configs)

That’s it.

The SimpleTagPattern object is a general purpose object that’s part of the markdown library and it’s used to create text rules involving inline patterns such as emphasis or strong. That’s all my version of the strike rule is.

I implemented my extension as a module, so I had to put it in the ‘extensions’ directory of my markdown library. It’s also possible to just incorporate the extension in project code and make markdown aware of it, but I haven’t tried that yet.

Categories
Politics

An Intemperate Rant

During the course of my normal blog readings, I came across this quicky. Naturally, I followed the link to Mr. Bartlett’s blog and read his entry quickly. The post that started it all was by Glenn Reynolds. Since then, a other bloggers have piled on to such as Matthew Yglesias and Mark Thoma. Mr. Sullivan has since followed up with this little beauty.

I am not going to defend Glenn Reynolds, he doesn’t need my help. But the arrogant, dismissive, “I’m-so-much-your-superior-that-I-don’t-have-to-prove-it” tone of the other bloggers just pissed me off.

Categories
Computers Misc

Using PGP

Those of you who receive emails from myself may have noticed that my emails now have some funny business attached to them. There is a simple explanation- I’m using PGP to sign my outgoing emails. Ultimately, I’d like to start exchanging emails using full encryption, but it takes two to tango.

Here is my public key. Using this, it’s possible for email software to verify my signature. Further, the public key can be used to encrypt email text so that only I, with my private key (no, you can’t see- it’s PRIVATE) can decrypt and read what’s been sent to me.

I’ve been checking around and it appears that gmail is experimenting with PGP support through their web interface. Additionally, just about any email program (Thunderbird and so forth) can be setup to use PGP. Therefore, those out there using 3rd party email clients should take the time to install GnuPG and join the encryption bandwagon.

The hardest part is the initial setup. Once that’s done, composing and sending email is more or less the same as it ever was.

Categories
Family

Tooth #6

The Tooth Fairy is going to get tired of trekking out here this winter. Whileout at dinner, literally just prior to the food arriving, the boy exclaimed “Mytooth came out!” and spat it out into his hand.

Bakugan from the TF this time around.

He doesn’t have anymore loose ones at this point. But this one makes it thefour front teeth across the bottom and his 2 top fronts that are gonzo.

If he were to maintain his current pace (3 in the last month, I believe) hewould need a set of falsies. Or a liquid diet…

Categories
Misc

Kids and Video Games

Being a reformed video game junky, I can attest to the notion that life has a wicked sense of humor.

We got the kids a Wii video game system last Christmas. Now, having familiarity with video games growing up, I was well aware of the possibility that the kids would be smitten with it to the point of obsession. Fast forward a year later and I have the following conversation with each kid almost daily:

Child: Dad, can I play the Wii?

Me: No.

Child (whining): OHHHH, I want to play the Wiiiiiiiii. Why can’t I play the Wiiiiiiiiii?

Me: Because I said so.

Child (still whining): That’s not fairrrrrrrrrr…. I want to play the Wiiiiiiiiiiiii

On a few occasions, I strayed from the above script by taking the time to explain that they need to find other ways to play. That they have other toys and games that they need to explore. That they should be using their imagination to invent worlds and scenarios and whatever else they can come up with. The Wii substitutes someone else’s imagination and it isn’t healthy for them to play the Wii all the time, or even some of the time, at their tender age.

Every now and again, the boy will try reverse psychology on me:

The Boy: Dad, I’ve been trying to think of something else to play and all I can think of is the Wii.

Me: Well, try harder.

The Boy: Don’t even tell me what else I can do. All I can think of is the Wii.

Me: Well, that’s the problem.

The Boy: Can I play the Wii?

Me: Nope.

The Boy: GRRRRRR!!!! (stomps off in frustration)

When I really want to flummox them, I go all Zen and tell them that they can only play the Wii when they don’t want to play the Wii. That’s usually good for a confused look, an eye roll, or a huff as they stomp away.

So, based on my experience, I would advise parents to save themselves a headache and put off video games for as long as possible. The headache of putting it off pales compared to the headache of keeping them from it.

Categories
Family

Hiking and Sledding

With the couple of inches of snow we got overnight into today, I told the kids we’d go for a hike and then go sledding. They got snow shoes for Christmas so they were excited to get a chance to use them. Plus, we were going to a big hill for sledding, how much better could it get?

Of course, all of this stuff seems great in theory. The reality of it usually has some sort of snag that I foresee, but strategically choose to ignore. In this case, the hike throuh the snow is cool because of the snow shoes. Unfortunately, it takes time to get from point A to point B- and it’s tiring. The other tidbit I omitted was that long hills are great for sledding down- not so great for walking back up. Especially after a 20 minute hike to get to the hill.

The boy was excited enough that he didn’t complain at all. I even got a chance to reinforce the “awesomeness” of his snow shoes. There was a point where the new snow covered up some older snow so my feet sunk way down. I pointed this out to him and he was very satisfied in the knowledge that his snow shoes worked so well.

The lass was a slightly different story. She lagged behind and I ended up carrying her for the last third of the way to the hill. When we were done- she was really done. I held her hand and made her walk the whole way home. She was fighting back tears from fatigue and the effort of trudging through the snow.

The Wife was waiting for them when we got back. She even made some hot chocolate. I played with the dogs for awhile before I finally trudged back in the house myself.

A nice way to spend a morning.

Categories
Politics

Rats From a Sinking Ship

I’ve lost count, at this point, of the number of Congressmen whom have decidedto call it quits rather than run for re-election. Based on the rise of the TeaParty, the seeming public rejection of the President’s policy choices, and thecontinued decline in confidence of government (Congress in particular) it’s hardfor me not to conclude we’re witnessing the “git’n while the git’ns good.’

The ones that come next will be interesting. How capable as governors will theybe? My own opinion is that the destruction will have to be both deep and wide.Politicians currently being groomed, or those who have been waiting in the wingswill need to be flushed from the system if We-the-People are going to trulyreassert our role as the boss of our country.

Interesting times, to say the least.

Categories
Misc

Those Sun Life Commercials

Who comes up with those commercials for Sun Life? What the hell are thesupposed to be proving? That Sun Life employs idiots and morons in theirmarketing department?

Really, other than that they are an insurance company, what do we get from thosecommercials? Crikey, even the people they talk with in THEIR commercials can’tstand them. Why should anyone else?

Methinks that heads need to roll. Starting with the two on those goons in theircommercials…

Categories
Misc

Concussion Update- 2 Weeks

Today being the 2-week recovery mark, I just thought I’d note my current condition related to the concussion.

I still have ringing in my ears, though it is greatly reduced from when it started. I’m can’t tell as yet, but there is clearly the opportunity for permanent hearing damage. I haven’t noticed anything in terms of volume, but I have noticed issues with higher frequency ranges. Sounds like “shh” or hissing, ‘s’ sounds there is definitely an effect.

As for pain, there basically isn’t any. Coughing and sneezing are fine. The only thing that bothers my head is popping my ears.

One thing I’ve wondered about, now that I’ve had the experience, is what it would have been like to suffer a concussion during football. I’m certain that, had I suffered this identical sort of event during a game, I would not have finished the game. But I am also certain I would have played the following week.

That’s where I wonder- how susceptible would I be to another one? How well would I have been able to handle playing? Would I even have given it a seconds thought? Remember, before accusing me of braggadocio, that wouldn’t have made me unique or special in any way. I can recall other guys who suffered concussions from repeated collison playing after a couple days rest. That’s just what was done.

I think about a guy like Muhammad Ali whom suffered multiple concussions over his career. Clearly, something I don’t want to aspire to. One is enough.

Yet, oddly, given slightly different circumstances I would have subjected myself to the opportunity for more without much thought.

Categories
Politics

Sen Ryan’s Budget

I don’t know if anyone is actually counting at this point, but I’ll just say that, in the absence of anything else to look at, I support his proposals. It sounds to me like he’s taken an honest shot at balancing the longterm Federal Budget. Frankly, I’m disappointed that more GOP politicians haven’t come out in support of it, or at least it’s aims. The GOP is supposed to show some fiscal common sense, meaning restraint. The fact that they aren’t getting behind this thing probably tells us where their motives truly lie.

Not that it was too difficult to discern before.

In a perfect world, the Democrats would give us something for comparisons sake. Since the GOP and Dems are all we have in Congress right now, I think it would be good to get a gauge for where these guys really want the country to go. My guess is the Democrats ideas are not anything I want to pursue. Regardless, I say put your cards on the table.

Until they’re willing to man-up, I think they’re criticisms are gutless bluster. For that matter, perhaps the fact that they haven’t come out with their own proposals means they don’t want to go there, for fear of what they perceive the electorate would think.

Categories
Misc

Got Milk?

Why is it that milk tastes best after fresh-out-of-the-oven chocolate chip cookies, warm brownies and ice cream?

I’m particularly curious about ice cream. I mean, a glass of water doesn’t satisfy. Plus, obviously, ice cream is made of milk.

Maybe it’s better not to know…

Categories
Computers

Building xpdf for Debian

For whatever reason, xpdf has disappeared from the Debian testing repository. It’s a nuisance since it seems to be the best combination of fast and usable among the various non-adobe pdf readers. It appears that a version has been reintroduced to sid, but it’s been awhile now and I wanted a working pdf reader.

So I opted to build it from source.

Categories
Family

Somthing Happened There

I’m just not sure what.

We were driving up to the Y for the lass’s dance class and the boy was merrily trucking along with his counting. He got to around 240 or so and then he stopped. The lass had distracted him. He went to start counting again, but he forgot where he was at.

Then he started to cry.

Not big crocodile tears, but more of a distressed and whiney “I can’t remember where I was.” I checked in the rear view mirror and he was visibly distraught.

Yes, over numbers.

Now, my first instinct is to point out the ridiculousness of his reaction. It’s numbers… and counting. But some part of my brain checked my mouth and instead I just calmly counciled him to calm down. That getting so upset wasn’t going to help. The part of my brain that had checked my initial reaction further engaged and basically turned my mouth off. Instead, I just sat and observed.

For about another minute or so, he continued with his agony of trying to remember what number. Somewhere along the way, I started thinking “Just pick a number and count from there,” but I continued to stay silent.

Then, he did. In a tearful voice he said “Two-hundred-fifty” and he continued counting from there. By the time he reached 260, his agony was gone and he was back to counting as if nothing had happened. He stopped at 299 because he hadn’t figured out the pattern yet.

I filled in the blank: “300.”

He picked up from there and continued. As we neared the Y’s parking lot, he hit 399. He paused, and then said “Four-hundred” and continued counting until I pulled into a parking spot. As I turned off the car he exclaimed “Dad, I know what comes next. When I get to 419, then it will be 500.”

I chose not to quibble about the details, as I’m sure his excitement had addled his speech somewhat. Like I said, I’m convinced that he had some sort learning moment for himself; but beyond the events, I couldn’t really describe what it might have been. For that matter, I may have stumbled across some sort of wisdom related to child rearing. It’ll be interesting to see if I recognize the circumstances again sometime.

Categories
Football

‘Aints NO More!!

I just wanted dibs on the title. More thoughts in a few minutes…

OK. Postgame thoughts in no particular order:

  • Not the best Super Bowl ever (still the Giants-Bills), but an excellent game from the 2 best regular seasons teams. Well worth watching until the end.
  • I was happy to be wrong about this. Oddly, though, the game went like I thought it would, except reversed! The Colts started fast and petered out and the Saints just kept on keeping on. I was expecting that kind of game flow, but the roles to be reversed.
  • Best quarterbacking in a Super Bowl that I can remember. I know Manning threw the interception at the end, but until then it really seemed like both QB’s had command of the game.
  • The onside kick to open the 2nd half by the Saints has to be the best coaching call ever. Totally, completely unexpected. It pretty much ensures that no head coach will ever leave a Super Bowl locker room without reminding his team to watch for the onside kick.
  • I thought the 2-point conversion was a little early- missing it meant that Colts could win with 2 field goals and there were still 6 minutes or so to go. I think it’s one of those calls that was vindicated by subsequent events.
  • Another call vindicated (somewhat) by subsequent events was the 4th down call by the Saints at the end of the 1st half. I actually liked the call to go for it, but hated the play call. The tightend is always open down there. Always.
  • I’m glad that the Saints won a Super Bowl, but really, the whole “How important is this to the city of N’Ollins?” bit is tiring. A football team winning a Super Bowl isn’t going to change the world or a city. 3 years from now, know one will even remember it. I know, now I’m just being racist…
  • Not so much Super Bowl related- but my guess is that was Peyton’s swan song, so to speak. That team has a ton of games on their shoulders and after the season they had, this one is going to hurt. They’ll continue to be competitive, but I’ll be surprised if Manning makes it to another Super Bowl.

That’ll do. Congrats to the Saints. Once again, I’m not sure how I’ll make it through the next few months worth of sports seasons. They just suck when compared to the football season.

6 months to go for next season…

Categories
Family

A Halftime Covnersation

Wife: Who’s doing the halftime show?

Me: Who’s doing the halftime show.

Wife: Right, who’s doing the halftime show?

Me: That’s what I said, Who’s doing the halftime show.

Wife: (Finally glances at TV and hears “Teenage Wasteland” playing.) OHhhh… (Makes a move to whack me.)

Me: (Wagging finger, then point to head) Concussion.

Wife: Yeah, not enough.

Maybe we should take it on the road…