Category Archives: Work

Nicky learns to debug


Nicky came with me to work this past Wednesday for “Take your kid to work day”. Not only did he see first hand what I do, he even helped me do it.

I showed him the “Database Explorer” software that I’m helping to develop for the next version of SAP HANA. It allows you, among many other things, to execute arbitrary SQL statements against any HANA database. But before he would have any idea what that was good for, I had to tell him what a database was. I simplified it to: a database is a collection of data stored in tables, where a table has a bunch of columns and each column has a type (i.e. text, numbers, dates, etc.). As an example, we created a table called “person”, with columns like “name”, “height”, “weight”, and “birthdate”. I inserted a row for Nicky and one for me.

Then I showed him how we can use the SELECT statement to get the data back. So “select * from person” shows both of us, with our names, heights, weights, and… incorrect birthdates. Each date was off by one day. Hmmm… that’s weird. Perhaps I made a typo on one of them, but not likely both. I updated a row and double-checked the birthdate but when I retrieved the data again, it was still wrong. OK, well, guess what Nick? We get to look through the code, find the error, and fix it. This is what I do.

I knew where the data retrieval code was, so Nicky and I looked it up and found where we get the data from the database and format it for display. I added some code to print out the value we retrieved and found that we were actually retrieving the correct date. This meant that it had nothing to do with the insertion process, and that the database itself wasn’t involved. Then I added a line that displayed the value again after we formatted it and found that it was wrong. So it was definitely our formatting code that was to blame.

Debugging

This is written in Javascript, and we were creating a Date object from the original value. We looked up what the Date constructor expects, and found that the format we were passing in was incorrect. Then we parsed the year, month, and day out of the date and used those directly to create the Date object. We fired it up again, and presto, it worked. High five, Nick.

Our next task was to write a barrier test. We have a suite of automated tests that run and must pass before anyone is allowed to make any changes to any piece of code. This is to make sure that nobody ever makes a change in the future that causes existing functionality to stop working. I knew there was a file that contained tests for many different data types, so I loaded that up to add a test for dates. Oddly, I found that there was one already there, but commented out. Then I read the comment, which stated that the test was failing but the author didn’t know why, so he was temporarily disabling it until later when he had some time to figure it out. The comment was signed “gperrow”.

I enabled the test, corrected one typo, and presto, we have a fixed bug and a barrier test. High five, Nick.

Nick said that between the bug squashing (he prefers that term to “debugging”) and playing with the Arduino and 3D printer in the morning, he had a really fun day, as did I.

Advertisements

Habitat for Humanity


Every year, SAP has an event called the Month of Service, where every employee is given time off from work to volunteer in one of a number of venues. Some are right in the building and only take a couple of hours, others are outside the building. The participation in this event is impressive – numbers from the Canadian SAP offices varied between 42% (c’mon Calgary!) to 72% in Waterloo to a confusing 129% in Ottawa. Overall, over 60% of Canadian SAP employees participated in some volunteer event and in addition, SAP donated money to some of the charities involved. This is a great event and kudos to SAP for doing this.

Oddly, I don’t remember hearing about this event last year, though I am now aware that many employees did take part. I wanted to do my part and bump up those Waterloo numbers, so I chose Habitat for Humanity. They are doing a build in Kitchener, and an employee who volunteered with them last year was organizing it again this year. I love building stuff but I’m not very knowledgeable about such things, so a place like this is perfect for me: they’ll tell me exactly what to do, they have the tools and equipment available to do it, and they have truly knowledgeable people around to help and advise.

The block we were working onWhen we first bought our house, we had lots of repairs to be done and I always enjoyed doing them. I can do simple electrical stuff and I don’t totally suck at working with wood, though I’m not going to be building a dining room suite anytime soon. I’ve installed phone lines and electrical outlets and replaced light fixtures and such, and I enjoyed helping my father-in-law and brother-in-law build our “cold room” (pantry) and workshop in the basement as well as replacing our deck. One thing I don’t enjoy is plumbing. For some reason I can just never get the hang of plumbing, though I have installed new showerheads a couple of times. That’s brain-dead easy but Gail’s done some more difficult stuff like replacing the kitchen faucets and our bathroom sink and she’s pretty good at it.

But I digress. We arrived on site around 8am where there were some snacks and coffee/tea available. There were about 15 of us from SAP plus a bunch of contractors. At 8:30 they had a safety presentation and after that we all geared up in our borrowed CSA-approved boots and hardhats and headed out to the work site. The area they’re working on is huge (see the picture below, taken from the top of the scaffolding on the new block). The site manager was telling us that if they were to buy just enough land for one house in this area, it would cost near $200,000 – and that’s without a house. Much cheaper to buy a large lot and put up townhouses, which is what they’re doing in Kitchener. There was one block of six houses that were mostly finished, and they’d started another block of four in the back corner, which was where we were working.

We started by bringing a pickup-truck worth of 4’x8′ sheets of plywood down to the site, and then passed them all up to the second floor. Those were later installed on the roof by some of my colleagues. We then installed a couple of 2x4s horizontally through the trusses, which I believe were to be used for running wire between rooms. The trusses needed spacers installed, so that was our next task. While getting ready for that, another contractor came by and asked if we had extra people since he could use a hand. I volunteered and so he and I headed to the other end of the building, where the all of the siding had been done except for the very top pieces. My first task was to install five pieces of J-channel, so I needed to measure the pieces, cut them to length, and nail them in place. Once that was done, I cut the last pieces of siding for each of the five sections – this took a lot longer than I expected and I burned through a couple of utility knife blades doing it. Finally that was done and I was able to install them and screw them into place.

The work siteThat’s it. That’s all I got done all day. Doesn’t sound like much, does it? It was a lot of work though and my shoulders and legs were feeling it over the next couple of days.

There was a 10-15 minute break at 10:45 or so, where they supplied some ham sandwich fixin’s as well as some crackers, cheese, and fruit. Lunch was at 12:30 and was catered by people from a local church. They had brought a bunch of baked potatoes and all kinds of toppings: grated cheese, bacon, onions, diced tomatoes, chili, sour cream, and a bunch more. For dessert there was more fruit as well as brownies, lemon bread, date bread, and banana bread. The food was excellent.

I have lots of kudos to go around. First to my SAP colleagues and particularly Dave Brandow for organizing it. Secondly to the church people for supplying lunch – it was fantastic. Thirdly to Andrew and Darrell and Marcus and the other construction pros who were all helpful and very patient with a bunch of non-pros. Fourth, to the person who gave us the introduction and safety training – I believe her name was Janine but I feel terrible that I don’t remember for sure. She reminded me of Penelope Garcia from Criminal Minds – particularly her voice. And finally to all of the Habitat for Humanity people everywhere, those who donate, and those who volunteer. You are doing a great thing and I am looking forward to volunteering again next year.

Yahoo decides this mobile thing is a fad


According to All Things D, Yahoo has made a change to their company policy on working remotely. The new policy is, in a nutshell, don’t. Employees who currently work remotely will have to either move so they can work in a Yahoo office or resign. This seems to apply to workers who work 100% remotely as well as those who work from home one or two days a week. Does Yahoo really not understand mobile yet? The entire point of the mobile industry is to allow people to do stuff wherever they happen to be – you don’t have to go to your bank to do your banking. You can shop without going to a store. You can send email, surf the web, watch TV and movies, and listen to whatever music you want from anywhere. But Yahoo employees must be physically located in their offices in order to be productive? Really?

The reasoning Yahoo has given for making this decision makes little sense: they had lots of people who worked remotely and weren’t productive. So instead of firing the unproductive workers or making them come into the office, they decide to punish all of the productive remote workers as well.

Many tech companies talk about hiring the brightest and the best. Google is notorious for their hiring conservatism; they’d much rather pass on someone good than hire someone who turns out to be a bad fit. Yahoo is obviously not concerned with this. It sounds like they’d rather hire someone who lives physically close to a Yahoo office (or is willing to move) than someone awesome who doesn’t (and isn’t). Maybe they have great people up the wazoo and have decided they can afford to lose some of them, which they will. Maybe this is a cheap way of getting rid of some employees without having to pay them severance. That strategy would only work if the remote employees are the ones you want to get rid of and you don’t mind having some that you’d rather keep quit.

I work from home at least once a week (and more if there’s nasty weather), and have for ten years. Even though I don’t work for Yahoo, I take it personally when I read stuff like “Speed and quality are often sacrificed when we work from home”. I obviously can’t speak for everyone who works at home, but it’s quite the contrary for me. I frequently get a fair bit done at home – at least partially to avoid this very stereotype. If my manager decides that I don’t get as much done at home as in the office, he may decide to revoke this privilege, and that’s a privilege I greatly appreciate and don’t take for granted. I certainly have the occasional work at home day where I don’t get much done, but I also have the occasional work in the office day where I don’t get much done. I also have days both at home and in the office where I’m very productive. And this is all ignoring the fact that I work at least two hours longer when I work at home since I’m not driving to Waterloo and back.

I’ve done work in a number of different rooms in my house. I’ve brought my laptop and gotten work done in mechanic’s waiting rooms, doctor’s and dentist’s offices, hotel rooms, friends’ houses, my parents’ and in-laws’ places up north, and even a couple of Tim Horton’s. Every SAP employee worldwide is given a laptop so that they can work remotely if necessary. If I worked for Yahoo, their company policy would ensure that none of that would ever happen again.

Dear SAP/Sybase: I’d advise against this strategy. The goodwill that you’d lose from your employees would vastly outweigh any potential (and purely theoretical) productivity gains. Not only does it limit the people you can hire in the future, but I know of a few people who’d likely quit. In fact, I know of one brilliant engineer who you’d lose because he lives far away from the office and works from home a lot. And trust me, you really don’t want to lose this guy.

Yes, that’s right – you’d lose Ivan. Oh, and I’d probably be outta there too.

Disclaimer: I am not speaking for Ivan, nor am I making any kind of ultimatum to SAP/Sybase. Just saying that I disagree with this policy.

If the coffee machine breaks, just drink water


At work, we have a fancy coffee machine in the kitchen which is similar to the Tassimo thing that’s all the rage these days. (A friend of mine who didn’t drink coffee bought one for his wife, and now he drinks at least a cup a day. You can judge for yourself whether that’s a good thing or not.) The one at work takes little pouches (called “pods”) of coffee, tea, or hot chocolate, pushes hot water through them at high pressure, and gives you a steaming mug within about 30 seconds. I don’t drink coffee but I like the tea and hot chocolate it makes, and the fact that it’s ready so quickly is very convenient.

When it’s done making your beverage, it automatically drops the used pod out the bottom into a big bin that gets emptied regularly. Now and again a used pod will get stuck, but the people who supply us with the coffee pouches have posted a helpful (hand-written) list of instructions on how to clear it:

The order is VERY specific!!

Turn off, unplug. Open big door, then put your hand under silver packet door, pull off, set aside. Look inside. If you see a pod give 1/4 turn, GENTLY slide out the back (DON’T FORCE).

Plug in, turn on, close big door IN THAT ORDER.

Next, put silver packet door on by putting top into place, smack bottom with your hand. PACKET DOOR  MUST BE PUT ON LAST OR ELSE IT WILL NOT RESET! Good luck.

Good luck indeed. Sorry, but if your product needs this level of detailed instructions (complete with UPPERCASE COMMANDS) to fix a basic problem, you need to revisit your design. Luckily this has never happened to me but if it did, Tim Horton’s is only a 3 minute drive away.

Tool review: Microsoft Network Monitor 3.3


I have used Wireshark for packet sniffing and analysis for a number of years, starting back when it was called Ethereal. A little while ago I was using it to look at broadcast packets that our clients send out, and decided that it would be great if Wireshark could interpret our wire-level protocol and display meaningful information about the packets. After a bit of searching, I found that you can add plug-ins to Wireshark, allowing you to do whatever you want with the packet data. I found some detailed instructions on how to do this, beginning with:

  • Install a version of the Microsoft C/C++ compiler
  • Install a particular platform SDK
  • Install Cygwin
  • Install Python
  • Install Subversion
  • Get the Wireshark source
  • Configure the source
  • Build Wireshark

Once you’re done all that, you can start looking at building your plug-in in C. I set up a Windows XP VM and spent a day or two doing all of this, but never got to the point of actually creating the plug-in. A few days later we had a team status meeting, during which I mentioned this project. A colleague, Peter, asked if I had looked at Microsoft NetMon, saying that he believed it allowed you to add your own parsers as well. I downloaded it and took a look. Thank you Peter, for saving me days, if not weeks of development time. In less time than it took me to set up the VM in preparation for writing a Wireshark protocol analyzer, I had analyzers written for the majority of both our UDP and our TCP protocols.

Writing parsers

As a packet sniffer, NetMon is not really much different from Wireshark, though I find the interface a little more intuitive. This might be because I’m running on Windows, and Wireshark has always looked to me like a Unix program that has been ported to Windows rather than an application written for Windows. They both support both capture and display filters. NetMon has colour filters as well – particular packets or conversations can be coloured based on the filter results. You can view packets as they are captured, save them to a file, and load them back in again later.

But writing a parser is orders of magnitude easier than writing a Wireshark plug-in. You simply tell it what ports your protocol uses and what the protocol looks like in a proprietary language (called NPL – Network Monitor Parser Language) that’s vaguely C-like but very simple. Some properties of this language:

  • it handles bitfields, ASCII and Unicode text, and binary data, as well as various types of numeric values (8, 16, 32, or 64 bits, integer or floating-point, signed or unsigned, big- or little-endian)
  • you can define your own data types
  • there are a number of special data types built-in; if your packet contains a 32-bit IP address, for example, you can just specify it as IPv4Address and it will get interpreted and displayed as expected
  • you can make structs which group pieces of the data together, and arrays which hold collections of the same type of data
  • you use while loops and switch statements to modify behaviour. For example, your protocol might have a byte that indicates the type of packet, and then the structure of the packet depends on the value of that byte. No problem.
  • you can indicate both storage format and display format, so if you have a byte that’s 0 for a request and 1 for a response, you can display the words “request” and “response” rather than just 0 or 1. The rest of the code can reference this value by name and get 0 or 1. The display string can be as complicated as you want, even referencing other pieces of the packet by name.
  • it supports conversations, and there are variables that have global, conversation, packet, or local scope

The help file installed with the app describes each of the language features, and I found a document that describes an example protocol in great detail.

Drawbacks

The biggest drawback of this tool is the parser editor. It’s not very powerful – it makes notepad look feature-rich. I use Ctrl-Backspace (delete previous word) and Ctrl-Del (delete next word) a lot, since it’s supported in Windows Live Writer, Word, and emacs, but support is spotty – sometimes it works, sometimes it deletes the wrong word.

The main feature it’s missing is undo. It doesn’t even have a single-level undo. If you hit backspace one too many times, you’d better remember what that last character was because it’s gone. An editor that doesn’t support undo is pretty much unacceptable in this day and age, and I lost data more than once because of it. Once you realize that you can’t undo mistakes, you end up clicking Save a lot more often, and do things like copy the file to a backup file before you make big changes. I checked my files into source control and started checking them in periodically, which is a good idea anyway, but if the parser stuff wasn’t so damn cool, the lack of an undo feature might be a showstopper. Emacs supports Ctrl-A and Ctrl-E to get to the beginning and end of the current line respectively, and sometimes I instinctively use those keystrokes in editors where they’re not supported, like this one. Unfortunately, Ctrl-A here means “select all”, so doing that and then typing something is disastrous because there’s no undo, so you just lost your entire file. You need to quit the file (do not save!) and then reload it, losing whatever changes you had made. Even a single-level undo would save you from that.

The compiler has some problems as well – there were a number of times where I got compilation errors that were badly written or vague enough that I didn’t know what the problem was. It would point to what looked like a valid statement and say that it was unrecognized or invalid, and it turned out to be because of a missing (or extra) semi-colon on a different line, or a language rule that wasn’t obvious.

Once you’ve made the changes to your parser, you have to save it and then click “Reload Parsers”, which reloads all 370+ parser files it knows about. Surely there could be a way to just reload the one that I changed? Now, there are dependencies between files, so changing one file might require that a different file be reloaded, so reloading them all is the safest but it’s slow. Ideally, the tool should be able to figure out the dependency tree and only reload files that depend on the ones changed. And the tool should prompt me to save if I have an unsaved file and I click “Reload Parsers”.

If anyone from the NetMon dev team reads this, here’s a bug report: If I load a parser file, then paste some code into the file, it’s not marked as “dirty” until I actually type something. Also, if I load a display or capture filter from a file, this generally means “replace what’s in the textbox with the contents of the file”, not “insert the contents of the file into the textbox at the current cursor position”. I can see how that feature might be useful in combining filters, but it should not be the default.

As powerful as the NPL language is, there are things it simply can’t do. In my case, some of our packets can be encrypted or compressed, but the NPL language can’t decrypt or decompress them. It would be nice to be able to write a small plug-in that could do these types of things, but it’s not supported. The Wireshark approach would work for that.

Experts

For those analysis needs that are not satisfied by parsers, NetMon supports things called “experts”, which are external programs that can read the data from a capture file and analyze it in whatever way it wants. It sounds similar to a parser except that it’s written in C or C++ (or C#, I think) and has the limitation that it only works on saved files, so you can’t look at the results in real-time as you can with a parser. I’ve stared to write one of these to solve the decompression/decryption problem I mentioned above. There doesn’t seem to be a way to decrypt the data and write it out into a new capture file, but I can at least decrypt, parse, and display the data. I can reuse the parser code I’ve already written, since the program is dealing with pre-parsed information, but I have to grab each field individually and display it, so I essentially have to rewrite all the display code in C.

Summary

Overall, this is a very cool utility and has replaced Wireshark as my packet sniffer of choice. The documentation is pretty thorough and it includes some good examples. If all else fails, the parser code for all the other supported protocols is right there. There is a help forum to which I’ve posted a couple of questions and gotten quick and helpful responses. I wrote a while ago about how cool Windows Live Writer is, so kudos to Microsoft for yet another cool utility.

Telecommuting tools


I wrote earlier this week about my experiences telecommuting, and after reading a comment left on that posting, I wanted to write a little about the tools that I use to be more productive when working at home. But first, a bit of history.

Back when I started at Sybase in August of 1997, my friend and colleague Lisa suggested I ask the IT people for an extra monitor, keyboard, mouse, and power cable so that if I wanted to work from home, I’d just have to bring my desktop machine home and plug ‘er in. I did this, and this made things pretty easy for the one day every few months that I worked at home. My desktop machine, running Windows NT 4.0, had a modem installed, and when I wanted to check my email, I had to unplug the phone on the desk and plug the cable into the modem, dial into Sybase, and then synchronize Lotus Notes. I only did this about once an hour because it was a pain. If I wanted to check some files out of source code control, I had to write down the name of the file in my notebook, manually reset the read-only bit on the file, and make a copy of the file in case I needed to revert it. Many times I forgot the copy and was unable to revert if I needed to. When I got to the office the next day, I’d have to go through the list of files that I wrote down and check each one out.

After a few years of this, management sent an email around asking if anyone would be interested in having a laptop rather than a desktop the next time that machines were refreshed. I responded with something like “Yesyesyesyesyesyes” several milliseconds after reading the email, and a few months later, I had an IBM laptop. This made things orders of magnitude better — I brought the extra monitor and stuff back to the office, and was then able to sit at the kitchen table when working. I had broadband internet at home by this point but no router, so I still had to use the modem to get email. Another couple of years later, I bought a wireless router for home, as well as a wireless PCMCIA card that I could plug into my laptop. I installed the Sybase VPN software and nirvana was achieved. I could then simply run Notes like I normally would to send and receive email, and I could also use our source code control software directly. I subsequently tired of Notes so I moved to Outlook and then a few years later, Thunderbird.

Back to the present. Here is a list of tools I use to make telecommuting easier:

  • Firefox for web, Thunderbird for email, MSN Messenger for IM (this is true in the office as well as at home)
  • A lot of people seem to use Skype for phone, but I don’t really use the phone all that often. My regular phone works just fine. It does have a speakerphone, which makes things easier, especially for long conversations. Our old phone had a headset that worked pretty well too. That allowed me to walk around while talking on the phone which I always tend to do when not typing.
  • Broadband internet (absolutely required!) and wireless network, though wired would work fine if the router was handy or there were drops available.
  • VPN software is obviously a must. I won’t say which VPN product Sybase uses for security reasons (security through obscurity, dontcha know!), but one of the “features” is that it automatically drops the VPN connection every 12 or 24 hours or something, even if the connection is in use, and with no way to cancel it. When the connection has been idle for a while, I can understand it but every now and again I’m in the middle of copying some large file to or from work and I get a popup saying something like “The VPN connection will be dropped in 2 minutes“. Since there’s no way to cancel it, the message may as well say “The VPN connection will be dropped in 2 minutes. I hope you’re not actually using it, but if you are, well, it sucks to be you.” I just have to hope the file copy finishes in that time, or that I can re-connect the VPN fast enough that the copy just continues. If not and the copy fails, I have to reconnect the VPN and start the copy all over again. My description makes it sound like a huge problem, but it’s actually only bitten me once or twice in however-many years. It’s just annoying that I have to reconnect, especially since the VPN software is buggy and sometimes crashes while connecting.
  • Remote Desktop when connecting to Windows machines if possible. Some of our older (Windows 2000) test machines don’t support this, so we use VNC for those. But Remote Desktop is preferable because it’s faster and replicates the user experience more closely. If you maximize the Remote Desktop screen and the machine you’re connected to isn’t heavily loaded, you can almost forget that you’re connected to a remote machine. This is not the case with VNC.
  • When doing Unix stuff, I use VNC to connect to a Unix machine in the office and then use that to rlogin to other Unix machines. This works quite nicely, except that every now and again, I’ll be in the middle of typing some stuff and a character will get repeated for no apparent reason. I’ll be typing and something like cd /tmp/grrrrrrraeme will show up. Very irritating. I’m sure it’s a problem with the VNC client software, because I occasionally see it in the process of repeating – like it thinks I’m holding the key down when I’m not – but when I hit that key again, it stops. I suspect this is because it got a KEYDOWN message but missed the corresponding KEYUP message. I have never seen this when VNC’ing into a Windows machine.
  • I have a couple of VMware VM’s set up on our VMware server so I can do stuff on a machine that’s in our engineering subnet when I’m at home. Another VM has all the NetWare development stuff installed on it, though I rarely need that anymore.
  • Apple iPod (5G, 80 GB) along with a Logitech Pure-Fi Express Plus dock for music. Another absolute must.