Coding without a Compiler

I’m between jobs right now which has given me the time to do some programming for myself. Sadly, my beloved w500 Lenovo laptop (8G RAM and 500M HD) had to be returned to my employer and now I’m reintroducing myself to my neglected MacBook Pro. However I’m programming in C#…without a compiler (yes, humble reader, I could install Mono but I haven’t). I’ve found the experience quite eyeopening. It’s helped me think more about what I’m working on than the syntactic correctness of the implementation. I’ve honed the design down to specific classes and their composition. However, it won’t compile. I’m sure there is a property or member variable I haven’t defined or misspelled. That doesn’t matter. Programming without a compiler has forced me to think more about the design than if it actually works. Once I’m sure the the design is right I can fix the code and even proper execution.

When one dimension of complexity is suspended, it’s easier and liberating to focus on what remains. I highly recommend it.

Compressing a file in Powershell & Waiting for it

Windows doesn’t have a standard command line tool for zipping a file. If you are writing a powershell script for portability you can’t depend on a third party tool.  The energized tech has a post how to compress a file without a 3rd party tool.  It’s very clever. His SEND-ZIP script uses a COM proxy object to the shell.application object  to create an empty compressed folder. Then the script copies the target file into the compressed folder and the shell.application is smart of enough to compress the file and then move it into the folder.   However, the compression and copying is done asynchronously.  This can be problematic if you want to, say, delete the file you put into the archive. You want to make sure the copy succeeded before you delete it. To address that I wrote two additional functions that blocks until a certain number of items are in the archive.

Here’s how I use it:

  "compressing datafile to $zipname"
  send-zip $zipname $datafh
  wait-zipcount $zipname 1

Here’s the code for wait-zipcount:

function wait-zipcount([string] $zipname, [int] $num) {
  $ExplorerShell=NEW-OBJECT -comobject 'Shell.Application'
  $count = count-zipfiles -zipname $zipname -ExplorerShell $ExplorerShell
  "waiting on zip [$count/$num]..."
  while (($count -eq $NULL) -or ($count -lt $num) ) {
    "waiting on zip [$count/$num]..."
    Start-Sleep -milliseconds 100
    $count = count-zipfiles -zipname $zipname -ExplorerShell $ExplorerShell
  }
}

and you'll need count-zipfiles:

function count-zipfiles([string] $zipname, [object] $ExplorerShell=$NULL) {
  if ((test-path $zipname) -eq $NULL) {
    return $NULL
  }
  if ($ExplorerShell -eq $NULL) {
    $ExplorerShell = NEW-OBJECT -comobject 'Shell.Application'
  }
  $zipdirfh = $ExplorerShell.Namespace($zipname)
  $count = $zipdirfh.Items().Count
  return $count
}

Memorable Phrases

I had a couple of good lines this week. Well, at least I think so:

“Baptism by fire does not apply to death inducing scenarios.”

I said this in reference to purchasing bike clips and shoes. I don’t want to practice right away on the road with cars around. I don’t want to kill myself!

“How do I sound incredulous without being rude?”

I said this to a Verizon phone representative while trying to work out a disagreement on part of my phone plan.

Obviously improv training pays off!

I am malleable clay

The majority of us, myself included, live physically safe lives. We have honed off the edges  such that we don’t expose ourselves to amounts of risk that outweigh the joy we derive from the activity. Mountain climbers get so much joy from that pursuit that they willingly put themselves at what they deem an acceptable risk.

I recently got into a little bike accident (my own fault really) and face planted during my bike commute. It’s reminded me what I’m made of. I am but malleable clay. The seemingly constant image of my face is easily changed. I won’t stop. I will continue to bike to work, once my head clears up. I will  stare up at the stars at 5:45am in wonder and say, “this is beautiful”. I will continue to wear my helmet, bike lights, reflective jacket and all the other reasonable gear I can wear to make the road safe for me and others.

To you I say: “Seek Joy“. Keep seeking your joy, but be smart and protect yourself for yourself and those that love you.

I’m In A Lexington State of Mind

It’s not NY and that’s the point.

I live near Boston, within the zone where self concern and whatdoIhavetodonext is almost always on the front burner. So, sometimes I need to escape that mindset and wander out to….Lexington Center. It’s not far but it’s far enough to feel the shift to a lower gear (obvious bike reference as the Minuteman Bike trail run basically right through the center). It’s far enough where, in the coffee shops, there isn’t a fight over every seat and every person isn’t plugged into something. As I look out the window this morning on the busy center there are parents bringing their children to a Halloween event. There are bikers discussing their loop on this crisp Saturday in fall. There’s a Alaskan huskie next to her owner gathering the attention of passer byes (a child dressed as a pumpkin with Dad is torn between fear and interest). There are a few people sitting numerous public benches simply enjoying the morning and their cup of coffee. On the way from my secret parking space to the Peet’s I ran into a pair of couples dressed as: Dorthy, Tin Woodsman, Witch and a Leprechaun. I’m sorry I don’t think I’d run into that at 8:45am on a Saturday morning in Cambridge.

Sometimes I need Lexington Center. I can’t wait to come here when the snow starts to fall and sit by the big glass windows and drink in an even slower gear.

Giving of oneself

The New Yorker magazine ran an interesting article in the July 27th issue titled “The Kindest Cut” by Larissa MacFarquhar. It was about kidney donation to strangers. It explored the perception of it and the results of it.  One portion fascinated me not only because of the exquisite wording but the insight as well:

“What, then, is it about saving a stranger by giving a kidney, a far lesser risk, that people find so odd? Do they feel there is something aggressive about the act, as though the donor were implicitly rebuking them for not doing it, too? (There is no rebuke in saving a stranger from drowning–you weren’t there, you couldn’t have done it. And you can always imagine that you would have if you had been.) Or perhaps it’s that organ donation, unlike rescue, is conceived in cold blood, and cold-blooded altruism seems nearly as sinsister as cold-blooded malevolence. Perhaps only the hot-blooded, unthinking sort can now escape altruism’s trainted reputation, captured in the suspicious terms for what people are really engaged in when they think they’re helping (sublimation ,colonialism, group selection, potlatch, socialism, co-depency–the list goes on).”

Wow. Yeah. Why can’t we think of good of this act of donation? What’s wrong with us (or me)?

loons, between the cries

[A journal entry from my vacation at lake front property.]

Loons are not silent when they are not nature’s mournful cry. No, they make a small hooting sound to each other, like small talk at a party before they must say something loud and meaningful. I heard the loons first by their small talk while reading on the dock. It’s the little things that one learns that is fascinating.

Just before it rains..

[yet another journal entry while on vacation.]

There is a moment before the rain starts when just a few scattered, random drops fall on the waters of the lake. They are so few when they fall that if you are lucky and there is no wind, preceding the impending precipitation, they sound like the individual strikings of a harp’s strings. Random, no mind to melody or rhythm.

Rain

[A journal entry from my lake front vacation.]

There are very specific types of rain. This is not a new thought–I believe the native American Indians categorized rain and named them uniquely. Perhaps categorized is too far, but one certainly could after experiencing so many types of rain at the lodge (my vacation spot of choice). But one thing is constant for today’s rain, it is not the ending type of rain. No, most certainly it is not. The advantage is, however, that again I get to be lazy with no remorse.

Generational Law

“”I am increasingly persuaded that the earth belongs exclusively to the living and that one generation has no more right to bind another to it’s laws and judgments than one independent nation has the right to command another.” “
Thomas Jefferson

I was watching the mini-series “John Adams” starring Paul Giamatti and Laura Linney and the actor who played Thomas Jefferson recited the quote above.

The quote resonnated with me because it’s something I’ve been thinking of for a long long time.  Time’s passage alters connotations and denotations of the words comprising laws and the governing documents made from them. I’ve often said on issues of healthcare are that “life” in the famous line  “life, liberty and the persuit of happiness” now must includes healthcare. Sadly my research for this entry shows me that this phrase is in the declaration of independence not the Consitution so therefore I can no longer use that as a basis for universal healthcare. But nontheless despite that mistake on my part, Jefferson considered and voiced with great clarity and succinctness what has been nagging me for many years. Laws must be reconsidered as time’s passage alters their meaning.  Society changes. Words, given definition by society, are not static.  Jefferson was concerend that the documents he was helping to create would bind subsequent generations to their words and meaning unfairly.  It is amazing that this profound thought was voiced at the same time they were making their historical governing decisions.

Follow

Get every new post delivered to your Inbox.