12:41pm on Jun 14, 2013
Phone #1: my fault, I cracked the screen. Oddly though, I noticed the phone audio quality was kinda degraded too...
Phone #2: first replacement. It was plagued with phantom touches at the upper-right corner of the screen (portrait mode), which would start about 10-30 seconds after unlocking it. Very frustrating.
Phone #3: this one seems to be full of dust in the upper-right corner of the screen (location coincidence) - enough that it's difficult to see the battery indicator and clock when not in perfect light, and enough that the proximity sensor doesn't function. A broken proximity sensor means that when you're on the phone and you want to type on the keypad, or perhaps browse your contacts, you can't, because the screen won't go on while the phone thinks you've still got it up to your face.
Phone #4: just ordered this, it's due tomorrow. We'll see if they get it right this time.
1:13pm on May 07, 2013
There is a bug in nginx - patch your daemon or implement this workaround.
12:08pm on Mar 07, 2013
Someone finally got me into the idea of using Python 3.x, so I started looking at my current projects, and picked one to test with. This resulted in me having to port a pretty major library, python-rrdtool. The trick about this is that RRDTool is a C library, so the Python module is an extension module, written in C.
And of course, strings and unicode are different from Python 2.x to 3.x....
Anyway, here's my pull request:
on github
10:22am on Feb 06, 2013
JWZ's post today is awesome. I agree with him, far too many
bugs are being ignored and that just sucks for us users. Especially when they get ignored for a very long time.
When did we stop being good software engineers?
12:45pm on Dec 21, 2012
So I'm doing some REST stuff with SQLAlchemy classes, and I needed a simple way to dump the objects to JSON. This base class will convert an object to a dict, and has some options for funny fields and such.
You may (will) want to use a custom JSON encoder (see simplejson docs) to convert some of the data types, like datetime.datetime in particular.
It's certainly not ideal, in particular the isinstance() call, but it works at the moment for what I'm doing.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 | class JsonObject(object):
def __to_json__(self, exclude_fields = []):
d = {}
for prop in dir(self):
if prop.startswith('_') or prop in exclude_fields:
continue
val = getattr(self, prop)
# we want standard data, not instance methods and such
if callable(val):
continue
if isinstance(val, (sqlalchemy.schema.MetaData, JsonObject)):
continue
# you can define a custom formatter for this data
if hasattr(self, '__formatters__') and prop in self.__formatters__:
d[prop] = self.__formatters__[prop](data)
else:
d[prop] = val
return d
|
11:21am on Oct 26, 2012
I haven't been doing a lot of perl lately, but a lot of my stuff at work is still perl, so every now and then I have to do some maintenance or add new features. Today I was working on new features.
One issue with perl is that there's no way to get an array of regular expression matches without building it yourself in a really ugly way. I had a situation where I was getting a '1' returned in array of match captures when doing this:
| if (my @matches = ($url =~ $test)) {
...
}
|
If there are captures in $test, you get the list of them, but if not, you'll get a '1' in there, in some cases. Frustrating.
You can do this (Thanks Paul!):
| if (my @matches = ($url =~ $test)) {
@matches = () if @+ < 2;
}
|
This works great... but in working out what I needed, I decided I wanted to handle both normal captures and named captures. So here's what I got:
| if ($uri =~ $test) {
# store named matches
%matches = map {$_ => $+{$_}} keys(%+);
# store not-named matches by number
for (my $i=1; $i<= $#-; $i++) {
$matches{$i} = substr($uri, $-[$i], $+[$i] - $-[$i]);
}
}
|
And that is some ugly perl. It works though!
12:19pm on Sep 26, 2012
I got a new laptop. More on that later, perhaps.
This laptop doesn't have hardware controls for the screen brightness, it's done via software. In linux, this is done via poking at stuff in /sys.
So to make my life easier, I wrote a little Python script to do it in a sane way. I do a similar thing for the keyboard backlight, but that only has 3 levels of brightness, so the math is much easier.
backlight.py
1:04pm on Sep 17, 2012
Today I went to Google Play Books to purchase Charles Stross' "Laundry" book "The Apocalypse Codex".
I was thwarted by Adobe Digital Editions.
Clearly Adobe don't want me to read this book. Or perhaps it's Penguin Books.
Google send you a .acsm file, which Adobe Digital Editions trades for the .epub you actually purchased, after doing the DRM thing. In my case, the DRM step didn't work, no matter which way I did it. I got a refund. It'd be one thing if I got a locked up .epub, I could just remove the DRM, but this file is useless.
And since I'm a nice guy, I emailed Stross and told him that I'm going to either download an ebook copy illegally, or just purchase the book used when the price drops.
I tried, I really did.
UPDATE
Stross wrote me back:
You tried; that's fine by me! Meanwhile, I probably don't need to tell you how much I detest DRM.
So there you go.
11:33am on Aug 29, 2012
So I'm working with Fedora 17 lately, which uses systemd. I really want to like it, there's a lot of good things here, especially the ability to auto-restart dead services, which I had been using daemontools for.
The issue is, systemd doesn't quite seem ready for production use, despite being adopted by various Linux distributions.
I just spent some time this morning trying to work out why some NFS mounts configured in /etc/fstab would mount, but others wouldn't. It appears to be a timing issue, for some unknown reason, systemd doesn't load the nfs module before trying to mount NFS shares.
Solution:
echo 'nfs' > /usr/lib/modules-load.d/nfs.conf
At least that's easy.
2:07pm on Jul 17, 2012
I use Finance::Currency::Convert::XE for the old perl version of an IRC bot, and recently xe.com updated their website, which broke XE.pm. This patch fixes it.
XE.pm.diff
UPDATE:
I submitted this as a bug, and it got merged into version 0.21:
bug #78433