Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.

2009/04/25

That's A New One On Me (Vista Content)

A friend of my wife is doing low-level web stuff for a class. On Vista. Her name has a space in it. Think Var Lo instead of Varlo. This means that her desktop is at C:\Documents\Var Lo\Desktop\.

There are many things that annoy me here, and only some of them relate to Vista. You cannot tell Vista's Windows Explorer to tell you the extension of known file types. This, to my telling, is Microsoft telling the users that it has nothing but disgust for them and everything they have done, are doing and will ever do. And then there's when the friend asked how to do something with a web page. I said "open that in your browser". She was unable. She then asked if I thought she was stupid. I said no. I didn't say that I thought she was deliberately being obtuse to try to annoy me. I do think she was being deliberately obtuse to try to annoy me.

But the biggest thing was that the page she was writing had an image.





dogpic.jpg existed and was in the same directory as the page. It should've worked. It didn't work. I suspect that the issue is that IE has problems with filenames with spaces, and while seeing dogpic.jpg as c:\Documents\Var Lo\Desktop\dogpic.jpg and then broke upon seeing that space.

They're currently using FTP (ack!) to move the file to the server. We'll see how that goes.

2009/04/09

And the jQuery is just that simple!


$(document).ready(function(){
$("legend").click(function(event){
if ( $(this).parent().children('div').is('.hidden') ) {
$(this).parent().children('div').removeClass('hidden') ;
}
else {
$(this).parent().children('div').addClass('hidden') ;
}
});
});


Except I think I will want an external link, so I'll have to add another level of parent(). But jQuery is hardly distinguishable from magic.

Investigating jQuery

So, you have a bunch of HTML elements. Let's say they're Fieldsets.



x
XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXX


x
XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXX


x
XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXX



Now, you want to be able to hide some of those fieldsets. You could make the legend clickable.



x
XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXX



hide_element() is dead easy. I do it in five lines. I could drop one if I wanted. Just a bit of stylesheet manipulation. But there's a problem. As written, that hides the fieldset for good. I really want to toggle. So, something must remain.



x
XXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXX




This is better, but you have to name every single fieldset. There should be a way to address everything anonymously. And there is. jQuery. Which I don't quite grok yet. But that's where my head is.

2009/04/01

Confronting Big Avatars with Perl and Magick

I do twitter. I run Linux. I use Twitux, not because I like it the most but because I dislike it the least of everything I can run without installing AIR.

It has a problem, however. Avatars are 48x48, but if you upload a way-too-freakin'-big avatar, like the huge pics you can get off your phone these days, it doesn't complain. It just screws up your display. And I finally got sick of it.


#!/usr/bin/perl

use Modern::Perl ;
use Image::Magick ;
use subs qw{ check_image fix_image } ;

# probably an easy change to make this more portable.
# oh well
my $dir = '/home/jacoby/.gnome2/twitux/avatars' ;

#go through all avatars
if ( opendir my $DH , $dir ) {
while ( defined( my $file = readdir( $DH ) ) ) {
next if $file =~ m{^\.}mx ;
my $full_filename = join '/' , $dir , $file ;
check_image $full_filename ;
}
}
else {
say 'Fail' ;
}

# are they 48x48?
sub check_image {
my $file = shift ;
my $image = new Image::Magick ;
$image->Read($file) ;
my $width = $image->Get('width') || 0 ;
my $height = $image->Get('height') || 0 ;
return if $height == 48 && $width == 48 ;
return fix_image $file ;
}

#make them 48x48.
sub fix_image {
my $file = shift ;
my $image = new Image::Magick ;
$image->Read($file) ;
$image->Resize(width=>48,height=>48) ;
$image->Write($file) ;
return ;
}


You need Perl. You need Image::Magick. You need crontab to run it ever so often.