Author Archives: JDługosz

Diamond’s “Found” Photos

See the previous post for the story.

Diamond positioned himself at the main entryway of this office building, watching people go in and out and getting spotted himself. Someone took this and, after looking for lost pets online, forwarded it to us via MMS message to the phone number on the flier.

Diamond_Found_IMG_0258

A perfect travel postcard

Someone else posted on a regional lost pets group of Facebook and also forwarded us a copy, as seen in the last entry. Here is the full photo, and you can see Brendan and his family’s car reflected in the window!

Diamond-Found_IMG_0260

A busy receiving line! Diamond is about to meet Brendan.

Brendan-edit-2

Sure, you can take a picture with me!

And here is Brendan meeting Diamond. He offered Diamond a cracker, which is a good way to make friends with a hungry bird.

Brendan-edit-1

Diamond’s “Roughing It” Vacation

Diamond

Friday

On Friday, April 10 2015, everything seemed normal.  Tao was out grocery shopping and I gave Diamond his dinner.  He acted normal and content, sitting on his deck (pictured above).  I expected Tao to be home soon so I stayed downstairs, putting away dishes and other small chores.

When I heard her coming, I watched by the door and when she got right onto the porch I opened the front door.  Diamond took off, and bolted out the door.  He was not trying to reach Tao, but flew over her head and to one side, full speed ahead.  I was in shock, not believing what I just saw so quickly.

That is simply not like him.  He doesn’t boldly explore new places, even within the house.  He sticks to a few favored places and is shy about being somewhere else with me, and never on his own initiative.

I expected he must be very close to the front of the house, as when he’s scared he will just grab on, hold still, and stay quiet.  The loud lawn machines across the street would scare him, and I expected to find him in the trees or landscaping directly in our front yard.  Shock turned to worry when a broader search did not find him.

After dark, I knew Diamond would not be active at all but needs to roost.  Parrots don’t have good night vision and can’t get around in the dark.  We decided to make some fliers, so I quickly put something together in Photoshop and took it to a nearby FedEx Office store for printing in bulk, before the closed at 9PM.

We left a few fliers at houses immediately surrounding ours, and I went a few blocks perpendicular to our street as well.  It was at this time that I met some neighbors:  one person a few doors down the block, and a family hanging out on the driveway behind the alley, and a man next door to that.  The whole time up to that point, nobody was visible on the street except for lawn-care professions (who would not stop using the scary leaf blower, BTW), and even knocking on doors I found nobody home to answer.

Tao posted on Craig’s List, which turned out to be useful (I think).

Saturday

Early in the morning, as birds were just getting up and becoming active, I went out to distribute fliers.  Since the binoculars were broken, I took a telephoto lens on my camera, which I thought a good idea anyway since I might examine a photo more carefully when I could not make out details though a shaky live view.

I also set out a portable speaker in the back yard, playing Tao’s voice in a loop.  If he can’t tell which house is his because he doesn’t know it from the outside, he might hear a familiar and distinctive sound and come that way.

Tao also distributed fliers, in a different direction.  I printed out a map to mark our routes and keep track of what’s been covered.

Sunday

I set out a plastic milk crate that he finds irresistible and just has to perch on and investigate.  I put it on the grill counter, near the back door, which is too close for wild birds but is an area he watches with great interest from his window.  I added to that a small stainless-steel bowl of nuts.  Again, shiny metal is something wild birds would be fearful of, but to Diamond that’s where food is found.  (It had not been taken by wild birds, so I suppose that’s right).

Monday

Tao passed out more fliers in the early morning before going in to work.  She has different hours on different days and Monday is a “later” morning.

I got a call from someone who found a flier that day reporting that he heard a parrot the previous afternoon.

That gave me renewed hope.  I used the last of the fliers in that area, at the same time of day.  It is common for him to call for a while in the late afternoon before evening, as do some wild birds.  So I tried to find his voice when that afternoon’s Social Chorus started.

I saved 3 fliers in reserve.

Tuesday

At last!  I got several calls in the early evening saying that Diamond has been spotted at an office building across town, 2 miles away!IMG_2458

When I got photos, it was unmistakable that Diamond was alive and doing OK, just a couple hours ago.  I heard that he was seen at this building from about 5:00PM, and that he had approached a woman in brown scrubs who met a kid.  Now it’s both exciting and frustrating, as the family who witnessed that interaction thought to look for Lost Pets online while waiting for the dentist, and did find my flier.  The people who saw Diamond and also found me did not know the people Diamond approached did not find me.

I went to the building and looked around, and left the last of the fliers where hopefully it make a connection the following day.  Most of the offices were already closed.

Wednesday

Early in the morning, we went out to that building again.  Looking around, I saw that there were numerous trees on the property, an open underground parking area, and the lot was adjacent to parkland featuring a creek.  The Google satellite view like I saw on my phone is shown below, with the red dot marked where the photo above was taken.

Office-Building

So, it’s a nice place for birds, as far as suburbs in this climate go.  I looked around, hoping I would find him still in the area, but also hoping I wouldn’t because he went home with someone.  I hoped this was it, because we were expecting severe weather starting in the afternoon.

When people started arriving, Tao asked them if they knew anything.  At last, we found someone who identified the woman in the brown scrubs, and had seen Diamond still riding her shoulder as she came back into the building.  She called her, and related that Diamond was not with her after all, but a different family was going to try to take him in.  She didn’t know who that was, but knew which office they were at.

The office in question opened at 9:00AM, so we waited until the proprietor came in.  He called the people who we knew intended to take in Diamond, and it went straight to voice mail.

Finally we heard back, and learned that Diamond went home with them and spent the night safe.  The only thing remaining was to go there and pick him up.

Tao and I had driven separately so she could go directly to work later.  Just to make things more exciting, my phone navigation was not working well:  it kept losing the GPS signal and the program would lock up for several seconds at a time.  It would show me behind the actual position and possibly in the wrong orientation, so I kept missing turns.

Tao had arrived ahead of me, and when I got there Diamond was sitting quietly on her shoulder.

Home at Last

So, Diamond spent 4 days and 4 nights in the rough, wild suburbs, and one night at a nice Roost and Breakfast.  I suppose people started spotting him and taking photos all of a sudden because that’s when he wanted to be found.  He spent an hour in public watching people enter and leave the building, before approaching someone.  He must have been considering who looked friendly, having to decide before it got late.

He seems find, just tired and hungry.  The slow and careful movements make me sympathize with being sore from overdoing it.  He also looks a bit unkempt, with his feathers seeming a bit frayed at the ends.  Besides fluffing up more for warmth, he didn’t have the time to keep himself groomed in his normal fastidious manner.  In addition to the dirt on his left coverts (slightly visible in this web-quality photo),  the ends of his primaries and rectricies (tail) appear a little frayed.

Diamond-3912

Looking Disheveled and a Bit Frayed

On the earlier photo at the top of this page, you can see that when his wings are folded, the tips of his primary flight features tough the tip of his tail features. Both are iridescent indigo in the light from the photo flash.

Diamond-3912-head

Bad Hair Crown-feather Day

The chatter in the local lost pets Facebook group is that Brandon (the kid who befriended him) should get the reward.  I still need to talk to everyone involved and flesh out the details, but look for a subsequent blog post in the pets category for more.

Next in topic: Diamond’s “Found” Photos

Most Boring Product Photos

Not to long ago I was photographing some product shots for family, to put on Amazon, so I had to shoot a nice shiny object with a pure white background.  Good product shots are not always easy, and some attention to detail is nice.

As it happens, the other day I came across the most boring product shots imaginable.  Ironically, both had to do with photography.  The first was linked from this post on using colored gels on the flash to match the existing lighting. This 20×24″ sheet of Full CTO can be cut up into pieces to fit over the flash head.  Click to open expanded view just struck me as funny.  Compare with this store, which uses the technical data sheet as a product image as well.

Then I came across this one, following link from the BFT by the same poster.  Now that’s hard to beat on pure useless minimalism while still being perfectly correct.  But let me know in the comments if you know otherwise.

 

Annual Black & White Play

The famous Black and White plays… well, there’s just no way to describe it.

Here is Tao and me before the play, with my brother-in-law in the frame as well. It is traditional to dress in black and white, especially for the New Year performance. But that’s not why it’s called a black and white play.

before-show

After the show, we met with the cast.  Here I am with Nick and Nora Charles straight off the screen from the 1934 film.
after-show-thinman

Well, actually it’s the world famous detective and aspiring actor Harry Bunsnacker and his paid by the hour assistant and close personal friend Nigel Grouse, in a clever disguise.  Below I’m with Lt. Foster, the show’s straight man.

after-show-foster

My family has been attending the Pegasus Theater’s productions since 1986.  And as I stated at the beginning, it’s indescribable.

A trip to the symphony

Dressed up to go out

Since Itzhak Perlman was going to be in town around the time of Tao’s birthday, I bought tickets for that show — six months ago when I saw the schedule.

Jaap van Zweden conducts
Itzhak Perlman, violin

RAVEL Daphnis et Chloé Suite No. 2
BRUCH Violin Concerto No. 1
Itzhak Perlman, violin
TCHAIKOVSKY Capriccio italien

It turns out this was the hottest ticket in town, being a special 25th anniversary gala at the Meyerson.  As well as starting a little late, people kept making speeches and I wondered how much music there would be given the times stated!  Among the “honorary organizers” were the mayor of Dallas and Ross Perot.

There was a special award for the architect I. M. Pei which was accepted by one of his sons.  Since it consisted of a “piece of original limestone” and a chunk of crystal, it looked rather heavy to the people who did handle it.  The 97 year old architect has won every award remotely connected to his field, so it makes sense that he would just send someone to pick it up [pun intended] for him.

Another speaker was Sarah, Duchess of York which surprised me.  I didn’t think that people outside of the area were involved, but apparently the building of the Meyerson was world-wide news and interested people in the Arts from all over.

As for the music, I needn’t have worried.  They simply played until they were done, never mind the printed times for the after party.  In fact, there were two encores: Perlman played the theme from Schindler’s List, and the orchestra continued with a waltz which name I did not catch.

As usual, the live performance at the Meyerson was richer and more powerful than any recording.  That’s the exact opposite of the situation with “pop” music in venues with acoustics so bad that it’s not about the sound at all but the experience of gathering.  I think I will find a good recording of Bruch, though, which is missing from my collection.

The Joy of Reading (21st century style)

I decided to read a science fiction novel.  Not a unique occurrence, as I have thousands of them in boxes and storage and shelves.  And that’s the problem, really.  Hard drive space is already increasing faster than my reading pace, so I could store books electronically and add to them indefinitely and keep the same physical volume.

Now I’m already well practiced with using my original Nook reader.  After downloading the file, I would next import it into calibre, not just to keep track of it but to massage the data.  But first it tells me that my version is woefully out of date and I go download and install the latest, which offers many improvements and rearranges the controls.

The book’s file is a bit strange, it seems, as it was not importing right.  Easiest thing is just to load it in Sigil instead (though I suppose I could figure out the import options or use new features to edit the files and not need Sigil anymore for its use in later steps) and save it again.

A first look at the formatted ebook is fair; I’ve seen much worse from some publishers.  Why can’t they do as well as, say, Project Gutenberg, and just put the text in a file?  But I digress.  I fire up calibre’s “heuristic” processing to clean up all the junk, and use its formatting features to optimize the file for my device’s liking and my reading preferences.  Ah, but that’s set for Nook.  Well, a new software reader probably doesn’t have as many peculiar issues as an old dedicated reader, so I probably don’t need that anymore.  Generic output profile to start with, but still specify traditional print-style rendering where paragraphs are indented on the first line as opposed to having double vertical space between them.  Margins and other stuff should be taken care of by the reader software.

Normally this is where I then load the resulting file into Sigil and see if there are any bizzare features that can be fixed with a simple global search-and-replace on the HTML source, if that is still necessary.  At the least I’ll manually retouch the css file to delete stuff that ought to be unspecified so the reader doesn’t feel it’s being bossed around, and get rid of the text-align: justify line since that doesn’t work as well on the old low-resolution e-paper display.  It looks better if the horizontal spacing is optimized for letterform appearance and not also trying to get a specific length too.

On the Nook, I then plugged in the USB cable (which was charging anyway) and had calibre export to it.  But how do I read it on the Android tablet?  USB filesystem hasn’t worked for a few years now and it’s futile to try.  It doesn’t have SMB file networking built in, but there are apps for that.  I know I’ve tried a fancy file manager that includes network access, and it doesn’t work.  I use the network plug-in for the well-regarded Midnight Commander port, and it doesn’t work.  I tried a few more programs, and nothing could get past the names of the file shares, if it got that far at all.  Must be some “security” thing?

Next I try a couple features in calibre.  One is wireless device access, and I’m not sure what that does, but a couple readers and stand-alone programs allow the Android device to use it, it seems.  Well, I can’t get anything to do anything with that.  The other feature is better:  a web server interface.  It tells me the local IP address and port, so I make that into a URL and feed it to Firefox.  Success!  It lets me browse the book collection on the Android tablet, and download files via HTTP.  So, now I have the book file on the tablet.

Next question:  which reader software?  A Google search turns up a few reviews.  Mostly they don’t address the features I’m looking for, or any real features pertaining to the core function of reading stuff presented on the screen.  I don’t care which stores they are integrated with, or how pretty the book chooser screen looks and all the skeuomorphisms present.  A shame that “able to load files on local storage” is a feature that needs to be checked for!  The supplied Google Play Read for example, has its collection of things you bought from them, and no way to point to an actual file.

I end up trying two, and spend the rest of the afternoon figuring out how to make it dance with the song I sing for it.  I’m glad to say that I had success in setting font appearance and size, getting the line spacing to look right, having it show margins rather than printing all the way to the edge of the screen, and so on.

The page is looking quite presentable.  I do mean “looks”, since I haven’t actually read the first page yet.  That’s a chore for next weekend.  It does seem like a lot of effort for a book I’m not going to like anyway, but that’s why I wanted to save five bucks for a remaindered copy plus shipping.

HOTEL alfa sierra kilo echo lima×2

From earlier posts, you know that I’ve been learning Haskell. Now it’s one thing to memorize some syntax rules, and be able to discuss intelligently the semantics and ramifications of some particular language feature, even typing a line or two at an interactive prompt. It’s another to face an empty page in a text editor with the intent of writing a program.

For whatever reason, it occurred to me to do something with the spoken (phonetic) alphabet.  It’s good to pick something you easily know how to do, as to concentrate on the mechanical details of the tools instead of the problem.

The Main Loop

To that end, I started with looking up how to fetch command-line arguments (simple output was already covered from hello world) and spent a long time pondering just how to structure the loop over the arguments.

Pretty basic, right?  With pure functions, given something to do on one input value (say, foo) and an ordinary list of input values, you can process all of them using any of several ways of saying “map”.

map foo values
foo <$> values
mapF foo values
mapM foo values
forM values foo
ff

The problem is that both the thing I want to do on each value and the function that obtains the list of values is “in” the IO monad. So instead of one token to put these two things together (whether a word like map or a infix operator like <$>), I need two separate tokens for monad composition and the mapping, and had further trouble combining the two things.

Separate steps for the monad and the map isn’t too unreasonable, but is just a little bit. There are different levels of wrapping, like having different levels of indirection. f $ g is one way to write simple function application, and the entire thing g is the argument of one call to f; f <$> g uses a different symbol to mean apply f to what’s inside g treated as a container, so f is called multiple times with values taken from inside g.  There are any number of different wrapping layers and different things can be wrapped in different numbers of layers, so having unique marks for each possibility is prohibitive.  There are ways to bump things up in general, so f g is plain function application and liftM f g tells f to look inside its argument.

So, given that the values I have are double wrapped and I’m targeting the middle layer (neither the innermost nor the outermost) it seems reasonable that an extra mark of some kind is needed to specify, in addition to a mark that says “put these two things together”, making two in all.

The other combining problem is harder to explain:  Given one function (foo) that produced something that you wanted to feed to another function (bar), simply combining them is a no-brainer, you would think.  In a C-like language, bar(foo()) is pretty obvious.  In Haskell you don’t even use the parenthesis, so it’s just bar foo.

You could use an intermediate variable name, like

s= foo();
bar (s);

but you don’t have to.  In fact, that’s one of the things wrong with using so-called OUT parameters, is that it ruins the expressiveness and you can’t simply chain them together.  And this kind of chaining is very much embraced by functional style and Haskell in particular.

If foo is actually getArgs, and bar is a function that takes a list of strings (don’t even worry about the mapping at this point—just write a function that explicitly takes a list), you can’t do it!

main = do
    s <- getArgs
    mapM_ body s

badmain = mapM_ body getArgs

Writing that without the named intermediate value and do-block, the “obvious” main = mapM_ body getArgs doesn’t work.

When I was pondering this as I was working on it, I concluded that the only thing that can be done to getArgs is the bind operation (>>=).  Now, maybe that’s not quite true if common helpers exist that themselves use bind, such as the liftM mentioned earlier.  Ideally I’d somehow mark the argument that is wrapped too much for the function, as the first argument (the body) is fine and there may be variations like liftM2 but not one that skips lifting some arguments and then lifts others.  Would ap or <*> mixed with $ work here?  That’s something to try next time.

Meanwhile, my first concern was with writing the for-each construct in a clear manner, without separating body into its own named function since it isn’t that complicated.  I wondered what the usual common idiom might be?

No matter how you arrange the pieces though, I needed to name the parameter for the individual value/iteration being processed.  In common imperative “structured” languages, naming the loop control variable is a basic part of the syntax of a for-each looping construct.  Using a higher-order function instead, writing a lambda expression for the body was a bit clunky.  In any case, the layout started giving me trouble, so I gave up on that and just made body a separate named function.

What I ended up with is (starts with, anyway)

main =
    getArgs >>= mapM_ body

and with the body being a single word, the arrangement of the components (looping construct, list of inputs, body) is not nearly so important.

 Look-up Table

Haskell’s go-to data structure is a list.  There is no simple way to make a O(1) random-access array.  I mean, there are in fact such arrays as libraries, but to populate it you need a list anyway.  Such an array would help random-access speed, but only makes creating the table more complicated.

For key-value lookup, the basic feature is a function called lookup.  It operates on a list of (key,value) pairs, and I really didn’t want to write out the keys a through z and pairs, but rather just list the values (the alfa bravo keywords) in order.  The zip function took care of that.

Since it is most definitely not taking any advantage of contiguous range of keys, I decided to use that as a feature and add keywords for some odd punctuation marks and such.

phon_table= nato_table ++ digit_table ++ 
    [('.',"Period"), ('-',"Dash"), ('#',"TicTacToe"), ('_',"Underscore"), (' ',"Space"), ('@',"Snail") ]

nato_table= zip ['a'..'z'] ["alfa", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel",
                "india", "juliett", "kilo", "lima", "mike", "november", "oscar", "papa", "quebec",
                "romeo", "sierra", "tango", "uniform", "victor", "whiskey", "xray", "yankee", "zulu" ]

digit_table=  -- FAA style 
    zip ['0'..'9'] ["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Niner"]

Thinking ahead, variations can be accommodated by building the master list out of different pieces.  For example, use ITU instead of FAA code words for the digits, and add application-specific words.

Function Decomposition

Functions need to be written in small pieces.  In real-world code (using common imperitive languages) I’ve seen people write what I call meandering functions, which is a lack of decomposition: one defined unit (procedure or function in the high-level language) does stuff, then does more stuff, then goes on to work on something else, etc.  Often they are much much too long, running hundreds of lines of source code.

In Haskell, pure functions don’t have multiple statements.  That makes it hard to meander, or, without being adept at functional programming yet, even writing more than one line!

I also see lots of code that is not meandering in that the function does “one thing”, but yet is not decomposed well in that the thing it’s doing is obscured (even overwhelmed) with lower-level details that should be unimportant to “the thing” being expressed in this function.  Many programmers have a hard time with that, apparently not recognizing or even understanding what that is.

Those same programmers would more naturally break things up more in Haskell, since it is awkward to stuff more detail inside the argument of a function.  Writing a list of statements, it’s all to easy to stop what you’re really doing and issue lower-level detail work, and then put in more higher level work.  When everything is an argument to a single function, it’s more in-your-face that you are interrupting your expression with details that should be elsewhere.

Haskell facilitates writing very small functions with features such as writing multiple branches as separate top-level functions, and nested functions which close over the variables in their parent scope.

So is it “smaller is better”, period?  How much logic should go into one function as subexpressions rather than separate named functions?  Since the stuff in a where block have the same meaning as being in-line, thanks to the parent variables still being available, naming many individual pieces of a function seems to be the way to go.  What to not break up would be logical constructs that are read as a unit, and idiomatic uses that are recognized as one phrase but would be disguised if broken up.

When I first started to formulate some code, I ran into trouble with multiple nestings of local definitions, or trying to combine them in ways that either were not supported or couldn’t work in the layout rules.

A harder thing to know how to get just right is when to make local nested functions vs top-level functions.  My instinct is to nest everything and not expose internal details, since there isn’t any level of organization and name hiding smaller than the module.

Once I got past the initial main-loop panic, most of my time was spent fiddling with just how to decompose the functions.  As an anchor point, it made sense that the principle function solving this problem would be a named function and the driver (getting the args and displaying the results) would be a sample usage of that function.  In a real project, that is what I’d be interested in, and what I have here as main would just be test code, as the function would be called by other parts of the program.

One interesting detail is that my function phon processes one character, producing one code word as a result.  It doesn’t provide a function for processing an entire string, which is something you’d probably add in typical programming languages.

Given the function phon, you can call it on a character using ordinary function application, but it’s just as easy to process an entire string so there is no need to provide another function for that!

codeword = phon ch -- mundane call
codeword = phon $ ch -- means the same thing
codewords = phon <$> s -- process whole string of input
codewords = map phon s -- same thing

It’s also especially important in Haskell to keep the physical realization of the output separate from the computation. In most common programming languages, it would be just as easy to have the principle function print the result, and multiple calls would print successive items. In Haskell it is not just as easy — The function phon in this case cannot call putStr or anything like that.

In this toy program, where phon is called right from main and nothing else is happening, writing phon as an IO function would not seem awkward.  But it’s still a deliberate act, and you’d certainly notice when making a recursive call (or trying to).

Of course, that’s good in general.  In my toy program printing the results was part of the specification, but in real projects such a function will be consumed by other code, so the result needs to be in a form that’s still internalized and can be handled however the caller wants.  Unfortunately, it also makes it difficult to add debugging trace statements to existing code, but that’s another story.

Here is the complete program, as I left it.

module Main (main) where

import System.Environment (getArgs)
import Control.Applicative
import Data.Char


main =
    getArgs >>= mapM_ body
    where
        body s = do 
            putStrLn $ announce s 
            putStr $ format $ phon <$> s
        announce s = "string \"" ++ s ++ "\" spoken as:"

format =
    concatMap decorate
    where decorate w =  "\t" ++ w ++ "\n"


phon :: Char -> String
phon c | isUpper c = toUpper <$> (phon $ toLower c)
phon c = 
    maybe (quoted c) (id) result
    where result= lookup c phon_table
          quoted c= ['"',c,'"']
    
    
phon_table= nato_table ++ digit_table ++ 
    [('.',"Period"), ('-',"Dash"), ('#',"TicTacToe"), ('_',"Underscore"), (' ',"Space"), ('@',"Snail") ]

nato_table= zip ['a'..'z'] ["alfa", "bravo", "charlie", "delta", "echo", "foxtrot", "golf", "hotel",
                "india", "juliett", "kilo", "lima", "mike", "november", "oscar", "papa", "quebec",
                "romeo", "sierra", "tango", "uniform", "victor", "whiskey", "xray", "yankee", "zulu" ]
                
digit_table=  -- FAA style 
    zip ['0'..'9'] ["Zero","One","Two","Three","Four","Five","Six","Seven","Eight","Niner"]

I welcome comments from experienced Haskell programmers on these issues, and overall style and idioms in general.

A Spriral Approach

I’ve heard of spiral approaches to learning, meaning that material is covered without much detail and making successive passes with more detail.

My recent experience makes me think of a slightly different spiral:

You understand, then you learn more, and then you are more confused than ever.

zeta

Maybe that’s why I like this particular representation of the Riemann ζ function?