Mac & Vagrant problem with setting up NFS? Could be your exports file

Suppose you get the following message when you're trying to provision a new vagrant instance:
NFS is reporting that your exports file is invalid. Vagrant does
this check before making any changes to the file. Please correct
the issues below and execute "vagrant reload":

exports:2: path contains non-directory or non-existent components: /path_to/something
exports:2: no usable directories in export entry
exports:2: using fallback (marked offline): /
This probably means that you had some older VM images kicking around, and now you've remove them, but the /etc/exports file wasn't cleaned up. Simply open the exports file and delete all lines associated with VMs that don't exist any more:
sudo rm /etc/exports
sudo touch /etc/exports

vagrant halt
vagrant up --provision

How to wipe clean a log file

Or log files. Sure, you can roll them out, using logrotate, or you can just let them build up like most of us do and then delete them. Or you can wipe them clean at random unplanned intervals.

If you do that, then it's a simple command:

sudo truncate *log --size 0

Assuming all of your log files end in "log"


The autistic programmer

It seems to me that developers can be far more stubborn than any other phyllum of worker I have known.

Not only do they get set in their ways, they get wedged in their ways, so tightly and so inextricably, that any attempt to dislodge them will end in disaster. Example: just try to get a developer who writes his functions in camelcase to use all lower case.Instead of writing function

myFunction()

you require that he writes:

function my_function() 

Try and tell a programmer to make that kind of a life-altering change, and then sit back, because, if you've never seen the Exorcist, you're about to see it now. You're about to see heads spinning 360 degrees and pea soup flying in every direction.

As a consequence of these - ahem - nuances, developers get an awful rap. They are resistant to change. They're surly. They're arrogant. They have massive egos.

But it's not really true. Few developers have big egos. For the most part, they have fragile egos, if they have egos at all.

The typical developer doesn't think massively of himself. He can barely make eye contact. And therein lies the root of the problem.

Developers are not arrogant and egotistic. Developers, for the most part, aren't even geeky nerds with low social skills. Developers are, for the most part, autistic.

The world of programming is a honeypot, attracting Aspbergers' like they were flies.

Keep that in mind the next time you are about to launch into a tirade with some junior developer who flouts convention when he puts braces on their own line.

When the cat is away...


The ballad of a man whose wife and kids are out of town for the weekend. As told through twitter.
Wife and kids are out of town for the next two days. I miss them already. In my underwear. Eating cheetos. Watching Netflix. #TheHorror
The hardest thing about having to stay home when your wife and kids take a short vacation is making sure they don't know how excited you are by prospect.
For the next 2 days, it will be like I'm in an alternate universe where I never got married. But my house is strangely filled with toys.
It's like Home Alone. Except no one left me behind. And it's not Christmas. And I'm not a kid. You know what, it's nothing like Home Alone.
The last time I was left at home alone, I watched all three Lord of the Rings, and blew $250 at online poker. Pretty sure I can top that.
She phones me only an hour after leaving. "Do you miss us yet?" she asks. "I sure do!" I agree. "Say, do you know if we own a blowtorch?"
Strangely paralyzed with indecision. What do I do first? A movie? Video games? Eat Cheetos in my underwear? Get drunk and yell at the walls?
Here I am alone in the house for the first time in years, and stupid Netflix keeps recommending kids movies. Damn you, children!
The only problem with being home without the wife and kids is that, at bedtime, you kind of want to check for monsters under the bed.
The wife and kids are out of town. On my first night alone, I did nothing. Turns out they're not holding me back. I'm just lazy.
For my first dinner without the rest of my family, I wanted go to somewhere they wouldn't normally want to go to. But I'm lazy. I went to the Food Court.
Last night, I could have gone to the Cineplex to watch a blockbuster. Instead, I watched Netflix. A movie from last year. That I've seen before.
Now that my wife and kids are out of town, the only rebel thing I can think to do is cook up some organ meat. #F***ThePolice
Psychological breakthrough. Now that the wife and kids are out of town, I have discovered my inner child. He likes Cheetos and Netflix.

An impression of myself

And now, my impression of myself at every meeting I've ever attended, in haiku form:

Check your phone check it
check it check it check it now
Maybe somethings new

The difference between perl backticks, system and exec

If you have to execute a system call using perl, there are three ways to do it. Two of them are synchronous and your perl script will pause until the system call is executed completely.

Be careful in your selection. If you choose backticks or system( ), your script will not continue execution until the process call is complete. If that process takes too long, and this is a CGI process, the calling script could timeout, and return a 504 error to your browser.

exec

This call executes a command and doesn't return. This, effectively, kills your script.

system

This call executes a command, and the calling script will wait for the command to execute before continuing. However, you can work around this by backgrounding the process:

system("perl some_process.pl &");


backticks

This call executes a command, then waits for the STDOUT output of the command, before continuing.


The autistic developer

It seems to me that developers are far more stubborn than any other phyllum of worker I have known. Not only do they get set in their ways, they get wedged in their ways so tightly and so inextricably, that any attempt to dislodge them will end in disaster.

Example: just try to get a developer - who writes his functions in camelcase - to write his functions in all lower case. So, instead of writing

function myFunction(){

you require that he writes:

function my_function(){

Try and tell a programmer to make that kind of a life-altering change, and then sit back. If you've never seen the Exorcist, you're about to see it now. You're about to see heads spinning 360 degrees and pea soup flying in every direction.

As a consequence of outbursts like these, developers get an awful rap. They are resistant to change. They're surly. They're arrogant. They have massive egos. But it's not really true. Few developers have big egos. Rather, they have fragile egos, if they have egos at all. The typical developer doesn't think massively of himself. He can barely make eye contact.

And therein lies the root of the problem. Developers are, for the most part, not arrogant and egotistic. Developers, for the most part, aren't even geeky nerds with low social skills.

Developers are, for the most part, autistic. The world of programming is a honeypot, attracting Aspies like they were flies.

Keep that in mind the next time you are about to launch into a tirade with some junior developer who floutes convention puts his braces on their own line.

Enough with the controversy

Enough with the endless controversy over braces. Same line or their own line – who cares. Why have we become such a fractured and polarized community over this? We aren't the Capulets and the Montagues. And this is not Sophie's choice.

Evil Guard: I will let you escape the concentration camps, but you must first choose between placing your opening braces on a new line, or on the same line as the function or conditional.
Sophie: Can't I do both as they suit me?
Evil Guard: No.

The difference between unit and functional tests

I do it all the time.

I call everything a unit test, when it really isn't. I can't help it. I've been conditioned because I use a tool called phpUnit to run our automated testing. As a consequence, I refer to Functional tests as Unit tests. But it's important to understand the differences.

Unit tests

  • each test tests one little thing in isolation from everything else,
  • Usually a test for a small method,
  • dependencies are faked, stubbed or mocked - there is no actual database connection,
  • they run very quickly,
  • these should be the vast majority of your tests,
  • they should be built as you developer (TDD)

Functional tests

  • these are high level tests,
  • they test the integration of the system with other parts,
  • they have dependencies (ie. database, other services, filesystem, etc),
  • run much slower than unit tests,
  • these should be at a bare minimum,
  • they are best built to duplicate a test that would be run by a QA analyst
  • they should be built using something like Selenium
  • they should be run separately from the unit test suite
Mixing Unit and Functional tests in same test class is risky. It means that your setup and teardown, which might include loading of fixtures, runs with every single test, including the unit tests. If this is over enough test classes, you'll find that your test suite will quickly get to the point where no one is running the tests locally, because they take too long.
To sum up:

  1. Keep your unit and functional tests separate
  2. Never connect to the database with a unit test
  3. Always run your unit tests before a commit (they should be very fast)
  4. Build your functional tests to be front end tests, mocked with Selenium or something similar
  5. Run your functional tests as part of the QA regression suite

Guess the browser


Brace yourself: there's an argument coming


I am now resident in an insane asylym where the coding standard is to have every brace on its own line.

I'm a great believer in In House coding standards, especially anal coding standards, because they serve a valuable purpose: they give us a weapon with which to whip the juniors. But sometimes, things go a little too far. Like our enforced coding standards:

Instead of:

if ($x) { doX();}
else{ doY();}

you must write:

if ( $x )
{
   doX();
}
else
{
   doY();
}

This, I am told, increases readability, carrying the direct implication that the former decreases readability. This is like asserting that raising corporate taxes will cause economic ruin. It sounds right, but it's never been put to the test. Likewise, I have yet to see any evidence that one brace convention is more readable.

Really, are we all children? If we don't see the braces on their own line, do we panic and spill our coffee over the keyboard? Has either one been the source of bugs in any program?

Manager: You've been working at your desk nonstop 16 hours. What's going on?
You: I'm trying to debug this program, but there are too many braces on the same line. I keep getting confused.
Manager: Deep breaths. Take deep breaths.
You: But it gets worse! There are all these braces that are on their own line. I don't understand why they are there.
Manager: A program with braces on the same line as the function AND braces on their own line. (picks up phone) Ted, you better wake up the President.

The real reason we have these arguments isn't based in rationality. There is no correct answer. The real reason we have these arguments is that most coders are autistic to some degree. Putting function braces on their own line is more than just a preference for them. It's how they live their lives.

In the same way that the Rain Man absolutely had to watch Judge Wapner every day, developers absolutely have to code in the specifically prescribed manner.

The soul search of riding the bus

I can't get it right. If someone sits beside me on the bus, it pisses me off that they have encroached on my personal space, and I steadfastly refuse to close my knees .

But if they walk past me, I take personal offense. I've tried smiling, I've tried looking them in the eye as they walk down the aisle. Or I'll studiously look away. It doesn't matter. They don't sit beside me. Which I realize is a good thing. But it's a bit of a shot to the self esteem.

Google tells us that it's a good thing to have only Google

Remember when Ask Jeeves, Lycos, and countless other search engines were all muscling against each other for the right to tell us where everthing was? No one realized it was a battle to death, and they were fighting over who could best predict what mankind wanted.

No one ever thought that having alternative search engines was particularly useful. We know this, because we've googled it and Google tells us that we only want one search engine.

Big Broogle

Does it make anyone else uncomfortable that Google has spent the better part of 20 years perfecting the ability to guess what everyone is thinking about?