Rawr, Lion

Mac OS X Lion If you've read any kind of tech news in the last few days, you might've noticed that Mac OS X 10.7 Lion is out. I wasn't going to upgrade for a while, but then it launched and I did. So I've been using Lion for a few days now, and I thought I'd join the endless ranks of people on the Internet talking about Apple's latest big cat. I'm not really going to be much competition for the real tech writers, so if you want to learn nearly everything about Lion, I recommend making a pot of tea and sitting down to John Siracusa's latest tome. Otherwise, read on to see what I think of the new features.

read more

n+1 years

One year ago tomorrow, I graduated from college. As my younger friends graduated today (thanks for the quasi-livestream, Skye), I actually realized this fact: it's been a year. A year as one of the dead. A year in the real world. It's bloody strange. On some level, it's unbelievable that I've been out for a whole year. Graduation was just a couple of weeks ago, wasn't it? I can still remember lectures good and bad, evenings in the muddhole, nights working in Platt, as though it were all just yesterday. On another level, though, it almost feels like I've been out forever. I have a life, and it fits me sort of like a glove. I sit in my apartment and I feel like I'm home, and I really don't know when that started. I can remember the details of life in college, but it no longer feels like I'm on a particularly protracted vacation.

Looking back with an iota of distance, Mudd was a really transformative place. I can look back on things I wrote a few years ago (hello first post), and it seems really weird. Mudd is a place that tears you down and builds you up in a shape that it finds amusing. Five years ago, about to graduate from high school, I wouldn't've been able to imagine pulling an academic all-nighter. Nor would I be able to understand the camaraderie of a research team, the bond of dorm-mates, or, well, you get the idea. By the time I crossed the stage last year, it would've been strange to me to go to bed on the same day I woke up.

And now? Things certainly have changed in the last year. Some for better, some for worse. I still have a lot of friends, which is nice. Some of them are even people who didn't go to Mudd with me. But gods know that nothing compares to having everybody you know or want to know living within a few hundred yards of you. Now I have roughly as much money as I could reasonably spend, which I suppose is a good thing. No more problem sets, which is both a blessing and a curse. Yes, I still have that dream sometimes where I'm in the exam for a class and I realize that I've never done any of the homework or the reading, and have no idea what the material is about. I know, it's clichéd.

My gods, dear reader, books! Mudd spent four years drilling into my head that books are those dense and mysterious things that you've got to read until you can't read any more just to keep on top of your classes. I've been working hard to get past that — nearly up to 100 books read since graduation, most of which are so light and irrelevant that you couldn't teach a class with them if you tried. That's a pretty wonderful part of the real world.

Looking out from the top of my building

Then, of course, there's the specifics of my situation. Working at Yelp is pretty good. It certainly has its moments of fun. And it provides me with plenty to do, although when I try to work sane hours, everybody says I'm working too much and should go home. Which is not necessarily wrong, but still rankles a bit. Living alone in the city, that's a more nuanced thing. I love my apartment, and my neighborhood is pretty cool, but there's no getting around the fact that it's pretty weird to live by yourself in the real world. You have to remember to vacuum. And no matter how delicious the food you cook is, there's always dishes afterward. And you have to work a bit to keep the antisocial factor from turning you into a caricature of yourself. On the other hand, there are no other people to bother you. Nobody complains if you play bad music, sleep weird hours, or let the windowsills get dusty. My view (right) certainly is a lot different than my view a few years ago.

The last year has had a lot of crazy things happen in it. It's also had a lot of perfectly humdrum things. It's life. Normal, plain, vanilla life. Who'd've thought?

This isn't a blog post that has a conclusion or a point. It isn't a guide or a manual. It's just an expression of how profoundly strange it is to be an adult, one year in.

Good night, reader.

*nix Tip of the Day: Unix Time

As the unix-savvy among you probably know, there is One True Way to tell the time: the number of seconds elapsed since midnight on January 1, 1970 +0000. It's an extremely convenient way for computers to represent the time, since it's just an integer that goes up. There's no parsing to be done, and arithmetic is just regular math. If you want a brain-numbingly-detailed overview, Wikipedia's article on unix time is, as usual, sufficient.

However, what I'd like to talk about here is converting back and forth between unix time and meatware time. I imagine that when your beard gets long and grey enough, you are actually able to think in unix timestamps. However, for those of us who have not yet reached that level, there's the traditional unix command date. (Forewarning: some of the examples I will give here may only be applicable for the date that is part of GNU Coreutils. Mea culpa.)

The simplest thing you might want to do is find out what the current time is as a unix timestamp:

% date '+%s'
1299476266

As you can see, we haven't run out of 32-bit integer space yet.

However, what about going the other way? Sure, you could write a C/perl/python/etc. program that uses some variant on `ctime(time(NULL))`, but that's cheating. There must be a builtin? Maybe something that's not really documented? Lo, there is!

% date -d @1299476266
Sun Mar  6 21:37:46 PST 2011

It's not in the man or info pages, but there it is. The trusty @-sign solves your problem.

Cheers!

sietchtabr reboot

I have a VM slice that I use to run DNS, a bzflag server, and a few other incidental things. This is what I see on it right now:

% uptime
12:05:13 up 450 days, 15:17,  5 users,  load average: 1.93, 1.35, 0.60

It's currently running Debian lenny, but I decided that I wanted to get with the times and upgrade it to squeeze. As expected the upgrade was fairly painless (took me a bit to figure out that booting by label was broken and I needed to boot by disk UUID), but it's kind of disheartening to see this:

% uptime
12:48:44 up 3 min,  1 user,  load average: 0.30, 0.27, 0.11

Linux Tip of the Day: SystemTap

The other day, one of my co-workers, Evan, presented an interesting problem to me. Every day, at some point, a file named ] gets created in his home directory. He assumes that it is being created by a script with a typo in it... somewhere. But how to find out? It's a hard thing to grep for.

My initial solution was to use inotify (which you might remember from a previous post) combined with libnotify to alert him if it happens while he was at his computer. It looked like the following:

$ inotifywait -t 0 --exclude='.*[^]]$' $HOME && notify-send "something just created ]"

This is an okay solution (especially in that it took almost no time to write), but it doesn't actually give any useful information unless you're sitting at the computer and can do some manual debugging (to try and find what processes are in cron for that time, maybe do an lsof). I could add those things to the script, but there's still enough of a race condition inherent in shell programming that it's unlikely they'd be successful. How to solve this problem?

Enter SystemTap. SystemTap is like Solaris's DTrace: a tool for monitoring and acting on events a the kernel level, without the added bulk of a debugger. Except SystemTap is cooler. It uses the really neat kprobes functionality to tap into the kernel (which I encourage any of you familiar with systems-level programming to read up on, because they're a lovely hack), it has a clean and typesafe compiled language, and it has a decent standard library.

Installation of SystemTap varies based on distribution, but it's described in pretty good detail on the SystemTap wiki. Generally, you install debugging symbols for your kernel and the userspace systemtap compiler and runtime. Once you have it installed, you can probably add yourself to a group in order to be able to run stap scripts, or just do it as root. Either way.

So, what did my solution look like in SystemTap? Behold:

probe syscall.open {
    if ((filename == "]") || (filename == "/home/evan/]")) printf("%s by %s (pid %d), parent %s (ppid %d)\n", filename, execname(), pid(), pexecname(), ppid())
}

Run that under stap and you get a nice summary of the what is creating the files. Straightforward, and without crippling overhead (just two strcmps per open call). Cool beans!

Of course, this is just the tip of what you can do with SystemTap. For example, Debian Developer/Mozilla Contributor Mike Hommey wrote up a good summary on tracking disk I/O with SystemTap. And SystemTap provides a good base of example scripts for your tracing pleasure.

Feel free to let me know if y'all find any other cool ways to use this technology.

A word on dreams

We use the terms "bad dream" and "nightmare" almost synonymously. I contend that this is a frightfully naïve perspective. When we wake from a nightmare, we shortly realize that the floor isn't made of spiders, that all of the clowns are safely at the circus. But a dream in which we are happy... ah! Such a dream can color the real world world a darker shade long after the dreamer has awoken. These are truly the bad dreams.

Firefox 4 and Vimperator 3

firefox

I've been using Google Chrome's dev channel for the past year or so as my primary browser, but between some questionable aesthetic decisions and Chrome's tendency to segfault every hour or so for the last few dev releases, I decided that it's time to give up on the faster browser in exchange for the usable browser. Toward that end, I'm going back to Firefox. I hear that Firefox 4 is the next cool thing, so I set it up on my work machine (4.0b10pre, if you're interested). And, of course, since I am both a die-hard vim user and a big fan of the keyboard, I've gone back to my old friend vimperator.

I had used vimperator with Firefox 4 briefly a couple of months ago, but found it to be most unsatisfactory. I am happy to report that they have resolved all of the concerns I had with the version 3 alphas, and it's now way better than 2.x was under Firefox 3. Of course, their Design Goals for v3 are really scary and seem like they'd neuter the project in the name of making it more “friendly”. Bu, for now, it's pretty awesome. That said, it's not perfect out of the box, so I've been working on a nice ~/.vimperatorrc. You can find the latest version at this dropbox URL, but I thought I'd post an annotated version inline as well.

set act=addons,downloads,extoptions,help,quickmark
set cpt=slt
set go=br
set hlsearch
set stal=2

autocmd LocationChange .* js modes.passAllKeys = /mail\.google\.com/.test(buffer.URL)
autocmd LocationChange mail\\.google\\.com :set editor="gvim -f -c 'set ft=mail'"

command! -nargs=? -description="Pin the given tab" pin javascript config.tabbrowser.pinTab(tabs.getTab(<args>))
command! -nargs=? -description="Unpin the given tab" unpin javascript config.tabbrowser.unpinTab(tabs.getTab(<args>))
nmap gp :pin
nmap gu :unpin

The first block sets up some useful parameters: it disables auto-focusing new tabs, it disables completion of local filenames (which is still dog-slow under Firefox 4), it disables the bulky, ugly toolbar, it turns on search highlighting, and it forces the tab-bar to always be shown.

The middle block ensures that I can still use keyboard shortcuts on Gmail, and that the file-type is set correctly when editing mail in an external editor from Gmail. Both of these lines are ganked from the Vimperator documentation.

The last block sets up commands to use the new “App Tab”s in Firefox 4. These behave like pinned tabs in Chrome, and I use them a lot.

By the way, if you anticipate working a lot on a ~/.vimperatorrc, you may find it useful to install the vim syntax file. It's a little out of date (doesn't have all of the Vimperator 3 configuration options), but it's better than nothing. To install it, drop the linked file into ~/.vim/syntax/ and add the following to your ~/.vimrc:

au BufRead,BufNewFile \.vimperatorrc set filetype=vimperator
au Syntax vimperator source $HOME/.vim/syntax/vimperator.vim

Cheers!

*nix Tip of the Day: Waiting in Scripts

Scripting is what makes Unix-like operating systems great. Every *nix, be it Linux, BSD, OS X, AIX, Solaris, or whatever other random distribution you can come up with, comes with a capable shell (or three) and a good set of basic utilities. Where a Windows administrator has to either fall to the horror that is Batch files, write code in a big, heavy programming language language, or submit to the terrible dominance of “management utilities”, a Unix system administrator has tons of the tools at his disposal to fix and automate things. I could talk about scripting forever (it is a substantial portion of my job), but today I'm just going to talk about one small facet: waiting for things to happen.

read more

What I Want: The Moonbat List

It's 11:39PM on the eve of the Great Tea Revolt. As I sit here, fresh off of my 12-hour shift at work, the national media is reporting headlines like G.O.P. Captures House and "Midterm Train Wreck"; the Republicans (particularly in their hard-right Tea Party libertarian wing) are winning this battle. And I thought to myself, "You know what the world needs? More amateur political commentary!" So here's my wingnut list, my moonbat list, my this-will-be-embarrassing-if-I-ever-run-for-office list. Here's what I wish the country, and the world could do. It's no more achievable than are the Randian dreams of a world without government where the poor die in gutters and the rich get richer (oh wait...), but, hey, one can dream.

Social Policy

I think I have a pretty straightforward idea for how basic social policies should work: if you're a legal adult, of legal sound mind, you can do whatever you want to yourself and with other consenting legal adults. Want to smoke random ganja? Sure, just don't do it where other people are picking up your second-hand smoke. Want to marry another man, woman, or hermaphrodite? Knock yourself out. Think that a painless death is preferable to months of pain at the hands of some obscure cancer? That's your call.

Government's job is to mediate the interactions between people, to bring us out of a Hobbesian state of nature, and to make our lives better.

  • EDUCATION! We live in a world where it is a legitimate and successful political strategy to portray your opponent as being too smart. We live in a world that actively thinks knowledge is bad. This points to a gaping error in our education system somewhere. My coworker, the inimitable Jeremy Latt has some pretty wild ideas about education. I'm not sure I agree with them, but I do know one thing. The first thirteen years of my education (which is to say, the thirteen years in the Fall River Public Schools) were wasted. I learned almost nothing compared to what I did in four years at Mudd. I was never challenged. I was herded like a sheep into classes that I slept in because of my unerring ability to parrot back what the teacher wanted to hear. And I was (and still am) one of the people who actually gave a flying fuck about learning, about weighty concepts like mathematics. The others? The ones who weren't being taught anything of value by the schools and who weren't motivated to learn on their own? I shudder to think of where this recession is finding them. But I suspect it's on the far end of a welfare cheque. What we have now does a lot of things, but what it doesn't do is work.
  • Privacy is a legitimate right. I understand that we need to balance security in interpersonal interactions with privacy. But the security theater of a TSA officer either feeling me up or looking at me naked isn't designed to make us safer, it's designed to get us used to the idea that we don't have any privacy in the face of the watchful eye. Cory Doctrow is about 800 times more libertarian than I am, but I still think all of you should go read his books. Even though it's just a "young adult" novel, I particularly enjoyed Little Brother.
  • Separation of church and state: also important. If you're an American, odds are that I disagree with you about religion. Although if you're an American reading my blog (hello all three of you), that is less likely to be true. But the fact of the matter is, I don't want you telling me what to believe, and you sure as hell don't want me telling you what to believe. Intelligent Creation isn't a scientific theory, it's religious propaganda. And, no, Texas and Kentucky, I also don't want you spending tax dollars and public land to put up a giant status to the decalogue. Unless you're going to put up every other religious and political document that's affected your judicial history. No? Then no. Also, I don't care if your religion says gay people are bad (even though it's quite hard to point to such a clause in the Bible). My philosophy says that believing something because a guy in a big hat tells you to is bad. Let's agree to not enforce either of our moralities on one another, mmmmkay?
  • There are tons of race and gender relations issues in our society. As an upper-middle-class straight white male, I'm just going to get shot down if I pretend that I can speak eloquently about them. But they're there. I think they're probably getting better; I don't think I've ever seen anybody in my generation obviously discriminating against somebody for their skin color, and growing up it was in fact expected that women would be smarter and earn more than men. Which made it odd when I got to Mudd and was told that women were discriminated against in STEM fields. Never would have guessed that when all of the honors and higher classes in high school were 60-70% women... Anyhow, none of this fixes things, mind you, but I can't imagine that it's a bad sign.
  • Corporations are not people. One more time: corporations are not people. Citizens United is the worst court ruling of the decade. Corporations are NOT people!

Politics

  • Political parties bother me. The world doesn't dichotomize into two camps where all of the people in Camp D feel the same way about all issues and all the people in Camp R feel the exact opposite about all issues. Partisanship and party loyalty makes actual progress in the direction desired by the sovereign (i.e., the people) impossible. On the other hand, without parties, the next issue would be even worse.
  • Elections are meaningless. People vote for a party, on the basis of months of fantastically-expensive mud-slinging televised lies. Is there a way to manage campaigns such that a relative unknown can still run for national office and also such that the person with the most expensive, most slanderous campaign doesn't win? I don't know. Is there a way to get candidates to reveal their true beliefs on issues instead of bickering about who slept with who? I really hope so.
  • Legislation should be simple. We should invent a time machine, go back to find the first person who thought of adding an unrelated rider to a critical budget bill, and shoot him in the face. I've read through a few congressional bills in the last few weeks (for personal entertainment), and they're behemoths. If I can't get through it, then how is a senator who was elected on a platform of being anti-intellectual and has to be on the campaign trail 23 hours a day supposed to read it?
  • Corporations are bloody not people!

Environmental Policy

I don't think I can say anything here that won't embarrass me in front of my much more knowledgable friends, but suffice to say that this is an issue that affects the whole world. In my magical pretend perfect world, it would be addressed by the whole world. Here's a real wingnut idea on this, though: require 100% carbon offset for all personally-owned vehicles. Cars are annoying anyway.

Fiscal Policy

This one's trickier. On the one hand, I do agree with the conservatives on some points. A deficit isn't really that good of a thing. Yes, government certainly should run a deficit during a recession to compensate for the fact that markets are not people, and just because the market clears doesn't ensure anything about the suffering of individuals. But I also think that the way our economy works right now is we have a lot of debt (which isn't money) acting like money everywhere. At the federal level, at the state level, and (in much larger quantities) in the private sector. If the financial sector is making a profit, that's a good sign that your economy is in trouble. If the financial sector is making more profits than the rest of the economy, then your economy is just plain broken. The only job of a financial professional is to take things that aren't money and aren't economically productive and turn them into money for people who already have money. As a side effect, they sometimes do good things. Sometimes. After that rambling prelude:

  • Consolidate duplicate state and federal agencies. I couldn't care less about states' rights, to tell you the truth. I've heard plenty of arguments for it, but our confederacy of states is just plain weird.
  • Establish a single-payer healthcare system. The goal of a corporation (like, say, your insurance company) is to make money. The goal of a healthcare system is to produce healthy people. These goals are fundamentally at odds with each other. Yes, blah blah competition blah blah expensive services. I don't care about those things. Your insurance company is out to make money. The way for it to do that is to charge as much as the market will bear and provide as little as the market will bear. Health doesn't work that way.
  • Maintain a simple, minimal social safety net. I don't believe that we as a people should be left to founder when we falter the way that Ayn would. But I also acknowledge that there are people who abuse our current welfare system, and that shouldn't be possible. We should develop some kind of technology that's good at aggregating information and determining aberrant patterns. And any safety net should, of course, encourage people to work. Which should be easier given the next point.
  • Affirm and maintain public infrastructure. I'm not advocating public ownership of all means of production, but the infrastructure that they run on? The roads, the fiber lines, the sewers? Those should be public, and should be cared for the way we care for our investment bankers.
  • Fair, simple taxes. Capital gains should be taxed the same as income, and income taxes should rise roughly logarithmically with income, maxing out somewhere around 50%. Estate taxes should match or exceed income taxes. One national sales tax. No state or local taxes.
  • People complain a lot about "income redistribution". Surprisingly, a lot of these people are normal people. I don't know why they do so, but they should look at history a bit. The income gap in this country is stunning1. And I'm not part of the solution. I get paid an ungodly amount of money to sit on my ass and press buttons all day. Then I give most of it back for a medium-small apartment in an only okay neighborhood. But, still. At what point did we as a society decide that we should give all of our money to the people who need it least? Was anybody whose last name wasn't Reagan involved in this decision?
  • Reduce our prison population. With the legalization of personal drugs and the improvements to education and employment in my magical mystery universe, this shouldn't be too hard. But it's worth mentioning that we spent $68 billion on prisons in 2006 2 and jailed 2.259 million people 3. That's only $30,101 a year per prisoner. Of course, the median income per household member in this country in 2006 was only $26,036 4. So you're worth $4,000 more to the country if you've been convicted of a crime and are doing nothing productive. That's a good use of our human capital!

Foreign Policy

  • Roll back the defense budget to what it was before World War II (adjusted for inflation, of course). The defense budget in 2009 was $661 billion. The defense budget in 1940 (during a war, mind you) was $1.6 billion5. Adjusting for inflation (with CPI as my index), that's $25.4 billion. That's a 26 times increase so we could lose several wars and fight insurgents armed with $50 IEDs in countries that we are bloody occupying. They're going to make a movie about this period in American history in 100 years, and I don't think we're going to be the plucky heroes.
  • Immediately withdraw US combat troops from all foreign wars. Democracy and liberalism can't be forced on a society; it only makes sense to give sovereignty to the citizenry if they want it. Don't get me wrong, I think that a democratic socialist republic is probably the ideal form of government for me (and, make no mistake, our government is and has been socialist in many of its dealings for a long time), but it's not my place to tell others how to live
  • Withdraw the majority of our foreign military aid. We gave Israel, one of the stronger nations in the world, $2.5 billion of military aid in 20096. Not only are we increasing the violence in the world (particularly, the weaponry in the hands of a fairly radical effective-theocracy), but we're doing it by giving away money during a recession. Madness!
  • Speaking of Israel, I am always amused (and saddend) by our irrational support of that country. Any other nuclear-armed theocracy that's occupying a foreign country (well, any one except ourselves) would probably have already been targeted as a member of an axis of evil. Israel gets bonus cookies, for some reason. I understand that Palestine hasn't exactly been a picture child, either, but I think it's time for us to ask them to grow up or stop giving them both cookies. By which I mean U.N. sanctions should be sought. Or we could stop exporting Mrs. Fields. Either way.

So, that's a list of a few of my crazy political leanings. Feel free to comment below, or not, as you wish. If you read this far, congratulations, you have too much time on your hands. Maybe I'll actually get around to that git post next week. And remember: corporations are not people!

Github

Brief post. I decided to actually use Github once in a while now (not in the least because I use it for open-source stuff at work). My page is up at github.com/Roguelazer, and the work account which I'm a contributor on is at github.com/Yelp. So, uh, feel free to comment on or improve any code that you see thereabouts.

Also, I am thinking about doing a series on git on this blog, since I get to use it rather quite a lot now, and there definitely aren't enough guides to it on the Internet yet. Yes, that last was sarcasm. I'll let you know.