Archive for 2009

a filter for life

November 5th, 2009

There was a movement within the Norwegian education system at one point to emphasize the goal that kids in school should be critical. More than that, it should be the goal of the education system to teach us to be read critically. Don't take everything you hear as gospel. This was back when I was still in junior high, so a good 15 years back. I don't know if this theme is still current today, but at the very least it made a good pass through the common consciousness at one point.

So why did this come about? Well, in the early 90s television was privatized. There had been cable tv for a number of years already, but in 1992 the channel TV2, the first commercial tv station to broadcast nationally, alongside the state broadcaster NRK, was launched. Effectively, television was let go from under the control of the rather insular NRK and freed to be driven by commercial profit. Naturally, TV2 in short order proceeded to import all of the popular culture, chiefly American, that has informed our lives. Another characteristic of TV2, quite unlike NRK -- the absolute sterility of any form of even mild intellectualism. (Aside from NRK which may have as much as 2-3 weekly hours of programming suited to the more discerning viewer, provided the topic is up your street.)

Another big development in the mid and late 90s, of course -- wide access to the internet. Here again is a brand new medium with immense amounts of information and culture "beamed" right into our homes.

I feel it was these two developments that formed the impetus behind this fashion within the education system. All of a sudden students would be writing essays using web pages for sources that, believe it or not, were just incorrect. :eek: Oh noes, something has to be done! And so it began. The internet is not trustworthy. You can't believe everything you read. The deeper reasoning behind this is the question of motive. More important than what they are saying; why are they saying it? Back in my junior high days we received the dumbed down version (as, actually, with everything in junior high). The question was framed in terms of sources. This source is reliable, because it's Encyclopedia Britannica. This source is not, because it's a web page, or I heard it on tv. Never mind who gets to decide what is reliable and why.

Of course, the truth, as your astute self would have figured out by now, is that nothing is in and of itself trustworthy. It's not just when you go online that you find garbage. There's just as much garbage in books, in what your teachers tell you, in what your parents tell you, and above all in what your peers tell you. You need to be critical of all this stuff, not just of those crazy people on the internet.

I'm inadvertently rehashing Jürgen's argument here. I read his entry and didn't give it any more thought, but perhaps my subconsciousness has been chewing on it ever since? Thanks, Jürgen.

Naturally, some people are just malicious, but that is not the main problem. Even if you do have a piece of insight that you honestly believe is beneficial to someone, there are still a lot of things that can go wrong:

  1. You're plain mistaken.
  2. It works for you, but it doesn't work for everyone.
  3. Even though you have the right idea, you fail to communicate it effectively.

The last one is particularly unfortunate. How many times has someone told you that they've just this discovered this new thing and it's everything they needed, and then you say "but I told you that already a long time ago!". Well, I guess you didn't tell me in the words that I needed to hear in order to absorb the information, or in order to be convinced.

Parental advice, of course, is susceptible to the same flaw as those self help books. I'm sure you've seen some of those around, the basic premise is always the same -- some person has figured out how to do something and wants to tell everyone. The problem is that just because it worked for him, doesn't mean it will work for you. Especially when you hear it from a secondary source (a relative comes up and says "I read this amazing book, it changed my life, all you have to do is.."). But it's not science. At best it "sorta works a lot of the time, kind of".

So over time you develop a filter. "This person is not worth listening to on these topics, this book is written by someone who has no idea what he's talking about, this website is usually reliable on these issues". Now everything depends on that filter of yours. You may find one day that you bought into some utter nonsense, or that you discarded good insight.

how much time you got?

October 23rd, 2009

One of the most important currencies of today is time. Of course, people have always been trading in time, paying people to do things for them that they were either too lazy, or "too important", to do. But in today's world time has gone as far as to replace money in the daily rhetoric of many people. I wonder if people in the past spent as much time complaining about not having enough time as it's common to do today. We have more freedoms and opportunities than ever, there's just no time to enjoy them all.

The biggest complaint among people today, once they stop complaining about lack of money, is lack of time. There is a strange kind of contempt for people who have time.
- Look at this cool thing these guys did.
- Yeah they really have a lot of time on their hands (those rich bastards!)

Strangely enough, there are also those who have a sense of pride about *not* having time. They just love fake-complaining to you about how busy they are. Well who decided you have to be so busy? Oh, I know, *you* did. Here, I have the solution for you. Ditch _everything_ that you're doing right now and you'll have more time than you ever dreamed of.

Being busy is also the standard way to lie to yourself when rejecting people. "Oh dear, I'd love to come to your whatever, but I'm just so darn busy". No, you just decided that you'd rather do something else. *I* know what it means, and you might as well just have told me that you weren't interested instead of telling yourself that you're a caring person who never lets anyone down. Because that's just plain obnoxious.

Now, what people seem to forget is that unlike money, time is very much your own choice. You don't choose to be born into a wealthy family, but you can easily choose to be rich on time. Here's a simple test: do you have a tv? Unplug it. You just won hours upon hours of time and it didn't cost you a dime! (Unless of course tv is what you most want to use your time for, but then you shouldn't complain about lack of time, you should revel in all the tv time you have!)

findpkgs: Find packages for application

October 14th, 2009

Every distribution has a package manager and a whole lot of work goes into maintaining packages and correctly resolving their dependencies. This is a descriptive kind of dependency tracking.

The other day I had the idea of using a more "evidence based" method. Given a linked binary, you can find out what libraries it uses with ldd. (This, however, will not account for any dynamic linking that happens during runtime.) More interestingly, perhaps, given a running process, you can figure out which files it using to run. There is lsof, and if not, /proc/pid/maps has that information too.

Such a list of files can then be fed to the package manager to find the packages which own them.

For instance, which package owns init (on an Ubuntu system)?

$ findpkgs 1
upstart

What's needed to run ls (on a Gentoo system)?

$ findpkgs ls
sys-apps/acl
sys-apps/attr
sys-apps/coreutils
sys-libs/glibc

What about a Python application like iotop?

$ findpkgs `pgrep iotop`
dev-lang/python
dev-libs/openssl
sys-libs/glibc
sys-libs/ncurses
sys-libs/zlib

The query-package-manager-for-owner-of-file tries to figure out which package manager is used on the system in this order:

  1. paludis
  2. qfile
  3. equery
  4. dpkg
  5. rpm

To be honest I'm not really sure how useful this is, I just put it together since I figured out it could be done. It *can* answer the question: which packages are required to run this application? (Or to be more precise: to achieve this specific runtime state of the application.) So if you write an app, send it to a friend and he can't make it run, you could use findpkgs to get a list of them he needs to install (provided he's on the same distro and all that).

# Author: Martin Matusiak <numerodix@gmail.com>
# Licensed under the GNU Public License, version 3
#
# <desc> Find packages by binary or process pid </desc>
#
# <usage>
# source this file in bash, then run `findpkgs`
# </usage>


function _findpkgfor() {
	local file="$1";shift;

	if which paludis &>/dev/null; then
		paludis -o "$file" 2>/dev/null | grep '::installed' \
			| sed "s/::installed//g" | tr -d ' '
	elif which qfile &>/dev/null; then
		qfile "$file" 2>/dev/null | awk '{print $1}'
	elif which equery &>/dev/null; then
		equery belongs "$file" 2>/dev/null | awk '{print $1}'
	elif which dpkg &>/dev/null; then
		dpkg -S "$file" 2>/dev/null | awk '{print $1}' | tr -d ':'
	elif which rpm &>/dev/null; then
		rpm -qf "$file" 2>/dev/null | grep -v "not owned"
	else
		echo "No known package manager found"
	fi
}

function findpkgs() {
	local arg="$1";shift;

	if [ ! "$arg" ]; then
		echo "Usage:  findpkgs [ pid | /path/to/binary ]"
		return
	fi

	local pid=
	local arg_new=
	local bin=
	if echo "$arg" | grep "^[0-9]*$" &>/dev/null; then
		pid="$arg"
	else
		arg_new=$(which "$arg" 2>/dev/null)
		[ "$arg_new" ] && arg="$arg_new"
		if ! echo "$arg" | grep '^/' &>/dev/null; then
			echo "Can't find absolute path (or not a binary) for: $arg" >&2
			return
		fi
		arg=$(readlink -f "$arg")
		if ! file "$arg" | grep 'ELF' &>/dev/null; then
			echo "Not a binary: $arg" >&2
			return
		fi
		bin="$arg"
	fi


	local fst=
	local fst_new=
	local files=
	if [ "$pid" ]; then
		fst=$(ps aux \
					| sed "s/^[^ ]* *//g" \
					| grep "^$pid " \
					| awk '{print $10}' \
					| tr -d ':')
		fst_new=$(which "$fst" 2>/dev/null)
		[ "$fst_new" ] && fst="$fst_new"
		if ! echo "$fst" | grep '^/' &>/dev/null; then
			echo "Can't find absolute path for: $fst" >&2
			unset fst
		fi

		if $(which lsof &>/dev/null); then
			files=$(lsof \
						| sed "s/^[^ ]* *//g" \
						| grep "^$pid " \
						| awk '{print $8}' \
						| grep '^/' \
						| sort \
						| uniq)
		else
			files=$(cat "/proc/$pid/maps" \
						| awk '{print $6}' \
						| grep '^/' \
						| sort \
						| uniq)
		fi

		files="$fst $files"
		for file in `echo $files`; do
			_findpkgfor "$file"
		done | sort | uniq

	elif [ "$bin" ]; then
		files=$(ldd "$bin" \
					| awk '{print $3}' \
					| grep '^/' \
					| sort \
					| uniq)
		files="$bin $files"
		for file in `echo $files`; do
			_findpkgfor "$file"
		done | sort | uniq
	fi
}

un giorno lento

September 22nd, 2009

Oggi avevo mal di testa. Ecco perché non ho fatto molto. Ho lavorato un po', e poi ho fatto un giro sulla mia bicicletta. Quando sono tornato a casa avevo sempre il mal di testa, ma un po' meno. Poco dopo ho fatto alcuni esercizi di italiano del mio libro per imparare la lingua, e quindi mi sentivo meno male. Forse imparare l'italiano fa bene per il mal di testa?

Starbucks? Not all that it's cracked up to be

August 19th, 2009

So I went by Starbucks today. The line wasn't quite as long as I had seen it on previous occasions. I went in. What struck me right away was how noisy it was inside. Mind you they're located inside a busy train terminal, with nothing but a delimiting glass panel wall, so it's not going to be a quiet, cozy café. But they clearly had done nothing to insulate from the noise. Which is just as well, because most of it was coming from inside the Starbucks. There was music blasting, and five staffers yelling orders over the music. It was literally as noisy as MacDonalds on a busy day. So much for ambience, none of it. Those stories about people hanging out in a Starbucks - those places must be categorically different from this one.

As I was pondering this, the line advanced and soon I found myself making my order. And that's when I noticed how poorly organized the staffers were. First I made my order to the girl leaning over the cake counter. She proceeded to yell it down the line to the production division. Then I approached the cash register and had to repeat my order to another girl. "A large caffè latte." "Was it a venti?" "I have no idea, I said large." I refuse to speak their pretend language.  The girl who had taken the order chimed in to clarify. I forked over cash and, strangely enough, did not receive a receipt. Are they saving on paper?

That's when I got in line behind the six previous customers who were still waiting to get theirs. Clearly, they were backed up with orders.  My coffee was ready before all of theirs was. But the girl in production had no idea whom it was for, because there were no receipts to work from. The orders were filled, but how to match them with customers? So she asks every person in turn "what are you waiting for?" That was the third time I had to say my order.

All of this somehow distracted me from noticing the beating I took on the coffee. €3.95 for a large caffè latte? That's hilarious. At MacDonalds you can get a meal for a little over 5 bucks. Maybe they could justify the price if the café was a great place to hang out. Or if the coffee were especially good. Or if they were especially well organized and efficient.