What Jessie Did Next...

...being the inane ramblings of a mundane Yorkshire bird.

Category: Geek (page 4 of 10)

Catching up on RSS feeds this morning I was extremely interested to see this technique for speeding up GROUP BY queries using approximation. In the first example, it knocked down the processing time from over 30 minutes to 30 seconds pretty much (as far as I can make out) because of MySQL’s speed in string comparison operations.

I can see this would be really useful for search tables…

Ben’s in the office with Nicky today and I’m sat at home waiting for my car to be ready.

As seen in another window:

okay – so Ben doesn’t want to play with the games on CBeebies, but he is enjoying looking at the source code for the site.

🙂

I’ve been using 10.5.2 for a couple of weeks now, and maybe I’m alone in this but I’m finding it more unstable than any of the other 10.5 “Leopard” versions:

  • Weird Finder bugs when using two monitors, reproducable by dragging/dropping where it ‘locks’ the destination window. Depending on which screen has the focus window in it, the Finder window ‘slides’ back and forth across the desktop.
  • Frequently my MacBook Pro fails to wake from sleep or – even worse – doesn’t properly go to sleep leaving the fans going while it’s in my bag (since then I’ve learned to check for this).
  • Application switching is a lot slower, there’s a lot more of the coloured ‘please wait’ spinner even when I’ve just got a couple of low-memory applications loaded such as Terminal and Address Book.
  • Occasional keyboard failure, still – all seems to be happening in the USB bits of the kernel (com.apple.iokit.IOUSBFamily or com.apple.iokit.IOHIDFamily).

For a machine that’s got 2G RAM and a reasonable CPU (Intel Core 2 Duo 2.3GHz) it seems Apple is still walking backwards. If it wasn’t for Coverflow/Preview I’d probably sod off back to 10.4 this weekend.

The sort of work I do is usually to do with end user services – websites which allow a user to create a login and password to give them access to larger featuresets, etc. You know the kind of thing – social network websites are a prime example: as part of that I frequently get asked to log information a user may do, recording the source IP address of any messages they may leave in order to protect from abuse.

A frequent mistake folks make in writing code to do this is in the IP address which made the HTTP request. Most larger ISPs enforce transparent proxying on the user, meaning that instead of having the IP address of the end user themselves you’ve got the IP address of a proxy which may handle hundreds of thousands of users! It causes issues not just in traceability, but also in things like bandwidth logging if you’re doing it at an application level.

Enter X-Forwarded-For. It’s an HTTP header which most proxy software will add, giving the source IP address which requested the page through the proxy and preventing proxy servers becoming anonymising services.

This is exposed to PHP through the $_SERVER superglobal, so you can use it like so:

if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
logEntry("User connected from ".$_SERVER['HTTP_X_FORWARDED_FOR']);
} else {
logEntry("User connected from ".$_SERVER['REMOTE_ADDR']);
}

Now there’s a gotcha here. A lot of ISPs such as AOL and NTL allocate ‘private’ RFC1918 IP space internal to their network. That means if you get 10.5.3.4 or similar then you’re on a hide into nothing because you’ve not got the proxy which may be ‘seeing’ that address – so you need to log both when you find a proxy:

if ( isset($_SERVER['HTTP_X_FORWARDED_FOR']) ) {
logEntry("User connected via proxy ".$_SERVER['REMOTE_ADDR'].
" from ".$_SERVER['HTTP_X_FORWARDED_FOR']);
} else {
logEntry("User connected from ".$_SERVER['REMOTE_ADDR']);
}

But what if users are stringing proxies together? Well, that’s dealt with too. The proxy software appends itself to each X-Forwarded-For header, separated by commas.

Of course this should be treat as a first line of defence – if someone’s really wanting to hide themselves they can, through IP spoofing or fiddling their own proxy software to remove the header. However, it’s a neat way of preventing false positives and – more importantly – finding out who’s really behind stuff, now RFC1918 endpoints are becoming more and more common.

Wikipedia has a bit about X-Forwarded-For here, if you fancy a little more reading.

With Microsoft’s announcement that they’ll be opening up their binary file formats from Office, I read with interest Joel Spolsky’s reasons why MS Office formats are so complicated – it certainly explains an awful lot.

(I’d strongly suggest reading Spolsky’s books and essays – they’re often insightful and you learn a lot.)

Ben’s lunch had RSS mashed potato.

A rather amusing look at the Apple product cycle. Seems to tick all the boxes 😛

After a long wait, Mac OS X 10.5.2 is out and available in Software Update.

My MacBook Pro took 3 reboots I think before it was back to the desktop, and then a “Leopard Graphics Update” appeared! I’ll give it a bit of hammer today and see how it performs, but I’m already pleased with the ‘list view’ in Stacks – I can have a sort-of ‘start button’ to list all my applications again, something I really miss in OS X.

Just a quickie note because I’m bored of relating the same data to everyone – there’s a Linux kernel exploit which seems to affect versions 2.6.17 to 2.6.24.1 and give root privs from any local user:

joel$ ./exploit
[..]
[+] mmap: 0xb7f29000 .. 0xb7f5b000
[+] root
root#

You can in some cases patch it live (!) but I’ve got at least two installations where I had to compile a new kernel.

There’s a patch at git.kernel.org, and you can test whether you’re vulnerable using milw0rm’s exploit proof-of-concept.

Just been reading on the BBC website that the Self Assessment submission page has died on the final day for submissions (giving this error).

The Service Availability page looks to be partially dead too – the stylesheet’s failing to load and without sensible fallback the information is patchy at best.

Trebles all round!

Monty Widenius (creator of MyISAM and MySQL) has announced the first public release of the Maria engine. This basically sounds like crash-safe MyISAM crossed with the InnoDB featureset, and there’s a Bitkeeper archive here.

It would certainly be nice to have fulltext column indexing in a format which supports ACID and row-level locking, together with the capability for foreign keys. It’s useful in some cases to have a table-per-file and would be even better if it was crash-safe 😛

I guess it’ll end up being version 2 or 3 before it’s ready for production, however. I certainly wouldn’t feel safe using something like that before it’s been through the mill at larger MySQL installations such as Yahoo, either.

More fodder for the ENUM-Bad-Or-Good argument!

I’ve just read this article over on the MySQL Performance Blog, comparing speed of ENUM vs VARCHAR vs Joined Tables.

I like ENUM and find it makes my life a lot easier in a lot of cases (but not all, let’s get that straight – it’s good where it’s appropriate).

Nice to know other people can justify use of it too 😛

Once again demonstrating an utter lack of clue, the EU guy in charge of the ‘personal data and privacy’ working group has stated IP addresses are personal data. I wonder what planet he’s on?

Back at Mailbox in the late 90s we’d allocate a block of 255 IP addresses to share between approximately 3000 dialup users, for instance. Then there’s the RFC1918 private address space, which not only is reused again and again the world over, but is regularly allocated by ISPs nowadays looking to conserve address space (as an example, Vodafone do this with their 3G service).

What an astounding display of fuckwittery.

Software update just popped up this:

This update addresses a responsiveness issue on MacBook and MacBook Pro notebook computers. Some MacBook and MacBook Pro systems may occasionally experience a temporary suspension of keyboard input which can last a minute or longer. The Mac OS X 10.5.1 update is required before installing the MacBook, MacBook Pro Software Update 1.1.

It’s installing now. I guess we see if it works. Also it appears 10.5.2 is seeding to developers for a rumoured January update (presumably to support new hardware being announced at MacWorld or whatever it is).

More Google-fodder for folks who might have the same problem. The keyboard and trackpad ‘disappearing’ under OS X 10.5.1 causes the following to appear in /var/log/system.log:

Dec 16 12:23:01 trixie kernel[0]: USBF: 31305.811 [0x3fa0000] The IOUSBFamily is having trouble enumerating a USB device that has been plugged in. It will keep retrying. (Port 2 of hub @ location: 0x1d000000)
Dec 16 12:23:05 trixie kernel[0]: USBF: 31309.651 [0x3fa0000] The IOUSBFamily was not able to enumerate a device.
Dec 16 12:23:50 trixie com.apple.launchd[1] (com.apple.dyld): Throttling respawn: Will start in 60 seconds

Seems that it ‘forgets’ the internal USB hub for the keyboard and mouse. The external keyboard/mouse work fine.

Older posts Newer posts