Vim and tabs

At work, we use vim for our editing needs – which, as programmers, means we spend our day in vim.

We have a lot of mixed-format code – sometimes it has tabs, sometimes it has spaces.  Personally, I prefer spaces for my indenting, but I’m a convert to the church of make-your-code-match-the-existing-code.  As opposed to reformatting the existing code, which is soooo irresistible until you’re faced with a mountain.

So, I have to switch back and forth a lot.  Here, for the sake of posterity, is how to switch from spaces to tabs on-the-fly in vim:

:set noexpandtab
:set copyindent
:set preserveindent
:set softtabstop=0
:set shiftwidth=4
:set tabstop=4

Dad Strikes Again

I’ll be honest, this post is mostly to gloat.

The night after the other parental unit’s disastrous night in the tent, I offered the kids a second camping trip to the back yard.

Alpha slept all night… in the tent.  (willingly!)

Beta slept all night… in the tent.

I slept all night… in the tent.

I was the last one to nod off, and that was before eleven p.m.  And we all slept until after sunrise.

The results

I am exhausted. Didn’t get to sleep until after 3. Alpha bailed on us around 10, and went back to bed. Beta conked right out not long after. So I was stuck in the tent. All night. The ground was hard. Everything was wet with dew. But you know what? Watching Beta wake up in the morning, all snuggled up next to me was totally worth it.

Now if only I could walk without groaning…

Plans run afoul, but we intend to soldier on

Alpha and the tent
The plan for tonight includes camping!

We bought a tent a few months back, with the intention of trying this whole camping thing. I haven’t camped in years, and neither has Quinn. The girls think it is super cool and romantic and cannot WAIT to try it out. The summer is nearing its end, and we haven’t done it yet. We checked the weather, took out the tent, and put it up. As we’re doing this, we feel a couple of little sprinkles, more of a mist, but nothing big. There was nothing on the radar, and there is lovely blue sky above us. Nothing to worry about, right? Right.

Dramatic picture of the rain
This is the view of the rain down the street

The tent was set up. The kids put their blankets and toys in there. I have all the windows open to keep it nice and cool. Suddenly, the sky opens out of nowhere! I managed to get teh windows zipped up before the real rain started, and came inside (not sitting in an untried tent in a downpour). The view down the street was beautiful, with the sun shining brightly through the downpour.

I have been informed that there is now water in the tent from their feet. Yay. So I get to sleep in a muddy tent. Oh, well. Its camping, right? What’s camping with out a little mud? At least I don’t need to go out there until dark-time. I’m already having fun, can you tell?

Working with hidden files and directories

I had a problem.  My home directory is huge – 9 gigs – but I don’t know what’s taking up all that room. My porn stash is on another partition where my wife doesn’t know to look, so something is taking up a lot of room and I want to know what and why.

Oh yeah, I know how to check the size of a directory – use du ('du -sh .') for the usage of current directory (including all sub directories).  And, to see the size for every individual directory in the current directory, 'du -sh *'.  Easy peasy.

But that didn’t tell me what I needed to know, since the total size of all visible directories was less than a quarter of the used space.  That’s where hidden directories come into play.

Now, in the unix world, there isn’t a special file permission to hide a file or directory.  You just name it with a leading dot, like '.my_hidden_stuff', and most utilities won’t display it.  There’s nothing intrinsically hidden about it, though.  You can view them easily enough, e.g. 'ls -a' will show everything, including the “hidden” stuff.

What if you want to see just the hidden stuff?  It’s not as simple as saying 'ls -a .*', since that includes '.' (the current directory) and '..' (the parent directory), too.  Some utilities, like du, will then combine arguments with a common root, which means you get the summary for the current directory, but none of the hidden files broken out.

Solution

In bash, at least, you can include simple regular expressions on the command line.  (Remember, in unix, your command line is pre-processed by the shell (bash, csh, tcsh, etc.) and the expanded items are given to the program. DOS/Windows, by contrast, the expansion and processing is the responsibility of the program and command.com (or cmd.exe) does little processing itself.

The regex for all dot files, minus ‘.’ and ‘..’, is '.[^.]*' (which basically says, “start with a dot, and the next character must exist but cannot be a dot, and then anything goes after that”).

So, my command to see how much space each of my hidden directories are using, is

du -shx .[^.]*

I hate you, Murphy

So, the baby gate is coming off the wall. This is a problem, as the Official Immigration Gate between Dog-ville, and Kitty Haven (which is made up of two neighborhoods, Mel-topia and Oo-land) must be operational at all times to prevent hostilities between the natives.

Obvious solution: get more of those oak medallions, urethane them, and use them to attach the gate to the walls. Well, I got the medallions. Urethaned them (that stuff stinks to high heaven). They are outside drying in the sun as we speak, with several hours to go.

And, lo, what do I see on the horizon? The maw of an angry beast of a storm.  Dammit.

Well, there she is!

Alpha child has been after us for riding lessons for years. We broke down a couple of years ago, got the helmet and boots. She lost the helmet, and we decided it was going to be a while before we tried again.

Well, here she is:

Alpha on Chester

She is so proud of herself (and well she should be). She payed attention to the horse and her instructor. She backed Chester up (right on cue). And then she insisted on helping out with the barn work afterwards. She got to help take off the saddle, bridle, brush him down, and then (wonder of wonders) CLEAN THE BRIDLE.

Happiest kid on earth. Yup.

Shrimp scampi the heathans will eat

Take a chunk of butter and some olive oil. Heat it up in a frying pan. Toss in a pile of minced garlic. Mix of around until its a little brown (careful – this stuff turns to sludge in seconds!). Toss in some shrimp (maybe a pound). Add some cilantro and lemon juice (not too much or the kids won’t eat it. I kept going until they started yelling at me to stop). Cook until the shrimp are pink. Serve over pasta.

Bask in the glow of creating a dinner the stinkers will eat.