Quantcast

Wonderfully funnily 2

Can this be real? I have a feeling that something’s being translated or rewritten with liberal use of a thesaurus. But I don’t get the point — there aren’t any ads that I can see, so it’s not just filler to bump up search rankings and get clicks. Weird.

I Have Cupcake 2

After saying it was coming, then delaying it, then people claiming to have gotten it, then those claims being debunked, then some people installing the UK version, TMobile has apparently finally begun shipping the Android 1.5 “Cupcake” update to US G1 owners.

This afternoon, I downloaded and installed the update by hand, a process that took maybe 5 minutes (tops). The instructions claim that there’s a risk of causing damage to your phone (bricking it, most likely); I followed them verbatim and didn’t have any issues.

So far, it’s really good. I doubt I could live without the hardware keyboard, but I was also really annoyed that I had to open the phone to be able to type even the simplest “ok”. The soft-keyboard completely solves that, and while I’m still in the process of calibrating my fingers, it’s worked well enough so far. The suggestions seemed accurate and have already saved me some pecking time.

Other than that, there seem to be a lot of spit and polish updates, and a few new features. The T-Mobile forums have a full list of changes. Since I have iPhone envy, I immediately turned on the screen transitions. I also played briefly with the video recorder, and also just made sure that I can play music through my Bluetooth headphones. I also turned on the auto-rotations, but I’m not sure I’ll keep them.

In short, if you have a G1, I’d say you check out the update now — don’t wait! (But, then, I’m impatient.)

When Objects Aren’t 0

When unserializing an object whose class definition is not present, PHP returns an instance of the special type, __PHP_Incomplete_Class, which issues notices if you attempt to call a method or access a property.

For example, this code produces the following:

andrew@fake:~$ php incomplete.php
object(__PHP_Incomplete_Class)#1 (2) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(4) "test"
  ["name"]=>
  string(2) "hi"
}

Notice: main(): The script tried to execute a method or access a property of an
incomplete object. Please ensure that the class definition "test" of the object you
are trying to operate on was loaded _before_ unserialize() gets called or provide
a __autoload() function to load the class definition  in /home/andrew/test2.php
on line 7
NULL

Interestingly, the is_object method returns false when given an instance of __PHP_Incomplete_Class. This seems to be in contradiction with var_dump (as evidenced above), gettype, and get_class, all of which return values indicating that the incomplete class is a normal object.

This was reported as bug 19842 way back in 2002, but didn’t seem to be considered a problem. (The suggested solution was simply to have all class definitions present before unserializing that object.)

To be fair, this behavior of is_object is documented in the notes section of its manual page. It also appears to be intentional, judging from this section in ext/standard/type.c, determining whether a variable is an object:

   220                          if (!strcmp(ce->name, INCOMPLETE_CLASS)) {
   221                                  RETURN_FALSE;
   222                          }

That said, it’s a little confusing when you first run into it, and means that if you’re examining a session for which you don’t have all the class definitions (writing tools outside of your application, for instance), it’s just a little bit harder to determine which variables within the session are objects.

The workaround, of course, is easy, given that most other methods treat the object as an object: $is_object = (get_class($o) !== FALSE);.

Best PHP Bug Report 1

If this isn’t the best PHP bug report ever, it’s definitely in the running.

Every day 0

Here are two PHP functions (although one’s actually from an extension) that I didn’t know existed, but give you some good insight into your variables, especially when you’re mucking around with more complicated stuff: debug_zval_dump and xdebug_debug_zval.

Both give you more information about the underlying representation of your variables: in particular, what the refcount is for that particular value. Note, however, that while it’s literally called the “reference count”, a refcount greater than one doesn’t imply that the variable is actually a reference due to PHP’s “copy on write” semantics. XDebug’s version of the method wins here, because it also dumps is_ref, which does flag a reference.

(See Sara Golemon’s You’re being lied to or Derick Rethan’s References in PHP [PDF] for more.)

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_id('stash-stuff-here');
session_start();
$_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 6

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:

ColorForeground=White
ColorBackground=#323232323232
ColorPalette1=#2e2e34343636
ColorPalette2=#cccc00000000
ColorPalette3=#4e4e9a9a0606
ColorPalette4=#c4c4a0a00000
ColorPalette5=#34346565a4a4
ColorPalette6=#757550507b7b
ColorPalette7=#060698989a9a
ColorPalette8=#d3d3d7d7cfcf
ColorPalette9=#555557575353
ColorPalette10=#efef29292929
ColorPalette11=#8a8ae2e23434
ColorPalette12=#fcfce9e94f4f
ColorPalette13=#72729f9fcfcf
ColorPalette14=#adad7f7fa8a8
ColorPalette15=#3434e2e2e2e2
ColorPalette16=#eeeeeeeeecec

Save the file, and revel in your new colors!

Tango Color Theme for XFCE Terminal

Karma 0

Windows is good at a lot of things. So is Linux.

On the desktop, Linux has only been getting better. For instance, imagine my surprise when I plugged my old wireless mouse into my Ubuntu box and immediately received a warning about its battery being low. I’d been using this mouse with Windows for years, and it had never once indicated that it knew anything about the mouse’s power status. I’ve always believed Windows to be the current leader in device compatibility (companies will pay to write drivers for what people are using, and most people use Windows), so I found this to be quite humorous.

Poor old Windows, showing its age. I pointed and laughed a little.

Only problem? That same warning has been showing for the last 6 months, and the power estimate has never changed. It didn’t go to zero when the batteries finally gave out and died and it didn’t go away after replacing the batteries.

Well, what’s that they say… Even a broken clock is right two times a day. Although this is only right once a battery set.

So close.

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.

Balancing Act 0

Here’s a replacement lens cap that purports to help you set the perfect white balance on your DSLR every time, without carrying around a gray card. Interesting idea and tempting, sure, but the $45 price tag (at the low end) has me thinking up some home-grown alternatives — a spare lens cap and a piece of milk jug, perhaps?

Psuedo-update: Amazon carries several cheaper versions of the same idea. Cheap enough that a ghetto hack might not even be worth it.

Next Page »