[ evanbittner.com ]
I've got a random number generator with a Uniform Distribution - Now I want to turn it into a random number generator with a Poisson Distribution...
11:29 PM 2/22/2010
Right about now, you're probably saying: "What?"
I want to write a function that returns random integers from zero to infinity that follow a Poisson distribution with a given lambda. I expect that I could take the random floating point number from the pseudorandom generator I've already got, count up from zero, subtract & multiply that result suitably so I can test it against zero, and break out of the loop when it accepts, leaving me with the last counter value as my output. I just need to figure out how to do this properly for any value of lambda.
Sorry, this is just the geeky sort of thing that occupies my mind.
In the desired distribution, there is some probability of having the result zero. This corresponds to a segment of the uniform distribution that should be coming from my uniformly distributed floating point number. I can calculate that on the fly. Each time through the loop, I can calculate it again. All those numbers will add up to 1.0 'exactly'. But, with rounding errors, at some large number of times through the loop, I will have subtracted the whole 1.0, guaranteeing that the thing exits, but eliminating the possibility of larger numbers occasionally getting spit out.
I thought it might make for simpler math if I worked out some recurrence relation of one term to the next, so that after subtracting from the random input, I could multiply by some factor that I would otherwise need to divide by while calculating the next term. That way each part of the next subtraction is simply larger by the same factor, substituting one multiplication for one division.
Whether this is an efficient way of doing it is another story... Large values of the parameter lambda will cause most trips through the code to loop many times (the expected value of the distribution is lambda, after all...). I had been thinking about a general procedure for converting the relatively 'continuous' uniformly distributed random numbers into another continuous distribution - I would need a special inverse function tailored to each distribution of interest. And, then I realized that it might make sense to tackle a discreet variable first. (Oddly, the internal representation in the computer has to be an integer.)
In ruby, I think you get something like the following. (Comments start with a pound sign.) I can fix the loop statement later...
def poisson(lambda)
x = 0
uni = rand
# We could always pass a block for 'rand'
cut = Math::exp(lambda)
#loop - I'm too tired right now to look it up...
break if (uni - cut) < 0.0
x += 1
cut = cut * lambda
uni = uni * x
# float uni times integer x returns another float
# lambda can be integer or float
#end loop
x
# which returns the value of x
end
'x' is the counter, which spits out the end when the test succeeds in breaking the loop. 'uni' is for uniform, which gets the system's idea of a uniformly distributed random variable. 'cut' is the fraction of the remaining segment that we subtract for the test. That recurrence relation I was talking about involved the constant e-to-the-lambda which can be assigned right away, raising cut one more power of lambda by multiplying lambda, and putting the next factorial in the denominator by dividing by x. Flip that division around and multiply uni by x to push it further right across the number line, then subtract larger and larger values of cut to pull it back to the left. Smaller and smaller fractions of that uniform distribution try to escape by growing too big for any of the subtractions to catch them, so this method does raise the possibility of an infinite loop, and suggests an arbitrary cutoff point for x, at which (we hope) it won't matter too much.
Ta-da!
Now all I need is some graphs...
Now that I've actually keyed it in:
9:26 AM 2/24/2010
It didn't work right away, but that's alright, because I had a testing procedure in mind... Lambda does not have to be an integer, but if it is, this could be clearer: Compare the random value from the uniform distribution with the function output. That value is approximately the Poisson random variable's cumulative distribution function for that output. If the input is close to 0.5, the output should be lambda. (For non-integral values of lambda, the integer outputs will cluster near it.)
Ruby offers the ability to pass code blocks to a method. I used it to override the system's existing random number generator - the code defaults to that if no block is passed, but I can send it any other fancy random number generator I want. Or, send it a plain old number for testing purposes. (I am reminded that in production code, you would be likely to write your load your own random number generator with the same name from a library - Ruby lets you overwrite a lot of existing definitions...)
Right away I could tell something was wrong with what I wrote above. There was an infinite loop waiting to happen, but my code included a loop exit at 32 times lambda. I was testing the subtraction of cut from uni, but I wasn't altering the value of uni. Duh. If you plan to subtract then test repeatedly, then you'd better damn well store the result of those subtractions. So now that's fixed, and it looks like it works. I still need to plot out...
Inverse Function
Passing my own numbers to the method using a code block, I was able to demonstrate how a uniformly distributed random variable is transformed into some other distribution. Each different distribution will have it's own special curve. I passed in tiny increments and scanned it like an oscilloscope. See how a large chunk around 0.5 flattens out at 8? This function will give you a lot of 8s "at random". Notice the stair-step pattern? That's the integer output vs the floating-point input. If I could show it, this graph would go off the chart as it approaches 1.0. Instead, I've got an arbitrary maximum output value from limiting the loop iterations. Otherwise, the rest of the chart would scale down too close to the bottom to be much use.
I'm a little stuck on how to proceed here.
In the eternal play of ideas, they stick and slip, stick and slip. Ideas arrive in my head like passengers on overfull trains way off schedule. Everything I attempt to do is clobbered by the arrival of more ideas. I can't even hope to keep track of it anymore. I should simply be able to work through the accumulated ideas like the shoveling of too much snow after it has finally stopped falling.
10:59 AM 2/13/2010
I just spent some time reading Market Skeptics: The 2010 Food Crisis for Dummies. It played right into some other things I've been reading lately, mostly on Globalization and Markets...
In Mark Elvin's "The Retreat of the Elephants: An Environmental History of China", he quotes from Donald Hughes's "Pan's Travail" that [...most ancient cities in Eurasia also] placed too great a demand on available resources, depleted them within their sphere, and then went as far as they could to gain access to additional resources, until that effort also failed.
Hughes was writing mainly about the Roman Empire, which excelled at the basic pattern of cities with a large "ecological footprint". Cities are good and evil. Perhaps that calls for some moderation - some balance? We have always needed cities as gathering places... Maybe we'll just gather on the Internet from now on?
Getting Into Arguments
5:42 PM 12/9/2009
I have recently been reading a copy of Lawrence B. Slobodkin's strange and wonderful volume "Simplicity & Complexity in Games of the Intellect" from 1992. Slobodkin took a lot of his ideas from Johan Huizinga, who I have yet to read. It was with this book in hand last night that I was forcibly reminded that some people do not know how to conduct an argument. Either they are unable to distinguish fact from opinion (mostly their opinion), or they are socially tone deaf to the various motivations for arguing. Quite possibly these people have spent too much time on the debate team and lost their sense of humor: There are times that call for open-ended, cooperative searches for truth, and there are times that call for the competitive besting of your opponent in the rhetorical arena - and I am based in favor of the former.
Richard A. Lanham is another interesting source, who in "The Economics of Attention", remarks that human motives exist on a spectrum ranging from "Game" to "Play", similar to what I just said: Game is the competitive contests, and Play is the cooperative searching. Game is opposite to Play in the same way that "Work" is: Games are to be won, and it is effort that tips the scale. Play, on the other hand, is not about those dichotomies of win and lose... Does it even have a purpose?
Look Before You Leap
One major problem I have noticed with people who argue is that they jump into the middle of conversations before they can possibly know what is at stake. They think they can show everybody how whip-smart they are. I'm not excusing myself: I tend to do it too, if I've got the energy. I worry that the problem involves people listening only for things that interest them, and not observing the whole situation. Some of us spent a lot of time educating ourselves on one subject or another, and it might seem wasted if we couldn't contribute something meaningful on short notice. Unfortunately, these contributions are usually misplaced. Proper discourse requires a set of shared premises, but take it to the extreme and it might be hard to imagine any discourse at all.
I have made a lot of broad assertions in my time - Statements that could be refuted with a simple counterexample - but to my amazement, people who care enough to open their mouths at all miss it completely. I can be in the early stages of an argument, proposing some foundations, and an excitable 'opponent' will jump right in and start tearing those apart. I haven't even made it to a thesis yet, and we're bogged down with disagreements of less and less interest. At best, I'll become obsessed with those preliminaries. At worst I'll decide it wasn't worth bringing up in the first place. Often my opponent thinks they have 'won' at this point, when it only represents a complete failure to talk about the same thing.
Put another way, I witness a lot of people arguing at cross-purposes, not head-on. Some of the same ideas, just phrased in a different way - not an opposition at all.
Building The Pyramids
The other night, someone I know asserted that humans always had science. I wasn't sure at first what this assertion was really about. We have only called it science in the past few hundred years, and by recognizing a certain set of human activities with a term and definition, we have changed how those activities happen. It took some time for me to condense my objections into something worth saying, so I wasn't able to get to far with an opponent who mostly wanted to score a point on me: She said the Egyptians built the pyramids. And, by implication, they observed the world and used some kind of science to change it...
I would require a lot more explanation to know if we agree or not, and sometimes I say things in an argument that are not strictly speaking conducive to winning because I want to elicit more of that explanation. I think there is a difference between Science and Technology. Just because the Egyptians built pyramids, or any of the other interesting examples of altering our human surroundings, it doesn't mean they were applying anything as elaborate as a "scientific method". It is easy for us to slap our current label of that past activity, but it appears that change happens faster with that self awareness, and I say those people didn't have it. I've read books about it, my opponent has read books about it... But so what? We're not starting a book club.
I've got something backwards. I remember now how we got to this point in the argument: When I said that we have more power to alter our world than ever before, it was interesting enough to start the whole thing rolling. "Every generation thinks that". Afterwords, I was able to articulate it better, but too late: You're right! Have you thought about what it might mean if they were all right? Us not destroying the world - or just altering it beyond our recognition - doesn't prove anything about our increasing ability to do it if we're not careful. Yes, past cultures thought they had special new powers to alter their world. Because they did. That's what life is like on an exponential curve: You ain't seen nothin' yet!
But, the Pyramid example actually got me thinking about another metaphor. Maybe we should start a book club, after all. We each assemble our understanding of the world like a pyramid. The books we've read, the schools we've attended, the teachers we've paid attention to: Our urge is to boil it all down, reach that narrow peak of certainty. If you meet someone with opinions, they are likely to have their pyramid completed, and unlikely to disassemble part of it to include new facts. The people who, for one reason or another, have not completed their pyramid, are in a better position to accomodate new facts, but it still requires lifting some 'heavy stones'. In one other sense, we sit on the tip of our own personal pyramids, and to really discuss anything we need to climb down, putting aside much of the hard work we did climbing up there. If someone says - as I have done many a time - "I've read a lot of books about this", then the argument is essentially over. Not much can be said until we return to our corners to read a bunch of each others books.
You can start reading one of mine:
We each see the world through very personal perceptual spectacles. It is obvious to observant adults that two-to-four-year-olds develop a personal set of natural laws - not necessarily correct, nor intellectually deep, but nevertheless adequate summaries of their perceptions. Things that smoke are hot, kittens can scratch, parents can grow angry under suitable stimuli, and so on. A child sorts natural phenomena into classes of events that are expected to have different properties and therefore must be approached differently. Scientists and philosohpers use a finer and more self-conscious system of categorizations. Sometimes the children are wrong in their expectations of how things will function. But sometimes older intellectuals are also wrong.
In light of that recent argument I had, this is pure gold. I was holding the book in my hands as I spoke! I was talking about things I had just been thinking about. It didn't help all that much.
Also, read about the
Dunning-Kruger Effect
Apologies For Not Posting
6:04 PM 10/27/2009
I'll have some stuff soon. Some of the things I do at work are a secret, but I can talk about the garbage business in a general way, why I get annoyed listening to the same 20 songs on the radio for 15 hours, and there might be a few photos...
Verizon Fail
11:59 PM 10/13/2009
I've been working pretty hard for EnviRelation this week, driving small trucks, hoisting bins of garbage... I have plenty of stories to tell that I probably shouldn't. Let me just remind you that 1.5 tons of unfinished hotel meals - I swear it was radiating heat - does in fact give you the urge to vomit. But, so far, so good. We're using rented trucks with less capacity, so it's not the normal procedure that I am learning right now.
Much of today I spent babysitting one of the trucks: Making sure it wouldn't get a parking ticket. I came out early to move it from a place with utility digging scheduled, and then I had to run some company errands. I found a place to get coffee - there's a big loading dock next to Sticky Fingers on 14th & Park - and I got more practice driving backwards in tight spaces. While I was parked along the curb, some fellow put his little sports car in the shadow of my gate - I couldn't believe it. I saw him pull in and just disappear. I was in no hurry to go anywhere - just sipping my coffee and waiting for telephonic instructions - so I hopped out and when he returned with his coffee to drive away I smiled, said hello and mentioned that I wanted to be out of the cab so I couldn't back up and crush his car.
Instructions did not come. I returned to find another place back in my neighborhood around the light industrial and overpriced luxury condos. I got a lot of writing done in my notebook just sitting in the cab all morning. And, I never saw parking enforcement once. Around lunch one of the bosses said I should take a break, so I went home to get a few things done...
My computer was running a little slow, but that shouldn't prevent me from sending email. I processed some photos from the other day and wanted to send one to a friend over email. An error came back about my SMTP server failing. Okay, what's wrong?
Verizon sent me a voicemail message about a change that might affect my email. There is a web page to 1)determine if you are affected, and 2)what to do about it. They are blocking outbound port 25 requests because many people have computer viruses that send junk mail out, unbeknownst to them. So they are changing the port for SMTP. This doesn't affect web mail systems, because those systems do everything through HTTP. Different port. So I'm supposed to change the port number for my outbound SMTP requests - as if that is going to be enough in the long run.
Well, I did that. I followed the instructions, and it still isn't working. Isn't my SMTP server (hosted with my POP and HTTP servers) supposed to know that I'm using the new port number now? Verizon didn't say anything about that. I need to put more thought into it, but I'm getting up early to work again tomorrow.
Some Results
My hosting company has a Wiki, and a quick search revealed this: with your provider to see if they employ "port 25 blocking". If they do, you will need to use their SMTP ser...
I can't remember my Verizon email address. I don't use it for anything. I will need someone to remind me what it is if I am going to send all my outbound email requests to their server - I have to log in.
A Moment of Excitement & Hours of Crime Scene
4:11 AM 10/11/2009
I awoke to the sound of gunfire.
Actually, that's not true... I awoke to the sound of somebody singing. That may be the weirdest part. I was lying in bed, listening to some dude out on Columbia Road attempting a version of "Synchronicity 2" by the Police. It requires a sort of bellowing. It would have been better if he knew the lyrics.
In my half-asleep state, my main thread of reality was the sound of people out in the Road. Which is why I distinctly experienced the sound of gunfire. No doubt about it. It was almost lyrical: A story told popping; Information, if only I knew how to read it. This was no quick discharge: It had prosody. It had timing. Later I would learn that two guns were recovered - A dialogue.
I'm an observer. Not a particularly objective one though, I'm afraid... I'll collect the impressions I can get, but I have little hope of ever piecing the whole story together. As it turns out, there are a lot of neglected stories on the perimeter.
Within a minute, the police cruisers were darting up and down the block, sirens blaring and engines revving. I put on some pants, grabbed my phone and a camera, and went looking for trouble. First, to the roof for an overview. A bad choice - most of the activity was blocked from view by a building - but, it told me where to go next.
I came out to the corner to find police already cordoning off the intersection of Euclid and Champlain, separated from Columbia Road by a tiny triangle of park. I skirted the edge, trying to see from different angles. There wasn't much to see. A few people were sitting on the curb in handcuffs. Some officers were scanning the ground with flashlights, while others were putting up yellow tape. There were no ambulances, so it would seem nobody was hurt. I walked over to 18th to see the crowds of closing time... and they were all oblivious. Maybe there is a lesson there: Once the shooting stops, the danger is gone. Or, that's the feeling.
The bars weren't quite closed yet. Last orders had been called. I poked my head in to say hello to Carina at Asylum, already busy cleaning up. She made a big deal about my new hair cut (shorter than it's been in years - I think she secretly liked my pony-tail better), and I told her what I knew about the shooting: That she was bound to see them still investigating in on her way home... I returned to see what more I could learn by gawking.
Crime scenes can have a social life all their own. Some of my neighbors were out. Many people attempted to duck under the yellow tape and were chastised by blue-uniformed authority. All of them were simply taking a short-cut ("But, I'm parked right over there..."). Since nobody was injured, the real victims were those who were inconvenienced, and many of them sounded like they needed a support group anyway. Attention condensed on two young ladies who were in their car about to drive away when the shooting started. They mimed the shooters holding their guns sideways, like in the movies. One of my neighbors was boiling over with the "why can't anything be done?" nonsense and the exasperation over police procedure, and somehow he got into an argument with one of the witnesses. A few minutes listening to that, and I couldn't sympathize with either of them anymore. I noticed one of the cops came over and put on the charm with the witness, which was a lot more pleasant for her than her catfight with a middle-aged gay man. I also thought it was strange that she was not terribly shaken up about the incident, despite her constant bragging about the being shot at part. I kept my mouth shut.
Quite a few police cars were parked behind the bike shop on Euclid. The K-9 units came in - I heard a dog barking, then some officers brought a dog over to sniff around. Our neighbor started in on how unprofessional it was for the police dog to be barking - It played into his existing rant about the crime scene circus, and - don't get him wrong, he has friends in the department who do a good job - but he's going to email Councilman Graham and Mayor Fenty first thing in the morning... But, I think the dog barking was a neighborhood dog, upset by all the activity and that new-dog smell. One of the witnesses was attempting to communicate with somebody on her cell phone - the boyfriend. The other girl started berating him - she got into a tussle over possession of the phone so she could finally tell him what a self-centered jerk he was for being insensitive about them running late on account of being shot at, and the cops had a tense moment over the need to break up the imminent violence. These little misunderstandings were the real story. I kept my mouth shut.
Later on, another young woman came up Euclid to gaze at her parked car, trapped in the thick of it. "I'm the silver Audi". After the witness statements had been taken, she was able to get some guidance. As activity trailed off, the perimeter tightened a bit, and an officer agreed to have a look: Her silver Audi was probably not damaged, but the car behind had a window shattered and would need to be taken to the lab. She wouldn't be allowed any closer yet, because the crime scene investigators had not been by to collect the shell casings yet. Some poor idiot had rolled up in the moments after the shooting and got blocked in for the night. That car was stuck double-parked next to the Audi. More tidbits of info were let slip, and I pieced together a plausible scenario: Two hot-headed ghetto kids in a gang turf war, blithely unconcerned about bystanders or property damage. The suspects, from what I could see, were more bored than anything else. About as inconvenienced as the people who had to walk an extra block to their cars. I had a minor "peak-oil" moment when I wondered how many more years are left in "happy motoring" America... How many people would come from miles away to dance, drink, eat jumbo pizza slices and shoot at each other? How many police cruisers would show up when they did? I wanted to say something, but I kept my mouth shut.
Sorry, I didn't get any pictures.
Cell Phone Boogie
11:40 AM 10/10/2009
I got a cell phone last week. I looked for the cheapest plan I could get. When I told my sister, she said she would send me an old phone that she doesn't use anymore - a phone running the mobile version of Windows. It turns out I can't use it as a phone. I was perfectly happy with my little phone - the first cell phone I have ever had. I just needed to be able to place and receive telephone calls more than five feet from my apartment. (I think I could stretch a phone cord that far out onto the fire escape...)
If you haven't been ignoring the technology the way I have, you probably know something about it. I never understood how people enjoy using cell phones. To me they are a tool, and that is all. I find it mildly infuriating to have a conversation on a cell phone. The fury builds up as you stay on the line, like hot peppers that don't seem so hot until ten minutes after you've eaten them. Telephone calls are something of a waste in my mind. There are people I want to talk to, and it reminds me that a face-to-face conversation would be better; There are people I don't want to talk to, and an email would be better. My plan, cheap as it is, has unlimited SMS texting, which has been an overpriced scam for many carriers. A 150 character text message requires the same bandwidth as a couple milliseconds of voice. Such short messages create such a slight load on the network that it could be given away free. It's "too cheap to meter". But, everything digital can be metered.
My phone doesn't have a SIM card. I am on a CDMA network. I assumed that I knew what Code Division Multiplexing was, but I was still wary of thinking I knew how the technique was applied in this instance. Standards are a lot more than basic principles.... A quick look through Wikipedia confirmed it for me: I learned about CDM in engineering school. Nothing terribly specific - it's more complicated to describe, but it solves some special problems with moving transmitters, interference, and security, so it's popular for cellular service.
Mosaic Tiles
11:11 AM 10/6/2009
I've been brainstorming lately, trying to come up with a better blogging system. Not too difficult, unless you've got a short attention span like me... Uh oh.
Problem: A lot of thoughts pop into my head at inconvenient times. I've heard a lot of good advice on how to deal with this problem, and I've even taken some of it. Carrying a notebook was a no-brainer. My sister suggested a voice recorder, but I'm not sure when I would listen back to what I recorded. I already blog. I'm scared of Twitter. All of the suggestions are certainly improvements on doing nothing, but it doesn't change the fragmentary nature of my thoughts to begin with. What I really need is a better way to file my utterances. Whenever I can't stop to write, or when I get "writer's block" (whatever you think that means...), I still have an electric crackle of thoughts in my head. Imagine a Geiger Counter.
In a computer's file system or database, you need a name for everything. It doesn't have to mean anything. It just has to be unique. On the one hand, if I don't pick something meaningful, I might have a hard time ever finding it again / thinking it was important. On the other hand, if I stop too long to craft the perfect name, or sufficient meta-data, I might have lost the thought completely. What I need is a routine that minimizes those problems. I also need my computer to assist me in following that routine. Total freedom is an illusion. Operating systems that make total freedom possible are just ropes long enough to... well, I won't say it.
Finding just the right word can be just the hook to hang everything else from. It shouldn't be so meaningful that it constricts, but it should be meaningful enough to evoke a few relevant ideas. Arbitrary yet resonant. A poetic tension, perhaps. Like a computer password needs to be memorable to you but not obvious to anybody else, and frequent use of any arbitrary choice invests it with meaning. Just think of your phone number or bank PIN.
Sets & Enumerators In Ruby
9:08 PM 10/5/2009
I don't know why these things pop into my head... I've got Ruby on the brain, I guess. I was reading another non-computer book when a real-world problem struck me and I realized that I didn't know how to solve it in Ruby.
Ruby has an Array object to hold ordered collections of other objects. Being an intensely object-oriented language, Ruby consists mainly of method calls on objects. Message passing is another way to say this.
Normally I don't find this confusing. But, on top of that mechanism is a layer of "syntactic sugar": What look like expressions are really method calls in disguise, and not every line of Ruby has to look like gibberish strung together with periods. Where you might normally think adding two variables together and storing them into a third: "c = a + b" is something like "c = add(a,b)", in Ruby you have something more like "c = a.add(b)". The first form asks the system to add a and b together, while the second form asks a to add b to itself.
Sound too subtle? It makes a big difference if a and b are not the same data type. The system would need a function to handle the addition of any two data types. Everything is just an object in Ruby anyway. An object's "class" is the messages it will respond to. All the classes that respond to some particular message are in that one sense interchangeable. The "+" symbol works great for adding two numbers, but it also concatenates two strings. Try it with two different types of data, and you may not get what you expect. I thought maybe a number would be converted into a textual representation then concatenated to a string, so that 'a' + 6 would give "a6". It gives an error instead.
Arrays are ordered collections, but they make sense for dealing with the sets of mathematics. You can get set union with "|", and set intersection with "&", because they have the analogous meanings of "or" and "and" in other code.
The Array class is a strange beast it has methods you can call to get it to act like a stack or a queue. Since it can hold other Arrays as members, you can use it for matrices or trees; Inserts and deletes based on index numbering or pattern matching; Sorting and reversing; Iteration through the members one at a time to perform a specified operation...
All that, and I can't figure out how to do combinations and permutations. Set multiplications; Scalar product, Vector product and Dot product... I wonder how I would go about figuring that out... Here is an example of multiplying an Array and a Number: (In all these examples I follow the convention of displaying the result of a Ruby expression on the next line)
[1, 2, 3] * 3
=> [1, 2, 3, 1, 2, 3, 1, 2, 3]
Alright. That might be useful in some contexts. What would you call that? A repetition operator? I was hoping for something along these lines:
[1, 2, 3].scalar_product(3)
=> [3, 6, 9]
Nothing I know of fits the bill. I might have to roll my own. Ruby is gracious in that way: You're allowed to modify common object classes, opening it up and adding new methods or replacing old ones. The operator symbols can even be reassigned if you want them o have a different behavior. I'll try my hand with scalar_product:
class Array # oh, yeah: comments begin with # and run for the rest of the line...
def scalar_product(rhs) # rhs... think "Right Hand Side"
self.collect do |item| # "self" within the class definition represents
# the particular instance getting the call; the "receiver"
item * rhs # collect iterates through the Array and
# returns a new Array of the results
end # done looping through self
end # done defining scalar_product
end # done extending the Array class
Don't you like it? It's very terse. My comments don't really help much.
The upshot of all this is that the "collect" method will return an array where each member has been modified. Collect is an enumerator. Like all enumerators, it creates a loop based on the contents of a collection - one time through for each member. Arrays are not the only kind of collection in Ruby: Ranges are useful, too. Some methods construct an array or range from something else and return it, so enumerator methods are popping up all over.
But, as I said before, the members can be objects of any class. When I do that "item * rhs" operation, it could be multiplying any two classes, and I won't know in advance what kind of results I will get. Recently, I have learned a few tricks. It is not needlessly complicated to ask 'item' and 'rhs' to return a numerical representation - but, that might not make much sense either. This puts me in the land of difficult choices, and that always annoys me...
Yet more complicated is the dot product. I have to iterate through two array objects simultaneously, and deal with the same issue of member classes. I've got some thoughts on the "each_index" method.
But the really tricky problem is the "set of all subsets" problem, which I didn't mention yet: I want to be able to do something like this, with a combination and a permutation thrown in for fun:
[1, 2, 3].all_subsets
=> [ [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3] ]
[1, 2, 3].combinations(2)
=> [ [1, 2], [1, 3], [2, 3] ]
[1, 2, 3].permutations(2)
=> [ [1, 2], [1, 3], [2, 1], [2, 3], [3, 1], [3, 2] ]
You may notice the basic properties involved: "all_subsets" is the set union of "combinations" run on 0, 1, 2 and 3. Self will have access to a count of its members, so you could build the former upon the latter. If only I knew how to build the latter... I suppose all I really need is the index numbers, coincidentally the same as the members in this example.
Scenes From A Birthday
11:24 AM 10/3/2009
It was my birthday on Thursday, and most of the day was rather dull. I spent a good chunk of it in the library.
Eventually, though, as night came on, I headed over to the bar. Another event was taking place: One of the waitresses is leaving town and this would be her last night. I was keeping my birthday a secret, but I didn't do a good enough job. Wednesday night during trivia it came up in conversation, and I knew that news would travel fast, even traveling from one heavy drinker to another, as it did.
Being socially awkward, I value people who take some interest in finding out about me. Most people do a pretty good job of ignoring me, even when I actively reach out. It's quite possible that my idea of friendly makes people uncomfortable, or that my attention drifts somewhere else in conversation, and so I tend not to work too hard on seeking people out. I have a bad reaction to hearing other people's conversations, which I tend to find vapid or just plain boring, and I withdraw inward to more interesting thoughts, read from a book, or make notes in my notebook. The night of my birthday I had a brand new mobile phone to learn, which was a prompt to exchange some phone numbers, but drew me away to an interior world of glowing screens, thumb presses and electronic beeps. Alcohol might be a social lubricant for other people, but it only enhances my feelings of isolation. When a conversation moved on without me, I started thinking about my camera, and the challenges of the poor lighting conditions in the bar.
I liked some of the results, as shown here. My camera has caught on that I hate flash photography, and consider it an extravagant waste of battery power. That was nice. I found warm light and cold light in odd alternation, where I might have expected different. A little tone correction in Photoshop cleaned that up somewhat, but looking at them now, they are still too dark for my tastes. You can tug at the exposures quite a bit, but that can make the images too grainy and saturated... So much blurry red and yellow that can't be mitigated. In fact, my normal routine is to preview the extremes of a treatment when I'm editing the file.
I might also note that the little LCD screen is misleading when I try to make snap judgments about the blur of shots I have just taken. Many things seem crisp enough at first glance, but appear fuzzy on the computer screen later. This is aside from the artistic qualities of motion blur. I really liked some of the impressionistic transformations I got. Someone unwittingly turns their head midway through an exposure, and they come out two-faced; Janus-headed. The ladies were not as impressed with those results as I was, but save the straight shots for the fashion magazines... You can't hardly even identify the person, and motion blur emphasizes the kinetics of activity.
I pushed the trigger through a whole sequence of shots looking for a perfect steady one, but in the end, I just liked the sequence, so I made another animated gif. Remember Calligraphy Girl? This time I assembled a much larger collection of frames without messing it up and starting from scratch a whole bunch of times...
The Outer Reaches
1:15 PM 9/20/2009
There wasn't much going on online yesterday morning, and the weather was so nice... I decided to see if my friend Christina was interested in doing anything. My call woke her up at noon, and she was grateful in her own special way that I did. I suggested meeting up in Arlington or DC, but as I expected, she was loathe to leave her apartment in Vienna, so I took the subway to her.
In all the years I have known Christina, she has lived mainly in Vienna, and this is the third time I have visited by public transit. It takes a lot of time, and on such good weather, I don't mind taking an epic walk, but this time I got lucky with the bus schedule. I still planned to sit and read for several hours. This time I had James Howard Kunstler's "The Long Emergency", which I picked up a the library that day.
Christina worked at Whole Foods for a few years, but not anymore. Most of her social life in Vienna revolves around former coworkers. She is living with her fiancee Bob right in the center of town. Bob worked an early shift at the market, so I got there right before he arrived home at 2. The three of us drank coffee, played with the cats, and chatted. All of the potential jealousy and tension you might imagine would attend the disruption of an old boyfriend into the space of a planned marriage and its native uncertainties was surely there just below the surface, but I am doing everything I can to be a supportive friend whatever the outcome. I didn't really know what to expect in the first place.
Just as I had awoken Christina at noon, she called her friend John and woke him at three. John is a much younger fellow, and she has been telling me how much he reminds her of me. I suppose. There was a DVD in their living room of Jan Svankmajer's "Alice", (which I've never seen, but my neighbor Paul has shown us plenty of vintage Czech animation on Sunday nights) - John lent that to them.
When we finally finished our coffee, Christina and I went walking out the WO&D trail west of town to spend the rest of the afternoon in the park with John. It was about two miles along the trail when we found him walking towards us. Christina wasn't paying attention - perhaps distracted by a sudden crowd of runners and cyclists vying for space to pass - when I noticed a young man in jeans and a t-shirt who didn't quite fit with the fitness crowd. That was John.
The first chance we had, we broke off the trail and went into the woods. I took some photos - I left everything but the camera back at Christina's place - and some of them probably turned out. We followed a creek for a while to the fringes of Fairfax county suburban development. Dogs came running to meet us at the verge. John eventually guided us to a groomed horse trail with jumps aplenty, but we never saw anybody riding - let alone jumping. I tried my hand at botanizing, fighting my camera's autofocus all the way.
John's house was just across the railway trail in yet another suburban cul-de-sac. We saw more friendly lawn dogs playing at guarding their homesteads and interrogating us with panting tongues. John fixed us a small snack, and from the patio we saw many deer grazing the mowed field out back.
Before dark, Christina and I returned to town on the trail to meet Bob already preparing a dinner of leftovers at the apartment. We ate, listened to music, then Bob had to retire to bed, weary from his odd work schedule. I looked at my watch on completing dinner to find that I had missed a bus by five minutes, and would have to wait it out for the next one that would arrive an hour later. Christina tried and failed to find a CD she borrowed from me three years ago.
With night in full force, the cats were frisky, and chased most of the toys we threw.
Notes
I just finished the text of Burgess's autobiography, V2 "You've Had Your Time" today before I came to the library. The tale stops around 1981, and somewhere I saw the remark 'multi-volume autobiography', so I have to imagine that there is a V3 floating around somewhere.
Tired of This Routine
12:59 PM 9/18/2009
Here I am, at the library again.
It has become a little tedious to go all this way, just in case something important happened online. Perhaps there is an important email message. Today there wasn't. But, you never know. And it's better in the long run to clear out the junk, so that it's not overwhelming to browse through and identify those important messages.
To make matters worse, I went to Mt. Pleasant first, because I knew they would be open early... And, their computers are all down again. So I went walking to Cleveland Park again, not sure whether they opened at 1pm. I killed a little time by going through the Zoo. Is it my imagination, or do Cuttlefish and Elephants share an ineffable affinity?
Hey: I'm in a library. Maybe there are some computer books here. Something on Rails, maybe? There are not. I'm still not very good at learning some things off the Internet. Computer languages are a good example. (Is that irony?) I've always needed to consult print materials when learning anything about computer programming - even if there are useful resources online. If I had three big computer screens like Al Gore, I could see more material at a glance. In lieu of that... I'll take a book any day.
The computer books the library does have are mostly Windows XP and Vista manuals. That's kind of interesting. I've never had access to a computer running Vista, but I did try to help my roommate fix something on his once. So yesterday while waiting for a computer at Mr. Pleasant, I browsed one of the Vista manuals. It's not terribly different from XP. I personally think it's hard to improve on XP. Don't get the impression that I like it, though... I've simply grown used to it. I'd like to get better at writing programs for Windows, but it seems hopeless. I use an open-source C compiler that will never be as good as official Microsoft compilers. I might as well abandon it for Linux, where it would be worth having more intense system knowledge.
Trivial Pursuits
4:38 PM 9/17/2009
Last night I showed up for Wednesday trivia night at the Reef. I get shuffled from team to team over the weeks as various people show up or don't. Usually the team I join wins.
It happened again last night. There are a couple of regular customers who work at Congressional Quarterly, and they attract a cloud of younger coworkers. Typically there are so many people that we have to split into two teams.
By winning, your team gets $100 off their bar tab. That meant I could have a celebratory whiskey without shelling out. I immediately bumped my arm and splashed a small amount on my t-shirt. No disaster... But, I was wearing the enchanting fragrance of Copper Fox Rye for the rest of the evening.
Writing By Default
2:58 PM 9/15/2009
I'm not sure I have anything much to say right now, but I've got this computer for 70 minutes, and there wasn't much to respond to in my email inbox. I've got a short list of web resources to browse - news, weather, etc., but today is not much different from yesterday. My sleeping computer at home mocks me, so I don't enjoy being there all day. It also makes me feel powerless not having Internet access on a whim. I clearly have some form of Internet addiction, but there is still a lot I can do only on my computer, without Internet, that I can do no where else. (Think of the programming and music stored there) The weather is so nice today, if a little hot - so my normal urge to walk around taking photographs is there.
I mixed up the hours for the library somehow. I must not want to remember. Soon enough (fingers crossed), I won't really need to know... Ahem: it won't quite so important. So I got here two hours before they opened. I went for a walk and read more Joyce. I got a soda from 7-Eleven and had a short visit to the zoo.
I couldn't help thinking about the challenges of productivity. Sometimes, having a short window of opportunity helps me to focus my efforts. Pressure to perform should do this in general... But, it isn't usually that way for me, and I have never really known why: Pressure to perform, deadlines, narrow windows of opportunity can scramble my brain. I'd rather work slow and steady over long sessions. But, there's a problem there too: The body rebels, nervousness kicks in. I fidget.
Reading Updates
2:17 PM 9/14/2009
Today the weather is probably too nice for reading... Maybe reading in the park will work. Of course, I am stuck in a library right now using the computer.
For economics, I've been working through Benjamin M. Friedman's "The Moral Consequences of Economic Growth", which I tried to read once a few years ago. It's a good history lesson, and it draws important conclusions about tolerance in society during prosperous times. Did I mention that I recently re-read "Shoveling Fuel for a Runaway Train"? I'd swear that I did... All this wonderful growth has an awful effect on things like endangered species, but - hey - if that's what it takes to make people more open and tolerant, then let's just trash the planet!
While spending so much time at the library, I grabbed a copy of Burgess's 1993 "A Mouthful of Air", which is old enough now that I might have read it long ago and forgotten. It's not too different from some of the other Linguistics and Cognitive Psychology I've read.
For inexplicable reasons, I started reading James Joyce's "A Portrait of the Artist as a Young Man". Well, it's not all that inexplicable... Burgess was an expert on Joyce, and he mentions facets of the language in his autobiography. I am getting tired of all the detailed Catholicism. It makes a nice reference if you care about that sort of thing. I imagined there would be more of a story beyond memories of churches, religious schools, and monastic orders. The book is annotated, and I find it odd sometimes what they thought I would need to be informed of. Sometimes it helps, and other times I just have to say "well, duh!". My roommate offered his copy of Ulysses, and a separate volume of annotations, but I have serious doubts that I will ever start that. But... it does seem like one of those things any civilized person should have a vague knowledge of.
My 20 year High School reunion is coming up next month. I feel really apathetic about it. It is hard to explain that I don't want to see all of those people without implying that I would not enjoy seeing many of them. Perhaps I would prefer to control the circumstances under which I make contact... But it also might be that this, by any objective measure, is the low point of my life so far. Can I say that without people necessarily thinking I am depressed? Assume, for this discussion, that I am not.
Actually, come to think of it, there is a recurring communication problem here... One I seem to encounter on a daily basis. People are motivated to read a lot into the things I say. It's frustrating. If I speak with the fewest possible words, they let their imaginations fill in what they will. If I take pains to go on at length, they ignore part of it. In my opinion, I do not have a problem expressing myself: It's just that the thoughts in my head are routinely more difficult to express in the first place. It just may be that I didn't discipline myself to eliminate or deny thoughts simply because they were difficult to express. More work for me, though.
I'm still taking a lot of pictures... But they remain on the camera. Still room for hundreds more, and that usually takes me several weeks, depending on inspiration. When I eventually get to transferring and processing them, it is going to be a lot of work. Like when a snake eats a small mammal.
The Library Is Not So Lovable After All
3:08 PM 9/13/2009
After one successful session on the computers at Mt. Pleasant, they stopped working. The reservation system was down, so twelve workstations sat there idle. Many times, the librarian thought they would be fixed in "about an hour" - I even saw a dude working on the problem - but that dragged on for a while.
When I asked if it was a problem only there, or if the computers were down at all the libraries, they answered that it was "the whole system". I am starting to think that they didn't hear the question, or didn't understand it. Today I walked across the park to Cleveland Park, and got on a working computer within ten minutes. It would have been nice to know that I could do that.
Truck Drivin' Man
I have that truck driving job if I want it. I just have to be able to get to Lisbon, Maryland to start the route. Fabulous. I was running through the options in my mind, all of them requiring no small expenditure up-front. Taking a cab would seem to be the most expedient method, but also probably the most expensive in the long run. It's looking rather bleak.
Books and the Films They Become
Sitting around waiting for the library computers to get fixed means I can get a lot of reading done. You'd be surprised how often I used to use my computer during hours that the libraries are closed. They are only open eight hours on a normal day and four hours on Sunday.
I'm to the part of the Burgess autobiography where he has to deal with publicity for "A Clockwork Orange". They let him show his face in public so often that he was sometimes thought to be Stanley Kubrick (ever seen "Color Me Kubrick"? John Malkovich plays a famous Stanley Kubrick impersonator. Not a lot of people knew what the man looked like, apparently...). Burgess also got blamed for the violence of the film. This remark in the autobiography got to me:
I realized... how little impact even a shocking book can make in comparison with a film. Kubrick's achievement swallowed mine whole, and yet I was responsible for... it's malign influence on the young.
Still Waiting
Maybe tomorrow afternoon I'll receive the store credit for the replacement power adapter. I hope... Let's just say, hypothetically, that I had a suicidal friend who forgot I couldn't respond to emails and didn't feel like calling. That would, hypothetically, suck.
Learning To Love The Library
2:55 PM 9/9/2009
Yesterday I went to the Mt. Pleasant branch of the DC Public Library. Today I'm back.
I'm reading an autobiography of Anthony Burgess: "Confessions, Part 2: You've had your time", and I realized that I had never read "Clockwork Orange", and always just thought the title was nonsensical. So yesterday, I located a copy and checked it out. Good thing I did: My library card had to be re-activated. But, once I filled out a form and they processed me through the computer, I could continue using the same old card with it's barcode and ID number.
I heard that the book was hard to read because of the Russian-peppered teen slang. It's not so bad when you've seen the movie and heard them say those words out loud, real horrorshow like. I learned from the autobiography that Burgess wrote a draft and shelved it because he couldn't decide on how to prevent the slang from going out of date too quickly. It was later when he planned a vacation in Leningrad that he started learning a bit of conversational Russian and that provided the solution. In fact, the autobiography starts out in the middle - being part 2 - but, I got a clearer picture of his career from the Wikipedia article. It was a hundred pages or more before the book mentioned his given name - and this after repeated mention of pseudonyms he had published under.
Today I came with a list of things to do on the computer, and signed up to reserve one. A special screen is hooked up to show the reservation queue, and while I was sitting there, it flashed up a Windows .NET error box, but the queue was still visible.
It's a form of discipline, I guess. I can't go online anytime I please, so I try to make the time count. I also memorized the library hours, so I can plan my day around it.
I have a job interview tomorrow to be a truck driver. It's a compost hauling company. I'm trying to figure out how to get a copy of my driving record, which I already know is clean for the past ten years. It's a good thing I had a chance to drive the truck at my old job, but it doesn't sound like much. I'll have to make a big deal of my other stints driving for rock bands. The main point is that I know the roads in DC like the back of my hand, and I have no problem reading maps to fill in the gaps in my knowledge.
My friend Christina knew the company. She used to work for Whole Foods, and they have strict policies about composting their biodegradable garbage.
As I've sat here on the library computer, I have discovered what I need to know about obtaining my driver's record. It's $13 in person at the DMV, and I can go to the one in Georgetown. Fees for a commercial DL are considerably more, so I'm wondering when I'll be expected to shell out for that...
Bad Power Adapter Means Denied Me the Use of My Laptop
11:03 AM 9/8/2009
I'm afraid I can't do much about updates until I get this power adapter replaced. It'll be copy shops and public libraries for about a week.
I was smart enough to buy the $10 replacement plan last October, which saves me $100, but costs me the time to ship it back. I'm at FedEx to print the return shipping label, and the computer I'm on complains that it can't display a PDF in the browser. Wow... That's some good customer service.
The Failed Hot Sauce Run
9:43 AM 9/3/2009
It was such a nice day on Tuesday that I decided to take a quick trip. I was disappointed by the selection of hot sauces at my grocery store, and I remembered that there is a specialty hot sauce boutique in Eastern Market.
I stood around waiting for the 96 Bus over here in front of the bank on 18th Street, but it can be thirty minutes between buses, and that is one sunblasted corner. All that direct sunlight was ruining the experience. So I walked around the corner to Calvert Street, where I knew it would be shady at the bus stop, and it's "upstream" on the route, so the bus would arrive there about a minute earlier.
At that shady, upstream bus stop, I saw this enormous dog hanging out the window of a townhouse. He looked so bored. Clearly, he would have preferred to be outside, and was doing what he could to make it so. I looked up the street and saw no buses coming, so I reached in my bag for my camera. I took position on the front stoop next door, and tried some shots. It's a good thing I stuck with it, because the last one was the only one with a good pose and good framing. That tree kept getting in the way.
Right then, a woman walked up to the bus stop and began talking to me. She said during the hottest part of summer, they would keep the windows closed on that house, and she missed being able to pet the dog from the front porch while waiting for her bus.
This time, when she got close, the dog began to bark. I suggested that I may have spooked him by taking his picture - all that waiting and staring and fiddling with the mechanism - but she claimed that she has taken many pictures of him on her cell phone. She thought the dog knew the difference between men and women, and was suspicious of me for that reason.
Preparing the photo of the dog reminded me of another picture I took a few weeks back: I was on K Street and noticed a tree up on the roof of a newly constructed office building. (By coincidence, that was how I was planning to decorate my apartment - a big glassed-in courtyard on an upper floor with trees inside...) From street level, my impression was of a tree trapped in a cage. I further realized that I could frame the shot with branches of the sidewalk tree - comparatively less trapped - to get an organic counterpoint to all that rectilinear steel, stone, and glass.
I caught one of the futuristic new Metro buses and rode it to Capitol Hill, where I took a stroll through Lincoln Park and down North Carolina Avenue to the newly renovated Eastern Market.
I looked for the hot sauce store, but it was long gone... The market didn't have anything special in that department either - the most exciting thing was the raw meat, which I didn't want to carry home in my bag for the hour it would take to get back. I also declined to wait in the really long line for fried fish.
The trip was a bust.
Reporting From Hobbyville
9:42 AM 8/30/2009
It feels a bit like I've been sleepwalking these days. Let me try to recap a few of the things that have been going on:
Movies About Movies
During a conversation one night with my neighbor Paul the projectionist, we were lobbing movie titles back and forth at each other, and he sent me off with two of his recent favorites: "Tristram Shandy: A Cock And Bull Story" and "Be Kind Rewind". If you know the films at all, then you know that they include a fair amount of movie production activity within the story. I liked "Tristram Shandy" despite the fact that it got somewhat tedious as it went on, and "Be Kind Rewind" was playfully absurd (who gets magnetized?).
Both movies have an important point to make about storytelling, and where culture comes from (more on that in a bit...)
Photos From India
I have been uploading some of my photos from my 2000 India trip to Facebook. Anyone can see the album using that link. I may still set them up here on the gallery page.
Everything I do on this laptop seems excruciatingly slow. Any kind of multitasking involving Firefox or an Office component causes frequent virtual memory paging, and on hot days, even with air conditioning, the computer is in constant danger of overheating. I have to periodically turn it off to let it cool down. The scanner program takes a lot of resources, and I have to commit a horizontal surface to the thing itself. Maybe that's why I haven't scanned more old photographs.
Even now, as I try to type this entry, my computer is engaged in yet another anti-virus pattern download, which tends to spin the disk. My one main complaint is when the mouse and keyboard are sluggish. It makes for a lot of misspelled words, and errant clicks, which can sometimes launch more programs, slowing things down further. If I could redesign this operating system, I would make the interface more interactive. I should never be able to type faster that the system.
Music Theory And Technique
I'm doing a lot of dull exercises on my keyboard and guitar. I hooked up my Roland GR-50 MIDI guitar controller. Now that I've spent so much time playing with sound programming on the XP-80 and the laptop, I have a better feeling for how to use the GR-50's programming. It also enforces a particular kind of enunciation for my fingers. I can drill for speed and see what the detector thinks.
There is also the never ending battle of List/Nyquist on the laptop. I still haven't produced much to show off, but I'm getting better ideas for how to use envelope followers, samples, etc.
Early Modern Japan
I'm slowly working my way through Marius B. Jansen's "The Making of Modern Japan", and occasionally consulting Deal's "Life in Medieval and Modern Japan". This necessitates frequent trips to Japanese dictionaries to see what I can glean from the etymology of the terms they use in Roman lettering.
Culture Studies
A little while back I picked up a used book copy of Scott Lash and Celia Lury's "Global Culture Industry". They attempt to update the ideas of the Frankfurt school thinkers like Horkheimer and Adorno for use with a set of recent marketing campaigns "Seven Cultural Objects": Toy Story, Wallace & Gromit, Nike, Swatch, Trainspotting, Euro '96 (Soccer), & YBA (The Young British Artists movement). Here's a quote:
"Products no longer circulate as identical objects, already fixed, static and discrete, determined by the intention of their producers. Instead, cultural entities spin out of the control of their makers... products move as much thought accident as through planned design or intention."
Sound like fun?
Public Key Encryption on SSH
12:39 PM 8/22/2009
I am not sure why it took so long, but I finally got it to work... Logging on to an SSH session with a key-pair instead of a password.
I blame the documentation. It took me months to figure it out - Or, I mean: Several unsuccessful attempts stretched out over a period of months. But, I could probably explain it to you in five minutes.
In a way, it's a hollow victory. I've memorized passwords before. The password on this web server is particularly strong, but it's not so hard to memorize a string of nine random keystrokes. I say "hollow" because for security purposes, I still have to type in a password to unlock the keys on my laptop. Given how often I reboot, that hardly saves me any trouble.
The important part of all this has to do with eavesdropping. And, that all depends upon how paranoid you are. If someone were monitoring your Wi-fi connection, they could see your password in the stream of information being sent. You type your password in "plaintext".
Here's another way to look at it: Words contain instructions for how to spell them. When you see a word, you immediately see how to spell it. You can't complain that you don't know how to spell a word that you are currently looking at. But, in a world where everything contains a microprocessor chip, this relationship is no longer necessary. I can type one thing, then a computer can convert it into something else. That something else does not indicate what individual keystrokes went into creating it, so anyone who discovers this new form has no instructions on how to produce it.
I had the concept. But then I tried to implement it. That was not as easy... One time I generated a key-pair and saved it. So I had a key-pair... But I couldn't figure out how to get the terminal program to send it. Or, I couldn't figure out if it was being sent. Or, if I had put the thing in the right place. There wasn't one help file, there were three help files from three programs, and they were big files, that I could barely read because I didn't know the jargon yet.
Those files didn't say anything about where the key needed to be stored on the server end. I thought they did, and it would take me a long time to find it. Maybe they do - I got bored and gave up looking. Today, however, I found some hints... There is a key generator program, a key holder program, and the terminal emulator itself. The help files run as child processes, so while I browsed the manual, I couldn't see the program. That means that I couldn't check the very settings I was reading about without closing the help file and losing my place. Fabulous. That discouraged me for months.
After a while, I gathered that there must be a special place on the server's file system where the public key needed to be stored. But, I couldn't figure out the name of the file, or what format it had to be in. The key gen program stores the public key on my disk in one format, and displays it in the window in another.
Normally several hours of reading to learn that I still don't know 1) what the file name should be, and 2) what format it has to be in would be enough to make me give up, but today I was browsing the man page for ssh on the server, and it was many screenfulls of command line options for launching the client on a Linux system (not what I was doing, but all I needed was a clue...), when I spotted it: "~/.ssh/authorized_keys". One of the five crucial things I needed to know - the only five things I needed to know to get it to work, buried deep within a somewhat related instruction manual on something else. Don't you just love the information age?
I had to clean up a few minor glitches after that. For one, I did get the public key file format wrong on the first try, then there was the issue of conflating the "passphrase", "comment", and filename for the private key on my laptop, but after a tractable number of possibilities, I hit upon the correct solution. (Use the "comment" line to remind you of your "passphrase" - it helps. But, the filename has to match the configuration file you saved for the session type in the terminal program, because that's the one that knows to send a key for authorization.)
So, to recap: Now, every time my laptop boots, and I know I want to log on to the server at some point before I have to boot again, I have to key in the passphrase to unlock the key-pair, which can then be automatically sent every time I start the terminal program. So, very little has changed from my point of view... But you'll have to do considerably more now if you want to pretend to be me.
Hold Still, Iggy!
9:49 PM 8/17/2009
This afternoon I bumped into my friend Mitch the dog walker. We were standing in front of a coffeeshop in North Dupont, so Mitch offered to go in and get a coffee if I would watch his dog. I sat on the patio of with Iggy while Mitch went in.
First Dog
According to Mitch, Iggy was his first dog walking assignment. Iggy kept "attacking" our friend Alec. I couldn't believe it: Maybe the heat was getting to little Iggy, because he didn't seem at all aggressive. Perhaps Iggy knows something about Alec that we don't?
Then one day, Mitch wore blue jeans instead of trousers, and Iggy started attacking him... Was it the blue jeans that Iggy doesn't like?
No, Alec always wears jeans, and they must remind Iggy of him.
Execute Format Changes
9:54 PM 8/13/2009
I just made a few alterations around here...
Background is now a mesh pattern from Photoshop, toned to the original color. I swapped out header-1 for a graphic in the font "Dauphin".
Everything else is style sheets: post borders, spacing, color tweaking.
Since I didn't know how long I would be sitting on this particular format, I didn't trouble myself with many niceties. Now that I've been doing the blog this way for a while, and the only back-end infrastructure changes will be in Ruby code... or PHP?... and miscellaneous JavaScript?... It seemed like a good time to settle some cosmetic issues. It's no longer a moving target. This is probably going to be the framework for a good long time now.
Thinking With Type
I pulled out Ellen Lupton's book "Thinking With Type", and after seeing some of the example web pages, I got all worked up. This page is rudimentary because I'm modest by nature. I'm not trained as a graphic designer, and I don't expect the things I do to match that professional standard. But, I do approach skill in an incremental way, so I'm willing to make everything just slightly better if I can.
I fear that I am never going to reach very far with type design. I've never seen anything I made with type look good on my screen, and I see things other people made look good all the time. I can't help thinking this is part of a much deeper neurosis... I'm not actively criticizing the results I get - it's always a very passive dissatisfaction. In Photoshop I've got about a hundred fonts to choose from, and I can spend an hour trying out the options in the 'character' and 'paragraph' palates to no avail - everything looks stupid, or shockingly gaudy. And on the web it feels like I only have three fonts, but I can still spend hours fussing with font properties on the style sheet and come up empty handed.
POP Goes The Weasel
3:42 PM 8/12/2009
Today I resolved to use Ruby to write my own Email Client. While it doesn't rank way up there with "Build an Egyptian Pyramid" or "Write a Bestselling Novel", it does cause you to stagger back a little when you actually begin the process...
I was vaguely aware of a POP3 library in Ruby. All the Internet session types have a library (maybe not ALL - but a lot of them - I haven't checked that for sure). A base library takes care of the underlying packet and socket work, then specific protocols build up from there using object inheritance.
I had the brilliant idea of using different email accounts to manage different mailing lists - should there be any trouble unsubscribing, I could simply deactivate that particular account. As it turns out, it has never been an issue, and my main account is getting spammed like crazy now anyway. But the important part is that I have several accounts that I can use to test my little email program without running the risk of losing anything important - all the messages have already forwarded to the main account. Please... don't look for things to criticize about my system. I already found out why it sucks.
After a couple hours of work, I had my script logging on properly to the mail server, grabbing the emails one by one and displaying a chunk of header plus some of the body on the command line window.
A lot of email programs store the emails in one big long file. It doesn't look that way to you because there is a system of folders for storing messages - 'inbox' being simply one of the special folders that you're not allowed to delete. I discovered that the POP interface is limited to a few specific actions anyway - if you want to get creative about it, the ball is in your court.
Quick Note on Programming Projects
3:02 PM 8/1/2009
Hopefully, before my computer overheats, I can mention a couple of Ruby exercises I've been working on over the past two days. It occurred to me recently that I'm not spending enough time on practical programming. Thinking about web sites ought to be enough, but it isn't.
Riemann's Zeta
This is an interesting function, in a complex variable if you like, that has been studied extensively. Ruby has a Complex math library package, so I thought I should be able to whip up a method to calculate zeta for complex variables.
But, it also meant that I had to think about good ways to generate an interesting range of complex numbers and to chart the results.
One possibility was to practice using Windows OLE routines: Start with a point grid on the complex number plane, calculate the function, then stick the results (I tossed the angle and kept magnitude) in the cells of an Excel spreadsheet, from where I could easily play with chart types for a presentable result...
So here's a poorly labeled segment of the surface that results from plotting the strip between (0.9 + 0.5i) and (1.1 + 3.5i)
I think it resembles what I was expecting to see. Out toward positive infinity, it settles down to a flat 1, but close to the imaginary axis, it develops chaotic ripples as the imaginary parts in the exponents of the infinite series start to jump wildly about the origin. At least, that's my qualitative take on things.
On that note, in the negative-real half, you can expect divergent sums, so I wouldn't bother to plot those. But, I could consider trying out a plot based on a 'count before diverging' method, like they use for those colorful posters of fractals...
Prime Numbers
Related to the Zeta, actually. But, I'm not going for that angle just yet...
It occurred to me after re-reading the chapter about Ruby and "Coding like a Duck" - About Ruby's 'attitude' toward variable type and polymorphism - that I should try to write as general a method as possible for identifying the next number that is relatively prime to a list of numbers.
Which led me to the issue of 'persistent data': Code that always looks at the list so far accumulated and adds one new item to that list. The script reads the list from a file, runs through a loop some modest number of times, then writes the new list back to the file.
Yeah, I could do some back of the envelope estimation, but I wondered how big that file would get, and I knew that as it got bigger, each iteration through the loop would take longer, and that might force me to alter the code. So far so good... Every call to the script adds 1024 new primes to the list, with a progress tick for every 32, giving me a sense of how long it takes. I'm up around the 230,000 mark (6 digits!), and I've introduced the features of 1) only looking at odd numbers, and 2) breaking from the loop when it gets to the square root of the number being tested for primeness. That's only one square root operation for each candidate, and an integer compare for each test division.
This problem suggested some statistical measures. I wrote a first version of a script that prints out a histogram of gap-lengths - how often neighboring primes are some distance apart, by distance. This is useful because it tells you how long a stretch of consecutive numbers can be without encountering a single prime. Of course, many primes are neighboring odd numbers, and there is some discussion among mathematicians about whether that continues forever - or how precisely such neighboring pairs would become less likely.
Here's one of the latest runs:
Frequency table of gap sizes between prime numbers: (difference between neighbors -> frequency)
largest prime considered: 278561
-----------------------------------------------------------------------------------------------
2 -> 2824 | 20 -> 668 | 38 -> 84 | 56 -> 7 | 76 -> 1 |
4 -> 2805 | 22 -> 606 | 40 -> 103 | 58 -> 11 | 78 -> 1 |
6 -> 4546 | 24 -> 685 | 42 -> 96 | 60 -> 20 | 82 -> 1 |
8 -> 1855 | 26 -> 304 | 44 -> 26 | 62 -> 3 | 86 -> 1 |
10 -> 2321 | 28 -> 305 | 46 -> 28 | 64 -> 2 |
12 -> 2463 | 30 -> 453 | 48 -> 31 | 66 -> 4 |
14 -> 1312 | 32 -> 110 | 50 -> 18 | 68 -> 1 |
16 -> 876 | 34 -> 134 | 52 -> 13 | 70 -> 6 |
18 -> 1403 | 36 -> 165 | 54 -> 27 | 72 -> 1 |
The "6" entry really dominates the chart - these are cases where only two consecutive odd numbers in a row are NOT prime. What's the significance of that, I wonder?
Having that histogram was also a convenient check against some absurd problem while I was improving the original routine... I did in fact make a mistake like that, which screwed up the list to show 1024 gaps of zero... Clearly not what I expected.
The Hacker Way
When you set out with ideas only, and no plan, things take on a piecemeal quality. Code isn't elegant at first. But, as long as you are willing, it is possible to test frequently, and refine everything. I find it necessary to do this on a small scale: Getting a new facet of the code to work is easy enough - you want to demonstrate an idea quickly, before the thought passes. But, as soon as you can demonstrate it, it is important to start tearing it apart: If it gets called often, it needs to be quick; If it can be expressed more generally, it might be put to work on other problems, etc.
"I Don't Want A Cookie-Cutter City!"
8:12 AM 7/31/2009
Last night I attended a public meeting on the DC Department of Transportation's plan to redesign 18th Strert in Adams Morgan. I got a card in the mail for 'resident' announcing the meeting. I was bored - if you want to call it that - it doesn't affect me directly, but I wanted to observe the meeting.
Although I couldn't remember ever hearing of the plan before, it was hardly surprising: There have already been similar urban planning initiatives in Georgetown, Columbia Heights, U Street NW, H Street NE, and some others I can't remember at the moment (DDOT's Major Construction Initiatives Page). Utility companies come through every few years to tear up the street... Sewer, Elecric, Gas, Water, Telecom. When I was working in Georgetown, there were a series of underground electrical fires that caused manhole covers to explode, and for a while several competing telecom companies were ripping up the street to install communications cable. Years later, after I didn't have a good reason to go there anymore, they fixed up M Street according to some long-proposed plan. Remember that pattern.
I arrived a little late to the meeting, where I found a packed room. The size of the room suggested low expectations for turnout. I was wedged in by some boxes in the back of the room, unable to comfortably take notes.
If you stand in a hot room for two hours listening to several government officials give a Power-Point presentation, then take questions from the audience, your opinion of the meeting is going to vary significantly. I had many bemused moments of reflection: Many business owners on the street had only just heard about the disruption; The design was declared "90% complete", but the meeting was designed to accomodate feedback, and it sounded like quite a few people wanted to go back to the drawing board. I just wanted to see a Gantt Chart.
Project Management is a fetish. Think about why this would be: Somebody started talking about this construction project in 2003. For every person there who was upset by a lack of the much-touted 'public outreach', there was a veteran Neighborhood Commission member who had been fighting to get streetscape improvements for decades; Anything you do to public property in a city requires cooperation from many agencies, public and private. The major worry at the moment is Pepco - the electric utility here in the city - who wouldn't agree to a timeframe for ripping up the underground cables. If you didn't have managers rocking back and forth in front of a projection screen saying things like 'public outreach meeting', '90% complete', and 'procurement bidding phase', none of it would ever be completed. Against the obstacles and distractions there can only be obstinacy.
7:05 AM 7/30/2009
New ideas, more than savings or investment or even education, are the keys to prosperity...
-David Warsh "Knowledge and the Wealth of Nations"
Google API
12:41 PM 7/29/2009
My Ruby script textbook has a section on writing scripts to take advantage of Google services... You know, searches, maps, etc. Google's developer site has changed a lot since this book came out, but the basic idea is still the same.
I haven't even scratched the surface today: I was going to try some of the example code in the Ruby book, but the real action is in the JavaScript code examples on the Google site. To me, it is still an overwhelming collection of puzzle pieces.
For a start, I took some example code for making elements on a page 'draggable'. Take at look at the results so far. It needs some cosmetic improvements, but I'm just happy to think that I know how it works.
Now I am disappointed that, after clicking one of the photos, and returning via the browser's 'back' button, the positions are all reset. I don't know why I thought everything would be where I left it.
What I really need is a smoother way to find and load a handful of pictures that I can then drag around the page. That's going to require a different approach altogether...
Soap - Lather, Rinse, Repeat...
What Ruby script offers is a Remote Procedure Call mechanism through SOAP. Any website that supports Simple Object Access Protocol really ought to have an XML document to describe exactly what is being offered, and the format of that document is WSDL - Web Services Description Language. Are you tired of the acronyms yet?
As with a lot of paper-based computer resources, this Ruby book is showing its age. Much of what they describe required some improvisation on my part:
A Day At The "Fair"
5:55 PM 7/19/2009
Congresswoman Eleanor Holmes Norton sends out a newsletter. The latest one announced an annual Job Fair at the Convention Center. DC is supposed to get $1 Billion in money for "Economic Stimulus", whatever that means.
The message is clear enough: Pork Barrel money for the states, endorsed by at least one Nobel-laureate Economist. Of course, DC had to fight for its share - all them that stood to benefit did - so it's basically some kind of feeding frenzy. Fair is relative. That's a fitting image for what I saw.
I Have Arrived
Being on time is a major source of anxiety for me. In my fear of being late from factors not under my control, I usually arrive much too early. On this day, I arrived right on time, whatever that means. I arrived at the announced time, within a couple of minutes. But, like an airport, when you arrive at the convention center, there could still be a lot of walking ahead of you. I've been there before, so I know the distances involved. I walked in the front door on K Street (it's actually "Mount Vernon Place"), got some directions from someone official-looking, and fell in with the drift of people headed that way.
The job fair was well subscribed. When I got downstairs to the first actual signs, there was some crowd control going on. People were lined up to get in to the hall, and the line snaked back through the corridor. The doors hadn't even opened yet. I had to head back in the other direction to join it. The helpful folks at the entrance had essentially sent me to the wrong place, but how could they know? That seemed to be the place where they planned to receive us. We were just so many.
Before too long, the line began to move. They were letting people in. Nobody said anything to us for a while. In fact, the line stopped moving again before staff checked our IDs to make sure we were DC residents, and handed us copies of the fair directory and a mail-in survey card. And then we waited. I read a book, but I was distracted by all the chatter (mostly on cell phones) and the feeling that I should be watching for clues. I browsed the fair directory, and got the gist of what they planned to do with us, but then I still didn't know why we had to wait.
Some woman working the fair - not a lot to differentiate her from the other people except her mobility - told us that the hall was at capacity, but I knew that was inaccurate. I've been in hall 'C', and it's huge. My fair directory said we went first through an orientation seminar. That has to happen in batches. So probably the chairs were filled for that, but people in the line were frustrated because it wasn't moving. I know my feet were starting to hurt after an hour of standing around. Some people had already bailed. They don't look any more anxious than anybody else, but suddenly after fidgeting around for a while, they just turn and start walking. Maybe they had something else they had to do. Maybe they just had a low threshold for boredom. I started writing in my notebook - so I could be doing something thoughtful that required me to observe what I was supposed to be observing.
All Together Now
As much as I like cities, and believe in having people live together in large concentrations, I still believe in the power of distributed processing: I don't like events that draw together so many people in the same spot. I don't understand big sporting events or political demonstrations. I didn't attend the Inauguration or July 4th. Once a girlfriend dragged me to an Immigrants' Rights march, and it was basically a mass exercise in limited mobility.
There are practical problems to putting so many people in the same room, even it is a big room. This particular job fair is an annual event, but can you imagine waiting around for it? It is also hard to imagine attending it out of curiosity. All of us were desperate enough to brave the crowds, and the few who gave up waiting and left are notable exceptions. In such a large group, you can guarantee that somebody would be fooled by the scale of the thing, and realize to late they had other pressing matters.
The organizers have probably also worked their share of events where hardly anybody showed up. It is not as if we all sent in an RSVP, or registered and brought a badge. Imagine the extra cost. No, this here fair is like any attraction: if an average number of people come, everything should work out, but if by some strange coincidence, a large mob arrives, it's too late to do anything about it.
The Awful Truth
After another hour or so, and some minor reassurances, we do actually make it into the hall. But after what I've been told, it is a little confusing. Just as it shows on the map, there is a stage with chairs facing it, but nobody is sitting there. They're all milling around at the booths. All the new people are being sent to the booths. Half of the cavernous hall is sitting empty.
I took the time to check off the booths that would interest me most - so many of them did not.
Now, If I Could Just Get Paid To Wander Around Taking Photographs...
Don't be fooled by these photographs - There were a lot of people. Let's call it a skill of mine: Finding the desolation in a crowded places. Once I felt satisfied that I had done what I came to do, all the unpeopled places in that enormous space started to interest me. Try to imagine a convention that actually used the entire space. It is a place designed for much larger groups than the one I had to wait two hours in line with.
Archives
July 2009
June 2009
May 2009
April 2009
March 2009
"There is more work in interpreting interpretations than in interpreting things; and more books about books than on any other subject; we do nothing but write glosses on each other."
-Montaigne