Avoding "Invalid byte sequence in UTF-8" with Ruby and CSV files

If you’re running into a ton of problems reading e.g. an ISO-8859-1 encoded CSV file into your (probably UTF-8) Ruby or Rails application, and if the error you get is “Invalid byte sequence in UTF-8” even though you’re giving CSV.open the correct encoding options, here’s a solution. The example CSV file is a tab-separated, ISO-8859-1 encoded file with CRLF line endings. You’d expect the following to work: But it fails mysteriously! Even though the conversion to UTF-8 goes without problems, you get an ArgumentError complaining about some illegal byte sequence. If you analyze deeper, you might find (in this case) a complaint about rn. The solution is very, very non-obvious: You need to specify the row separator in addition to your encodings! ...

September 8, 2011 · Psy-Q

Watch TV on your PC, no ads, no Flash

Roman Haefeli strikes again: Watchteleboy makes it possible to watch dozens of live TV channels using mplayer in your very own machine, without the need for Flash, a web browser or any other such nonsense. Here’s the source code: https://github.com/reduzent/watchteleboy Here are Ubuntu packages he maintains: https://launchpad.net/~reduzierer/+archive/reduzent Caveat: This only works if you’re located in Switzerland or in some other place that Teleboy’s geotargetting likes (such as Italy).

September 7, 2011 · Psy-Q

Vegan Black Metal Chef, Ep. 1

Give this a look: http://www.boingboing.net/2011/05/12/vegan-black-metal-ch.html Thanks, lix! 🙂

May 20, 2011 · Psy-Q

Moving from Google Reader to Tiny Tiny RSS

In my quest for more freedom from companies that don’t take privacy too seriously (such as Facebook or Google), I found a fantastic FOSS replacement for Google Reader: Tiny Tiny RSS. It does everything important that Google Reader does and even has its own little syncable native Android app called ttrss reader (available through the Google Android Market). The only additional feature I’d appreciate is a Reader Play-style view for very important tasks, such as scrolling through large amounts of animated gifs or lolcats quickly. Tiny Tiny RSS’s code seems to be clean and concise, though, so it might not be that much work to make such a feature if I ever find the time (which won’t happen). ...

November 10, 2010 · Psy-Q

Why is Switzerland/Norway so rich/expensive/not part of the EU?

This is a great Google Suggest Venn diagram generator: http://www.technomancy.org/google-suggest-venn. Only a fool would suggest that not being part of the EU makes a country rich and expensive 😛

October 27, 2010 · Psy-Q

Good quality music from your PC, Mac or NAS: Music Streamer

Most PCs come with onboard audio circuits that, at best, sound OK. But there’s a cheap way out of that. The Music Streamer by High Resolution Technologies. It’s an external USB sound interface with a very good D/A converter. This is a semi-audiophile device, yet it costs only about the same as your average USB audio interface these days. This isn’t made for 5.1 surround sound, it only has two analog RCA (Cinch) outputs to hook up to your amp. Of course you can also play games in stereo on it and watch films. Both sounds crystal clear. ...

August 16, 2010 · Psy-Q

Sidegrading from Ubuntu 9.10 to Debian squeeze: It's a breeze

Since I’m switching many machines from Ubuntu to Debian, I was wondering if I could just keep my home partition intact and simply install Debian “over” Ubuntu, or if that would cause major problems with application configuration files etc. Here’s the good news: It’s absolutely no problem to sidegrade from Ubuntu 9.10 to Debian squeeze (testing). I chose to keep the /home partition unformatted in the installer, but formatted the / partition. When the system rebooted, I logged in and my entire desktop looked exactly the same as under Ubuntu. Even my GNOME settings were intact, down to the desktop background. ...

April 20, 2010 · Psy-Q

How to decrypt an Adobe DRM-crippled ePub eBook file

I used to have a mirror of all sorts of decryption tools here, but the legal situation has improved over the last few years so that this is no longer necessary. Instead, I am happy to refer you to Apprentice Alf’s blog with his decryption tools.

March 7, 2010 · Psy-Q

Nitpicking: KDE vs. Windows 7 window controls

I’m using Windows 7 a bit more regularly for gaming purposes now, so I thought I’d start on a series of articles about Win 7 vs. KDE. I’ve given up on GNOME until 3.0 rolls around, but once that’s out, I can do three-way comparisons 🙂 Today I’d like to nitpick on something. Observe the following screenshot from the top right corner of a KDE 4.3 window using the default theme: ...

October 12, 2009 · Psy-Q

A week with KDE 4.3

I’ve been using the new KDE 4.3 for a week now, and I think I’ll stick with it. There are still some issues to fix, but they are small things, I’m sure 4.3.1 will take care of them. The fun I’ve had so far, and this is why I’d recommend trying KDE 4.3 to any computer user, is in the subtle little helpful things KDE does: When you move a file to a folder that already contains that file, Dolphin (the file manager) will ask what to do with it. It even recognizes the file if they have different names! You can choose to skip, auto-skip, overwrite… No more manually trying to find duplicate files to interleave one directory with another. In Dolphin, clicking on the filesystem path shown on top of your file list lets you edit it and manually enter paths. Very quick. The widgets on the desktop are both silly and useful, depending on which ones you choose. I have the latest lolcats, Penny Arcade, XKCD and Nichtlustig comics on my desktop. But I also have a dictionary widget, the weather, a fuzzy clock (says “half past eleven” in so many words) and the files in my homedir. I can also add the files from my former desktop directory, and they show up in orderly fashion. Compare this to your average desktop, where there’s just clutter and no real useful features. In the worst case, I can glance at the weather and some lolcats. In the best case, I’ll quickly navigate to a file I was looking for. Dolphin as file manager is amazing. I can have OS X-style columns in the window, then split the window and have your usual detail view on the right half. I can mix and match view modes as I please and use the one that’s best for each situation. When navigating the hierarchy a lot, column view might be good, but when sorting audio files from left to right it’s better with a side-by-side detail view. Alt-F2 (this is freely configurable) brings up a quickstart dialog that is really powerful. If I enter “fire” and hit enter, firefox will launch. If I enter “22+3=” the bottom of the window will show “25”. If I enter “Ruben” and some Rubens are in my address book, one of the choices will be “Write e-mail to Ruben”. If I enter “gmail”, my Gmail opens because I visited that site in my browser once before. This is all done 100% automatically and transparently, without any configuration. I’m sure if I configured this thing, it would be even cooler. Very, very, very fast working is possible this way. Kate is a wonderful text editor, it has probably the most beautiful code folding I’ve ever seen. Choqok and other social networking tools integrate nicely with the desktop and also make use of the cool notification feature. If your machine is doing something in the background (copying a bunch of files), your screen isn’t cluttered up with useless progress dialogs. Instead, all current tasks are summarized in the lower right corner in your notification area. Once the task is finished, you will be notified. If you want to look at the progress, hover your mouse over the notification area. I have OS X’s Exposé and other window management features at my disposal, but I don’t need to use OS X for them 😛 The kickoff menu in the lower left is very convenient as well. I think you can see that I’m very happy with KDE 4.3. If some of the issues (like the WLAN network manager that can’t connect to corporate WPA2-TKIP networks) are fixed, I see no reason not to recommend this stuff. ...

August 22, 2009 · Psy-Q