Archive for the 'tips' Category

Instant Storage 1

Here’s one of my favorite PHP ‘hacks’: when I’m whipping up a quick script that needs a place to stash some persistent data, but don’t feel like coming up with a database structure, or doing anything remotely approaching a real solution, I instead stuff it into a “static” session. By static, I just mean that I set the session ID to a static value, so I’m always pulling the same session. Instant data store.

$_SESSION['stuff'] = $w00tz;

(Another quick and dirty approach would be serializing an array into a local file… oh, wait, I just recreated the default PHP session handler. ;))

Tango Color Scheme for XFCE Terminal 23

At work I run XFCE; at home I run Ubuntu. Yesterday I noticed that the default Ubuntu color scheme for Gnome Terminal was really nice — called the “Tango” palette — and wished I could have the same at work. I already run the Tango icon theme, so it’d fit in nicely.

Turns out, the default XFCE terminal supports color schemes, too; I just had to stuff the correct color values in. I searched around a little bit, but couldn’t find anyone’s config to steal, so I copied and pasted the values in — one by one. To save you the same pain, open up ~/.config/Terminal/terminalrc, find the lines that all start with Color, and replace them with:


Save the file, and revel in your new colors!

Tango Color Theme for XFCE Terminal

RTFGoogle 2

Let’s face it, every now and then certain people need to be reminded that Google still exists, and that it can still be used to find the answers to the simple, often stupid questions they’re asking. I mean, half of the time the answers are in the first page of results. It’s not rocket science.

Enter Let Me Google That For You. Perhaps slightly harsh, it’s a wakeup call for those pestering you. Brilliant.

Sansa C200, Linux, and Rockbox 0

A few weeks ago, I purchased a refurbished Sansa C2xx series MP3 player. It’s a small, 1GB “gumstick” player with a microSD slot and supports Rockbox, an alternative, open-source firmware. When running Rockbox, it’s rumored to support MicroSDHC, giving it a total capacity of (currently) ~17GB. In addition, it seemed to support both Windows and Linux pretty well, making it a good fit for someone who, like me, jumps between both.

For the most part, things work pretty well. Up until tonight I’d been running the default firmware, when I tried to install Rockbox. Here’s a collection of my experiences with the player.

  • In the default firmware, the volume level is not saved when the device powers off. I use a set of earbuds that seal very well to my ears: a little volume goes a long way. Whenever I turn the player on, I have to immediately crank the volume down. I’ve heard that Rockbox will fix this.
  • When resuming a previous playback position, forward/back functionality works inconsistently from how it works at all other times. If you resume partway through a song and press back, you expect it to rewind to the beginning. Instead, it skips to a random song. If you then press forward, you skip to another random song — not back to the song you were listening to.
  • It’s a hybrid MTP and MSC device (in that order), picking whichever is supported by your operating system. On Windows you’re most likely stuck with MTP, while unless you specifically install MTP software on Linux, you’ll be given MSC. Unfortunately, the files you can see in MTP mode are not visible in MSC mode, and vice versa — and there’s no way to choose one mode or the other. In practice, that means there’s a big wall between your Windows and Linux music (until playing it).
  • Linux apparently doesn’t play with the FAT(32) partition nicely enough to use it as a disk — I could not get the songs I copied onto the device via Linux to show up in the player’s database. In addition, just trying to use the device routinely caused file-system panics (to be honest, I didn’t even know they existed) which took down my whole box. I was also unable to get Rockbox installed via my Linux box.
  • I experimented with MTP support in Rythmbox (granted, very quickly), and couldn’t see everything I’d loaded onto it (complained about a codec..?). I didn’t try adding new files.
  • Given the problems I had getting files loaded from Linux into the database under the default firmware, Rockbox seems to be the way to go, as it supports browsing the actual file system for music.
  • I finally installed Rockbox via an older XP install (which saw it as an MSC device), and confirmed that it did recognize a 4GB MicroSDHC card. But the default firmware always handles USB communication, so you have to copy things onto SDHC cards externally.
  • None of the SD readers in my house support SDHC, again leaving me without a way to load music from Linux.

So, while I like the player overall, it hasn’t proved as Linux friendly as I’d like. Once I get an SD reader that supports SDHC, things should improve markedly.

Binning it 0

Most of you are probably familiar with pastebin, officially, it’s a “collaborative debugging tool,” unofficially, it’s a place to temporarily stick random blobs of text for other people to look at.

We’ve set up our own instance of pastebin in the office, and I often found myself wanting to paste files on my system, or the output of commands (like svn diff). After getting sick of literally (copying and) pasting stuff into the text box, I whipped up a command line script that takes its input from a file or STDIN. Sure, these probably already exist, but who cares.

Aptly, it’s hosted at pastebin.

Digital Cloaks 0

Not too long ago, Matt talked a bit about p0f and it’s ability to distinguish your operating system based on the packets its sending.

Today, Hack a Day highlighted a project that can help you overcome some of the fingerprinting in p0f (and other tools, like nmap) by emulating the characteristics of other OSs.

Tunnel to the World 0

A lot of people know that OpenSSH’s client supports tunneling out of the box. But some don’t realize that it also supports tunneled SOCKS out of the box. Here’s how to set up a quick SOCKS proxy across an encrypted tunnel:

ssh -NfD 8888 user@host

The proxy will be on port 8888. The other flags just tell ssh to go immediately to the background (after getting your password, if needed) without running a command.

Across an Instance 0

Here’s the quick PHP tip of the day: class methods can access the protected (of any shared ancestors) and private (of the same type) members of any instance, not only their own instance. That may sound confusing, but it’s really not so much.

Read more »

The PDT (Or: I Don’t Like Zend) 1

My animosity towards Zend has really increased lately, due to a number of factors (the recent ZendCon, their character when dealing with open-source projects, etc.), so much so that I’ve sworn off Zend products. Which doesn’t really sound like a difficult task at first glance, since I only use one Zend product — but that one product just happens to be one of the only good PHP IDEs out there: Zend Studio.

Fortunately (and if you follow the PHP world, you’ve probably heard about this), Studio is receiving competent competition in the open-source world from the Eclipse platform in the guise of the PHP Developer Tools, or PDT. (And that’s competition in a very liberal sense of the word, since Zend is actually backing PDT — so they can rip it of– base future versions of Zend Studio on it.)

Anyways, the real goal here was just to talk about a quick PDT tip (now that I’ve switched), not rant and rave about how Zend seems to have a knack for positioning themselves in the middle of hugely conflicting interests.

The tip: Most people know that you can Ctrl+Click “into” a function call. What I didn’t know is that you can also Ctrl+Hover to get a tooltip containing the first ~10 lines of the function.


This can be immensely useful when you’re just trying to figure out what a piece of code does, without completely losing your train of thought and switching contexts.