2008-02-26

Death by tune2fs

Suppose you want to shrink your root filesystem a bit, to make up some space for World of Warcraft in that old Windows partition. You fire up a rescue disk, and parted complains about “unsupported feature”. It doesn’t say which feature though, so you google around and try to tune2fs -O ^dir_index the partition. parted is still not satisfied, so you say what the hell, I’ll just turn off everything, resize, and then turn’em on back again. Can’t do no harm, right?

Then you clear sparse_super and tune2fs warns you to run e2fsck. At this point, since you’re eager to see what your Female Human Mage alter ego will loook like, you might think you can save some time by turning off filetype too, and then fscking just once. Don’t do that. I mean, don’t be stupid. What kind of moron would ignore that warning when dealing with his primary, most important filesystem with all your cherised data in it?

/me lost everything

2008-02-23

Trouble using utf-8 with ncurses?

Disclaimer: these are experimental results and I’m not too sure about what’s going on.

First of all, link to -lncursesw instead of -lncurses (from packages libncursesw5{,-dev} on Debian/Ubuntu).

I assume your source files are in utf-8. This will not work:

(more…)

Creating ringtones for the Blackberry 8700 under Linux

So I decided to put a few of my favorite game soundtrack tunes into my Crackberry. My first attempt was naïve: knowing that the thing supports mp3 files, I just uploaded a couple files to an web server and downloaded one with the handheld. It played okay, but went “Unable to save file” when I tried to save.

I search around and found something about “AMR files”, so I installed libamr and libamrwb and fiddled with ffmpeg until I could massage some files into the format. It’s a voice codec so it sounded like crap, but what the hell, as long as it works, right? Only it didn’t. Blackberry didn’t even recognized the .amr as music.

Back to mp3 files. My guess was that the “informative” error message when saving had to do with space; and indeed Google seems to think there’s a limit of 300KB (or 300KiB?) for sound files. I recoded the beginning of a few tunes to a low bitrate extract with a command like this:

ffmpeg -fs 300000 -ab 32 -i <fullfile>.mp3 <ringtone.mp3> # or -ab 48, etc.

Then I edited the ringtone with audacity to create a fading effect at the end (anyone knows whether it’s possible to do it directly through ffmpeg?). You have to be careful ’cause audacity doesn’t preserve the bitrate when exporting, and you need to set it low manually. The resulting extracts downloaded, played and saved in the BB, though they’re too short and still sound bad. Yipee.

Useful bash tricks: learning from history

Have you ever tried to do something like this?

# echo "eat flaming death!" > /etc/motd
bash: !": event not found

And then Ctrl+P (or Esc k) doesn’t show the offending line again. Many of my friends are frustrated by this seemingly magic behavior of ‘!’, but never bothered to learn about it. If you read info bash, you’ll see that it’s for history substitution: tokens beginning with a bang are expanded to certain parts of command history. There are like four dozens of history expansion designators and most don’t seem useful enough to memorize, which is why so many people choose to ignore history substitution altogether. I use a few of them frequently, however, so I’m listing my top three here for your reading pleasure:

(more…)

Edimax EW-7318USg / Ralink rt73usb on Debian

So I got an Ralink-based EW-7318USg wifi USB card ’cause people said it had an native free software driver, supported monitor mode, and maybe even master (AP) mode. It should work out of the box, right? Well it didn’t, either in Debian or Ubuntu. I also couldn’t get the manufacturer’s driver nor rt2×00 CVS to compile.

My error was forgetting to check syslog (or making sure syslog writes to my pseudo-tty). Debian sid running kernel 2.6.24 found the rt73usb module just fine and created the network device as wlan1, but failed to ifconfig it up; this is what syslog said when I tried:

oni kernel: phy0 -> rt2x00lib_request_firmware: Error - Failed to request Firmware.

Sounds like I’m missing a binary blob, right? And sure enough, the (outdated) official driver included an rt73.bin file. I copied it to /lib/firmware, and finally my card worked (though not as master).

Update: I managed to compile rt2×00 cloning their whole freaking kernel tree from git. Still no mode master, though.

2008-02-20

A small manifesto for simplicity on the Web

When writing Web services, know HTTP and be RESTful.

When writing Web pages, do not use:

  • Java applets,
  • Flash/SVG,
  • AJAX,
  • Javascript,
  • Images

…unless it’s necessary. In that case, prefer the technologies closer to the bottom of the list. Never use any of those technologies to reinvent the HTML user interface.

Follow web standards as far as it’s reasonable. If you haven’t read the standards you shouldn’t be a web designer.

If your site is simple, it will be much easier to make it:

  • Compatible with different user-agents, including future and mobile browsers.
  • Standards compliant.
  • Acessible to people with impairments.

Simplicity will save bandwidth, improve latency, and reduce rendering time.

Simplicity is the best search engine optimization. Be nice to robots.

Simplicity is beautiful. Avoid visual pollution.

KISS.

A very small shell script


#!/bin/bash
file=$HOME/Desktop/sounds/zenbell.mp3
interval="30 min"
player=/usr/bin/mplayer

function usage()
{
    echo "Usage: $0 [OPTIONS]
Options:
 -f FILE:     play FILE (default: $file)
 -i INTERVAL: wait this much, in at(1) format (default: $interval)
 -p PLAYER:   use PLAYER (default: $player)"
    exit 1
}

while getopts "f:i:p:h" opt; do
    case $opt in
        f) file="$OPTARG";;
        i) interval="$OPTARG";;
        p) player="$OPTARG";;
        *) usage;;
    esac
done

sleep 100 # time to get away from the computer and sit
("$player" "$file"; "$player" "$file"; "$player" "$file") >&- &
at now + "$interval" <<EOF
"$player" "$file" >&-
EOF

Gmail has some pretty powerful keyboard shortcuts

picture of gmail keyboard shortcut list, with emphasis added to typoed entry ‘more action’

That’s exactly what I needed for my life: a “more action” key. I’ll start using it right away!

Como arrumar o canal de modulação na net digitalizada

(It’s the second day of the blog and I’m already breaking the self-imposed rule of writing in English only, as this stuff is only interesting to Brazilians. Sorry.)

Eu tenho um receptor de TV a cabo digital da Net (plano “digitalizado”) num televisor véio pra caramba. Mudei o canal de modulação de 3 pra 4 no menu, perdi a imagem e não pude desfazer a alteração. A título de referência, segue a seqüência exata de teclas para restaurar o canal 3 às cegas:

  1. Liga, menu
  2. baixo, baixo, OK
  3. baixo, baixo, OK
  4. baixo, baixo, baixo, 0, 3

Neste ponto a imagem volta e você pode terminar sozinho. Kudos ao ehabkost por me ajudar a arrumar minha tevê pra eu poder voltar a assistir For Ma^W^W Discovery.

P.S.: Mudar essa configuração é um bom trote para desafetos :p

2008-02-19

Dealing with mailing lists on gmail: * u m and saved searches

In the spirit of eating our own dogfood, I’m learning to use gmail for heavy handling of mailing lists. It isn’t as automateable as mutt or wanderlust, but if you dig around it has some neat features.

One of them is keyboard shortcuts. Once activated in the Settings screen, press ‘?’ to see a short help. Some shortcuts worth learning are ‘y’ (“take this thread out of my face”) and ‘m’ (mute, or “take this thread out of my face and keep it there forever, unless someone actually messages me personally”). Mute is absolutely the most important command evar and you should learn it now.

  • FUN FACT: mute was internally called “murder” by Googlers. Totally true!

Here’s my algorithm for early morning mail reading:

  1. Find all interesting mail and read it. Labels help here, as does the little arrows from the “Show indicators” option (they identify which mail is sent directly to you).
  2. Do “* u” to select all remaining unread threads.
  3. Do “m” to mass murder them.

This magic incantation, “* u m”, has saved me from much information overload.

[From my Google blog, 2008-01-18]

New: Gmail labs now finally offer saved searches! They’re kind of hidden in the “quick links” feature, but with this gmail is finally usable enough for me to not miss mutt.

Here are a few saved searches I use often with the above “* u m” technique:

  • in:inbox is:unread (to:me OR cc:me): the same stuff from “show indicators”. Easier than visually scanning for the little arrows, like people commented in this post.
  • in:inbox is:unread (label:ML1 OR label:ML2 OR …), where ML1–N are mailing lists I’m not very interested in: Mailing lists I don’t care about go straight to archive, but there are those I kind of care but not too much. I want to see them in the unread mail count, but they pollute the inbox too much. I call this search “mass murder targets”; it isolates messages I’m very likely to mass murder.
  • in:inbox is:unread: The plain version is useful if you like to keep important read messages in inbox. Sometimes unread messages get lost in the past.

Big screen for weird characters

I finally found out what to do with the giant monitors.

Anyone who studies Japanese must have had the brilliant idea of turning their desktop to Japanese, in order to help training. If you do this, you quickly find out it’s easier to remember the position of buttons and menu entries than to look up the reading of each and every character.

But these days we have help. Tools like edict-el for emacs and rikaichan for firefox make it very simple to peek unknown characters in Japanese dictionaries. Rikaichan in particular is extremely convenient, and since so much modern work happen inside web apps, its power is extended quite a lot.

Problem is, all those little wiggly characters make me dizzy. Giant man-eating monitors to the rescue! I now set my fonts to unreasonably large point sizes, and use all this extra space to make kanji readable. Real men need no more than 80×30 anyway.

It still has some problems. Some so-called web designers still make fixed layouts, and the big characters get all cramped in a corner while 75% of the screen remain blank (cough Blogger cough). The default monospace font for Japanese is unreadable for Western scripts, so I changed it to Courier to make textareas usable. Something is causing a lot of lag in keyboard reaction time. Etc. But, annoyances aside, I think I can train some Japanese while work, without affecting productivity… too much.

[From my Google blog, 2008-01-15]

The existential pleasures of engineering

(Or: why I’m working at Google, part LXIV)

EDWARD: I’m in love, Chief.
SIR HENRY: So was I, once, but I shut myself up for a week, and worked at an air-machine. Grew so excited I forgot the girl. You try.

Another interesting quote from the book:

The engineer already knows a lot about restraint and cooperation. He is logical, sober, and well-meaning, a very good citizen. I submit that the study of the liberal arts will rob him of his innocence, stain his character, make him less “moral” — or, at least, less naïve. And this is exactly what the engineer needs.

[From my Google blog, 2008-01-14]

Disabling that annoying green light in the blackberry

Since I won’t have an Internet connection at home until I have, well, a home, I’ve been playing with the Crackberry a lot. I was quite impressed when I asked one through the relevant web service in the morning and got it in the afternoon.

Now the Crackberry 8700 has a bright LED right above the screen. When you have new messages, it flashes red; when the battery’s low, “amber” (looks like yellow to me); and when you make a Bluetooth connection, (you guessed it) blue. Someone also had the amazingly braindead idea of making it flash green when you have a network connection, which is, like, always. You’re forced to hide the damn thing with a sock or something when you go to bed, but the light is most annoying when you’re actually trying to use the device and it keeps flashing in your face.

I was ready to cover it with duct tape, but luckily I googled for a solution before; since it was a bother to find it, I’m writing it down here for the benefit of my fellow nooglers. Just go to Settings → Screen/Keyboard → LED Coverage Indicator → Change Option → Off → Save. This is a good example of what the Gnome developers call a “fix my application option”; an option that shouldn’t even exist.

[From my Google blog, 2008-01-11]

On eagerness

It’s my fourth day at Google, and I don’t remember ever having worked this much — willingly. Am I being tricked? Is Google Mind Control Ray in beta? Is there kool-aid in the water?

Is this what actually being motivated feels like?

[From my Google blog, 2008-01-10]

No ‘p’ in Blogger

I can’t believe Blogger has auto-generation of <br /> tags, but not <p> tags. What is this, 1997? I feel dirty for using subpar HTML elements. This blogger thing really could use some Markdown.

[From my Google blog, 2008-01-08]

Monitor woes

Google monitors are so big, I feel like they’re going to eat me.

I was a ratpoison user. I don’t use it anymore, but I got into the habit of maximizing everything; never before I had used a monitor so big that a maximized firefox window is actually a bad thing. I had to change the local branch of my devilspie conffiles.

At the end of the day I found a way to live with the monitor peacefully: instead of maximizing firefox, I make it occupy half of the screen. But now I don’t know what to do with the other half.

[From my Google blog, 2008-01-08]

Next Page »