pic#80953
I ran into an interesting bug on OS X this week. I had an object which was trying to calculate a value that had been requested of it. The calculation can take a long time so every now and then the object would check to see if the user had pressed the escape key to abort the calculation. But the very first time it tried to make the check, it would crash.

Using a combination of the debugger and print statements I was able to determine that the problem was that when it tried to check for the escape key, window redraw events were running and at least one of those was calling on the object to calculate the same value that it was already in the process of calculating. Since the object was non-re-entrant (i.e. it had to finish doing one thing before it could be asked to do another), that was resulting in the crash.

The thing is, the check for the escape key shouldn't be allowing any other events to run. Most or our code is written in C++, but this bit was in Cocoa/Objective-C and looked like this:

NSUInteger mask = NSKeyDownMask|NSKeyUpMask;

NSEvent *event = [NSApp nextEventMatchingMask:mask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];

The first line defines a mask of the types of events we want to consider: just key presses and key releases. The second line, which is probably broken into two in your browser, asks the application's event loop (known in OS X jargon as a 'run loop') to return the first event matching the mask which is currently queued up for processing, if there is one.

Given that the mask setting should only allow key presses and releases to be processed, how the heck were window redraw events getting through?

It turns out that the answer lies in that 'inMode:NSDefaultRunLoopMode' bit. A "run loop mode" determines which input sources the loop will check for events (keyboard, mouse, etc) and, critically, which observers it should talk to while processing events. Observers are other bits of code which have asked to be alerted at various stages during the processing of events.

You can define your own run loop modes, but OS X has four pre-defined ones:
  • NSDefaultRunLoopMode
  • NSEventTrackingRunLoopMode
  • NSModalPanelRunLoopMode
  • NSConnectionReplyMode
Without going into the details of each one, it's sufficient for the purposes of this post to just note that the first three are so frequently used that they are grouped together as "common modes". Observers can subscribe to all three just by subscribing to 'NSRunLoopCommonModes'.

We use Nokia's Qt toolkit to implement our application's GUI. It turns out that Qt sets up an observer on the common run loop modes. That observer apparently does not (or cannot) check that we are running the loop with a mask which only allows for keystroke events. So it goes ahead and issues its own internally generated window redraw events, even when we are only asking for keystroke events. Thus the crash.

The fourth run loop mode, NSConnectionReplyMode, is intended for waiting for network connection events, but we don't really care about that. The important things are that it is not one of the common run loop modes and thus does not have a Qt observer sitting on it, and it accepts the keyboard as a valid input source. By using it, we can stop Qt from issuing unwanted GUI events while we check for key presses:

NSEvent *event = [NSApp nextEventMatchingMask:mask untilDate:nil inMode:NSConnectionReplyMode dequeue:YES];

It would be even better if we created our own run loop mode which had no observers at all attached to it, and whose only valid input source was the keyboard. Unfortunately, while I've be able to figure out how to create my own run loop, I haven't been able to figure out how to get hold of the 'port' for the keyboard so that I can add it to the run loop. So we'll have to make do with NSConnectionReplyMode for now.
pic#80953
After almost six months of not geocaching, today I got out and picked up four new caches, bringing my total to 290.

Six months ago is when I went back onto Paxil. As I noted in earlier posts it knocked the stuffing out of me for quite a while. But over Christmas I came to the conclusion that my body had re-adapted to the drug and my problem was now a combination of reacquired bad habits, shortened daylight and a daunting backlog of work which had built up during my period of drug-induced lethargy.

The first step was to get my work habits back under control. For the past couple of weeks I've been getting to bed earlier and getting up earlier, often before 08:00. Despite my natural night-owl tendencies, I find it much easier to put in a full workday if I get an early start on it. As a result, for the past two weeks I've managed to put in a full day of work each day, plus a bit extra to start reducing that backlog.

A side effect of that is that when the weekend comes I feel less guilty about taking some time off. My earlier bedtimes also mean that when I finally manage to get going in the morning there's still enough daylight left to do something, even with these shortened days. Combine all that with today being sunny and an expectation of snow for the next several days and the formula was finally right for me to get back out geocaching.

None of the caches today was especially interesting. Or rather, each cache has its own unique challenges, frustrations and victories, but they are all of the moment and do not lend themselves well to description afterward. The second cache I found had an interesting container, though: a star-shaped plastic box, covered in camo tape and hung from the branch of a little fir tree, like an ornament. A nice little touch, that.
pic#80953
This is pretty awesome. A chandelier made out of paper clips and a couple of hoops of wire. The shadow pattern is wonderful.
pic#80953
Over the holidays I cooked a turkey, for just the second time in my life. The circumstances were similar to the first time: as a bonus for spending lots of money at the SuperStore we received a free turkey. It sat in the freezer for a couple of months until I got tired of it taking up space and decided to cook it.

The results were similar to the last time around as well. To begin with, the defrosting instructions were completely and utterly wrong. They said that a turkey of this size (5.9kg) should defrost in the fridge for two to three days. I remembered from last time that the turkey was still frozen after that, so this time I left it in for almost four. Except for the outermost layers, it was still frozen solid.

There were also "quick thaw" instructions which said to put the turkey into a basin, cover it in cold water, and let it sit for six hours. I decided to try that instead. Despite having already defrosted in the fridge for four days it took the full six hours before it was sufficiently thawed to start cooking. Even then I had to work a bit to free the neck from where it was still frozen to the inside of the bird.Next time I'll do what my Mom does: throw it into water before going to bed and let it thaw out overnight.

I've determined that I'm really not that keen on turkey. It's okay, and it's nice that you get so much meat off a single bird, but all in all I prefer the taste of roast chicken.

As before, the big hit was the stuffing. I use this recipe, minus the walnuts and olives. I've got enough turkey stock left over that I'm going to make another batch today or tomorrow. Yum!

I hope you all enjoyed your holidays. As usual I spent the bulk of my time doing as little as possible, just playing games and watching videos. It was lovely.

Now back to work until my vacation in February.

pic#80953
As is my annual tradition, I wish all of my friends and family a happy Winter Solstice. The days have stopped getting shorter and are now getting longer again.

For anyone west of the Eastern Timezone, which includes me, Thursday will have 30 or so more seconds of daylight than Wednesday. For those of you in the Eastern Timezone and anywhere east of there, Thursday will actually be a few seconds longer than Wednesday due to the solstice being later in your day. But fear not, by Friday we'll all be reaping the benefits of that extra half minute each day. Cumulative!
pic#80953
I was just reviewing some code which was copying a linear array of 16 values into a 4x4 matrix as follows:

for (int i = 0; i < 16; ++i) {
    matrix[i / 4][i % 4] = array[i];
}


That immediately joggled my inner optimizer. Shifting right by 2 bits is equivalent to dividing by 4, but faster on most processors. Similarly, masking off the lower two bits is equivalent to taking a 4 modulus, but again faster. So this should be significantly faster:

for (int i = 0; i < 16; ++i) {
    matrix[i >> 2][i & 0x3] = array[i];
}

But wait. Surely today's modern compilers are capable of detecting this level of optimization themselves!

I tried it out and found that even at the highest level of optimization in g++, the second version is 60 times faster than the first one.

Nice to see that some of that old learning is still useful today.

pic#80953
I keep getting calls from people claiming that they are from the "Windows Technical Department" saying that they have detected a problem on my computer and want to help me fix it. Usually I just hang up since it's clearly a scam, but tonight I decided to play along.

The first call (yes, they called twice) was from a guy with an Indian accent. I asked him for the name of his company and he said that the company was called "Windows Technical Department". I clarified with him that that was the literal name of the company.

I asked the guy for the company website and he told me they didn't have one, which seems pretty odd for an outfit so advanced that they can tell remotely that one of my firewalled machines has a virus. Oddly, though, when I asked for a phone number he gave me one: 209-753-4558. Not sure who it belongs to, but it's somewhere in California. When I asked for their email address there was a long pause and then he hung up.

A Google search of "Windows Technical Department" turns up about 127 million hits, which all seem to talk about how it's a scam. They convince you that you've got a virus on your computer by having you look at system logs which actually show normal activity, then they sell you software to "fix" the non-existent problem. Then, for good measure, they get you to give them full access to your machine so that they can steal your identity if they so choose.

The second caller was a woman with an Indian accent. I didn't quite catch the name of the company this time but it also had "Windows" in its title. She was able to give me a web-site - www.turnertech.com - but not a phone number, saying that they had no ability to receive calls. She started out saying that they had detected that my computer had a problem. I told her that I have five computers and asked which one it was. She told me to check all of my Windows computers. I kept insisting that if they were able to remotely detect that one of my computers had a problem, then they should be able to tell me which one. Give me a system ID or even an IP address! We went back and forth like this for about 10 minutes, then I got bored, told her I knew she was a scammer and hung up.

I don't know if www.turnertech.com is really involved in the scam in any way, or just an innocent bystander. However they are located in California and it is odd that a company which claims to be highly trusted only accepts payments by PayPal which, conveniently enough, has very loose identification requirements and leaves virtually no trail. (H/T to the paramour for finding that.)

So, if any of my less computer savvy readers should happen to get a call from these people, do NOT give them money or access to your computer. Don't even type a single command or make a single mouseclick that they tell you to. If you think that they might be at all legit, take down their contact info and tell them you'll call them back. Then get hold of your computer vendor and check with them whether the call is legit.

pic#80953
When I was negotiating my contract with ME (My Employer) four years ago, I asked for four weeks of vacation per year. I was told that the company had a strict policy of only three weeks for new hires, rising to four in their sixth year of service. I asked for an exception to the rule but was told no exceptions were allowed.

After being hired I received a copy of the employee handbook and found a clause in it which stated that if a new hire had at least 10 years of prior work experience and had four weeks of vacation with their previous employer then we were entitled to four weeks at ME as well. I pointed this out to my boss, who was also the one who'd handled my contract negotiation. He admitted that he hadn't been aware of that clause and had my vacation rate adjusted accordingly. I've been enjoying the extra week for the past three years now. Yippee!

Today I got an email from a fellow in HR saying that an internal audit had found that I was getting too much vacation and would be reduced to just three weeks a year. I quoted the relevant passage from the employee handbook to him, which led to my favourite exchange so far:

ME: So I am entitled to the four week vacation accrual rate.

HR: Then why didn't you get it?

ME: Clearly I did get it or you wouldn't be trying to adjust it now.

So we'll see where this goes. The manager who hired me has jumped in with his support and noted that it had all been approved by HR at the time, so I doubt there will be any problems. If there are, I still have one good line left up my sleeve:

"At this point I suggest you contact the legal department and ask them about the implications of negotiating a contract in bad faith."

While there would be some satisfaction in getting to play the bad-ass, my dislike of confrontation is stronger. A quick resolution with no ruffled feathers would be much more to my liking.

EDIT: HR found the original paperwork and all is well once more.
pic#80953
When friends start sending concerned emails wondering if I've been abducted by aliens, that means it's high time I posted something to my journal.

So no, I've not been on an interstellar journey, nor contracted some horrible disease. My absence has been due primarily to something far more prosaic than that: I've become addicted to a new game. The game is called minecraft and I'll go into it in more detail in later posts. (Doubtless far more detail than you could ever want.)

My battle with paxil-induced lethargy continues and I seem to be slowly winning the fight. Most weeks I manage to get in a week's worth of work. But then I reward myself by firing up minecraft and when I next look at the clock six hours have passed. As a result, I haven't done any geocaching since July and haven't been on the exercise cycle since September. Bad Dean!

I'm giving a talk at a conference in Las Vegas at the end of the month and I really need to buckle down and start working on it, so I'm belatedly trying to ration my game playing time a bit better. Wish me luck.

Aside from that, not a lot new.
pic#80953
For the past couple of weeks I've been spending a lot of my free time watching events unfold in Libya. Over the weekend it finally came to a head with the "rebels" taking control of most of Tripoli.

Gadaffi hasn't been caught yet and there are still pockets of resistance throughout the country, but now I feel confident enough that they've won a durable victoray that I'm no longer glued to Al Jazeera and Twitter for four hours each day.

Which is good because I've got a lot of work to do that I've been neglecting!
pic#80953
The lethargy I've been feeling since I went back onto the paxil a few months ago has lessened a bit, but not enough, so I've started to take a more active approach to dealing with it.

I've had a lot of problems recently with restlessness in bed, which makes it difficult for me to get to sleep at night. I was taking my paxil just before going to bed and the restlessness seemed to start up about an hour after that. Often when I go to bed I read or play games on my phone for a while before turning out the light, so the first thing I tried was to hold off taking the paxil until I was really ready to sleep. That worked insofar as I no longer had trouble getting to sleep. However, I would only sleep for about four hours before waking up and it would be difficult to get back to sleep after that. As a result I was tired most of the day, had trouble concentrating on my work, and often ended up taking a nap in the afternoon. The nap would then make it more difficult for me to get to sleep that night.

It occurred to me that I might now be experiencing the restlessness while I was asleep and that it could be contributing to the short duration and poor quality of my sleep. I switched over to taking my paxil in the morning, with my breakfast, in the hope that the restlessness would be out of my system by the time I went to bed. That does seem to be working as I'm now sleeping longer and feeling more refreshed when I wake.

That still didn't get me out of the woods, though. I was still finding myself overcome by extreme drowsiness shortly after breakfast and again after lunch. I know that a degree of drowsiness is normal after eating, but this was beyond normal.

To deal with that I've started drinking caffeinated cola in the morning and only switch to decaf in late afternoon. Also, on those occasions when I do succumb to the drowsiness and crawl into bed in the middle of the day, I'm setting a half-hour alarm so that I'll still be sufficiently tired at night to get to sleep.

Taken all together, it seems to be working. I'm spending more time in bed at night and less during the day. I'm getting more work done and there are fewer occasions where I shy away from difficult tasks because I don't feel that I'm up to them.
pic#80953
Just before heading off to SIGGRAPH I had my monthly weigh-in, and the news was not good. I'd gained three pounds taking me back up to 222.

While unfortunate it was hardly unexpected. I only used the exercise cycle twice and only got out for walks twice. And since being lethargic quickly gets boring, I spent some of the unused time entertaining myself with food.

The one bright spot is that when I weighed myself again after getting back from SIGGRAPH, I hadn't gained any further weight. I'd figured that a week of restaurant food and sitting auditoriums would pack on another pound or two, but as it turned out I did a lot of walking. My hotel was 1.3 km from the convention centered and I walked there and back pretty much every day. One evening I attended an event at the Vancouver Aquarium, which was 2 km from my hotel and I walked there and back as well. So all that walking helped counteract the food.

This just emphasizes what I already knew: that I have to get to grips with this lassitude which has overcome me since I started back on the paxil. But that's the subject of a separate post.
pic#80953
Today I sat in on an interesting course on character rigging. "Character rigging" is the process where controls are set up to make it easy for an animator to control a character's movements.

Read more... )
pic#80953
Or my Day 1, at any rate: there were events yesterday before I got here and some ancillary events on the weekend as well.

Read more... )
pic#80953
For the past few weekends the paramour and I have been attending the recently discovered farmer's market, which is held each Sunday not far from where we live. It's a decent sized affair as these things go, sporting about 40-odd different booths.

One of the venders is Morden Maples who, unsurprisingly, sell maple syrup. Last Sunday they were handing out samples of cotton candy made from maple sugar. It was so delicious that this week I bought a small package of it. Good thing the package was small, as I could easily eat this stuff by the pound. Yum!
pic#80953
Most mornings my breakfast consists of instant oatmeal with a handful of blueberries tossed in and some extra oat bran to give me a bit more fibre. One of the things that I take quiet pleasure in is the timing of its preparation. I put water in the kettle and turn it on. I then get a bowl and spoon, empty a packet of oats into the bowl, spoon in some oat bran, mix it up, grab a handful of blueberries from the freezer and sprinkle them on top, then get my vitamins from the medicine chest in the bathroom. Just as I finish washing down the vitamins, the switch on the kettle pops, indicating that the water has boiled.

That's right up there with the toast popping just as I pull the warmed meat from the microwave. :-)
pic#80953
My footgear of choice is hiking boots. I wear them when geocaching, grocery, shopping, weddings, you name it. I'm going to SIGGRAPH in August and my six-year-old Salomon high-cuts, while still quite usable, look a bit too ratty for someone who will be representing their company. So today I bought a new pair. I wasn't specifically looking for Salomons again, but that's what I ended up with: Comet 3D GTX. They're light and feel good on my feet. Cost about $210 after taxes, but if they last as long as the previous pair it will be money well spent.

Now I've got a week to get them broken in.

Oops!

Jul. 23rd, 2011 11:25 pm
pic#80953
On Friday I created a Google+ account and I think that I may have been spamming family, friends and coworkers with updates.

Google+ is Google's answer to Facebook. It has a really nice feature that instead of just having a bunch of people all classified as your "Friends" you can create different 'circles' with different people in them and control who gets to see what.

It also allows you to add to your circles people who are not yet on Google+, using their email addresses. That's what got me into trouble. I had created separate circles for Family, Friends, Co-Workers and Business Acquaintances. When I went to post updates it asked me if I wanted to share it with my circles, to which I said yes, thinking it would only make it available on Google+ stream for other Google+ users to view, much like Facebook's whiteboard. In retrospect, I think that means that it was sending the updates out to all of the email-only people in all of my circles, too.

Oops.

I think that when posting I need to share with "Public" rather than my circles. That way it will only be made available to other Google+ users.

BTW, if anyone wants a Google+ invite, let me know and I'll send you one.
pic#80953
Usually when I buy dates I buy Medjool dates. They're big and sweet and yummy.

Today at the grocery store they had honey dates for almost half the price of Medjool. They were pitted, too, which means that you're not paying for the stone, so the price per gram of edible fruit was probably less than half. I don't recall having had honey dates before so I picked them up. I've just finished a handful and they're slightly less sweet than Medjool, but not by much. They are still plenty sweet for my sugar-saturated tastebuds. Aside from that the only difference I can see is that they are smaller.

Is that the main reason for the price difference? Are we so obsessed with "bigger is better" that we pay more than double for bigger dates? Or is there some specific cachet to Medjool dates that commands such a whopping premium?
pic#80953
I find that making up a to-do list can be a good motivator for me to get things done, just so long as I don't do it too frequently. I've tried using to-do lists on an ongoing basis in the past and have found that they work well for the first week or two, but after that they start weighing me down and just adding to the stress in my life. Like so many things, they seem best when used in moderation.

This weekend I made up a list of seven things that I wanted/needed to get done, most of which I'd been putting off for far too long. Yesterday I managed to get five of them done and today one more.

The only one still not complete is getting my passport renewed, which I'll need to attend a conference in Las Vegas in October. I already had the photos. Today downloaded the form and printed off and confirmed with two friends that I could use them as references. All in all one of my more accomplished weekends of late.

Last week was also the first week in the past two months that I've put in my full hours at work. So the lethargy does seem to be lifting.

Profile

pic#80953
deane

January 2012

S M T W T F S
123 456 7
8910111213 14
15161718192021
22232425262728
293031    
Progressive Bloggers

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Style:
Yvonne

Expand Cut Tags

No cut tags