Eric Gazoni's Blog

Daily thoughts for computer scientists

Month: March, 2011

Mounting virtualbox osx share on ubuntu guest

When using auto-mount I could list directory content, but only as root. When using my regular user, I had a “Permission denied” error. Apparently it’s an old issue that was not really fixed.

I spent an hour looking for this, so I’m posting it in hope it can help someone:

Let’s say I have a “Documents” shared folder on my OSX host, and I want to mount it on /media/my-share on the Ubuntu guest:

  • Install Vbox additions
  • Add the share in the “Shared Folders” screen, in Virtualbox, give full access, but don’t check auto-mount
  • Check your uid&gid on the Ubuntu guest (by doing a cat /etc/passwd and looking for the numbers after your name, mine are 1000 and 1000)
  • Add the following line in your guest’s /etc/fstab
Documents   /media/my-share  vboxsf  uid=1000,gid=1000,nodev,noexec,nosuid,auto,rw 0 0

 

Working from the couch

Red sofa

Image via Wikipedia

Those days I’m in southern France, in a small (15 sq.meters) flat originally rented for my wife who’s working at the local museum.Even if I’m here to cheer her up, I still have to get some work done, but obviously there is no room for a large desk (nor for any desk actually), an external 24″ monitor, or my beloved wireless keyboard and trackpad.

There is not even a decent table, we have to put our dishes on a stool and eat in the sofa. In those conditions, I’ve been trying two configurations: the standing desk and the lap desk.

The standing desk

Pros

  • trendy
  • good for your back as it preserves the ‘S’ shape of your spine, instead of bending it into a ‘C’ like modern office chairs do
  • looks like a good idea when the only flat surface you have is a 30cmx40cm stand-up kitchen table

Cons

  • 16 hours on your feet is quite a lot of time, especially when you don’t have proper shoes nor proper rubber carpet
  • putting an expensive laptop on top of plastic candy boxes, next to an open window is … stressful

The lap desk

Pros (compared to placing the laptop directly on your lap)

  • comfy, veery comfy
  • prevents lap burns
  • greatly improves wrist position and angle
  • you can move around the house (seated on the couch -> seated on the armchair -> laid on the couch)
  • as the couch/armchair is much softer than the usual office chair, you can stay seated much longer before feeling tired

Cons

  • (not sitting properly in the couch is) bad for your back
  • (being seated too straight in the couch is) bad for your neck
  • (not moving your bum for 4 hours straight is) bad for your knees
  • (not changing your posture for several hours is) bad for your shoulders

As I couldn’t find any affordable cardboard boxes to build my poor man standing desk, I opted for the Logitech N550 lap desk which is an excellent product. It keeps the laptop cool, and the additional speakers have more bass and power than the internal ones. This version is for 14″ laptops at best, the N700 and Comfort Lapdesk are slightly larger, but the foam shape is different (it ends with a ‘^’, while the N550 is like a ‘<‘) and I find it more comfortable this way.

I’ve also looked at different brands and models, but the Logitech are the only ones that I find soft enough and properly engineered, for example, CoolerMaster makes ugly all-plastic stuff intended for overheating laptops, with giant fans, but no foam, no cushion of any kind. Not suitable when you need to work several hours a day.

To avoid neck and shoulders pain, it’s important to be properly seated, and moving around the flat for 1 minute every 2 hours keeps your knees from hurting.

It won’t replace my casual desk at home, but I definitely won’t work with my laptop on my lap anymore, and after one full week in this position, I found that I could work for 4-5 straight hours without notice, like in good days at my office desk. Totally worth it !

What I learned from game developpment

A decade ago, while I was finishing my master’s degree, I also started developing games with a few friends. Nowadays, I can’t overestimate the benefits those years of late-night-coding brought me, and here are a few lessons I learned in the meantime:

Data is important to the user

In online games, players are your customers, and they pay the high price of their free time to use your product. As most of us know, free time is a scarce resource, and your players won’t stay for long if you mess with their time, such as because of a bug, they lose all their possessions (technical issue), or if their character is killed too often (game logic issue), …

Having no backup of your database is the surest way to lose all your players at the first server crash.

Lesson: backup systems should be designed at the same time as your product, so you never lose a customer because you screwed up 10 years of accounting and the backups are unreadable.

Data quality is important to the coder

If you want to know where you are going, what happens in your game, and feel the effects of the changes you make to the world, you need some feedback systems. And there you start to pull your hair when you try to automate checks or data aggregation with non normalized data. For instance, if you want to make statistics over genders of in-game characters, and let’s say gender is a free-text field, then you’re in trouble: most people won’t fill the box, some will fill garbage, and some will try to fill it, but are not able to spell properly (yes, it happens). Therefore, you have useless statistics, stating that 30% people play a girl, 60% a boy, 1% a ‘dude’, and 9% of players actually play a droid.

Lesson: the earlier you freeze possible entries for your data, the less corruption you will have in the future. You never know what data could be useful one day.

“Hell is other people”

Amongst all the different behaviors you can meet, the script kiddie is the most difficult you can have to deal with. This guy will try to input all kind of data into your forms, hoping it will crash and get him access to something interesting. He will hammer your server with requests, because he read somewhere he could become root somehow by doing it.

Needless to say, he will more often crash your game than root it, and also make a lot of people frustrated because they just try to play and the game is down again. He will also create a myriad of fake game accounts, and automate them so he becomes a one man army.

Lesson: you should build your security model first, and then add features on top of it it, not the other way around, or there will always be a hole in which a malicious user will try to sneak in.

Copy-Paste is your best friend as long as you’re not sleep deprived

“I’m in a rush, I’ll just copy this old code and change it so I’m done earlier”. Except you don’t change it. Or worse, you don’t change it enough, and suddenly have all those crazy bugs coming from everywhere. You check and double-check the changes you just made, but can’t find where the issue is. Usually, it’s because you just replaced 3 parameters, but forgot the 4th, and your brain skips it every time you read it.

Lesson: instead of copy-paste, think about refactoring your code, write generalist functions and don’t duplicate code anymore !

Version control or die

There was a time, I did not know about version control at all, and trusted my luck to revert changes made over 3-5 files. It can sometimes work, but sooner or later, you’ll forget one of the changes, and then you’re stuck in a looong bug hunt. Repeat again, and then your entire code base start working against you, showing incorrect data to your players, or granting them with unwanted powers. This actually happened to me, and I decided to restart the whole project, from scratch, but with version control from day one.

Lesson: programming without version control is like walking on a tightrope: one day or another, you’ll fall, and this day, you’ll regret not to have a safety net.

openpyxl 1.5.0 released

It has been almost one full year since I started this project, and it has now reached a state where it is well suited for production, and intensively tested by an increasing number of people around the globe.

The most recent additions I’m the most proud of are the optimized reader and writer, that become stable in this version. It took around 6 months to get them working properly (the reader was the hardest actually), and now they’re here !

You can read and write workbooks of any size, with low and almost constant memory consumption (which is not the case with Excel actually).

I’m also really happy that people keep sending patches and asking for features, so the project continues to live, even when I’m not fully available to work on it.

You can get the latest version of openpyxl either with easy_install:


easy_install openpyxl

or from the official website.