Wrapped in gaffa

Programming, Art, Music, Philosophy, Politics

Archive for the ‘Programming’ Category

Downloading galleries with Zenphoto

with 16 comments

Last weekend I had a Christmas Party or what you call it in english – it is basically a danish tradition where you drink a lot of schnapps, with marinated herring and anything made from pigs on rye bread. A great one also has warm food, but mine didn’t.. I think it all evolves around the schnapps and beer, the rest is just fittings.

Anyway I took a lot of pictures with my quite expensive digital camera before I got too drunk.. and decided to hide it from myself. Digital pictures is no fun unless you can share peoples embarrassing moments online, so I installed Zenphoto on my Dreamhost account. Worked like a charm, but soon people started requesting an archived download of the entire gallery. I did a little search and found out that Zenphoto already had that function printAlbumZip and I just had to add it to the Template which was as easy (even for a PHP virgin like me) as adding <?php if (function_exists(‘printAlbumZip’)) { printAlbumZip(); } ?> somewhere appropiate in the template and turned on persistent archive in Zenphoto, so that the gallery would not be archived more than once. Storage space was not a big issue, but apparently RAM was – I kept getting errors because memory ran out. I took a look at createAlbumZip and found that it was sending the file by using readfile which puts the entire ~500MB into RAM before sending it. I did a small patch to cache and send chunks of 16MB at a time in createAlbumZip, it’s not a pretty patch, but I guess simply using readfile isn’t either.

I replaced this code in zp-core/functions.php:
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="' . urlencode($album) . '.zip"');
echo file_get_contents($dest);

With this:
$buf_size = 1024*16;
$file = fopen($dest, "r");
 
header('Content-Type: application/zip');
header('Content-Disposition: attachment; filename="' . urlencode($album) . '.zip"');
header('Content-Length: ' . filesize($dest));
flush();
 
while(!feof($file))
{
print fread($file, $buf_size);
flush();
}
fclose($file);

Link to gallery

Written by gaffa

2008-12-07 at 17:12

Posted in Programming, Software

Tagged with

Update Anjuta Auto-Complete

leave a comment »

The tags used by the auto-complete feature (Scintilla only) in Anjuta can be updated by running this script:

/usr/share/anjuta/scripts/create_global_tags.sh

The script automatically scans your /usr/include folder. It is also running pkg-config to update dependencies for packages.

Maybe there is a way to do this from within Anjuta, but if if there is, it is so unintuitive that it was more obvious for me to open a terminal and write dpkg -L anjuta-common to locate a script ;)

I’m having some issues with the Devhelp extension for Anjuta on Ubuntu 7.10, I’ll post something if I find some time to debug it. I know it crashes on running gtk_moz_embed_realize, but I don’t know why yet ;)

Written by gaffa

2007-12-29 at 02:18

Show me good use of ECMAScript on the Web

with 2 comments

Microsoft want their Silver-something to replace ECMAScript and Flash and Mozilla wants to develop ECMAScript in the direction of Silver-something.

What do I need it for? Nothing.

You can view this blog perfectly fine with a pure HTML and CSS renderer.

Interactivity? What kind of interactivity? Like submitting a comment to this post? It seems to work fine with just HTML/HTTP.

I only know a few great ways of applying ECMAScript and that is in presenting sites like I want to view them, using the Greasemonkey extension for Firefox.

What is the real reason to make my browser execute code from the internet? The answer is advertising. The funny thing is as soon as you disable ECMAScript the content you miss out on is advertising. It is simple to show ads without using ECMAScript, but most ad providers use it to collect information about us. Users don’t need ECMAScript.

I’m sitting here trying to come up with a good use for ECMAScript, Flash and Java, but I just can’t. I need your help, please post a comment.

I can only come up with playing music in your browser and watching video, but really the ideal thing would be a video player plugin and a music player plugin for your browser. You don’t need a completely different audio/video engine as a browser plugin. All you need is a plugin that uses your favourite mediaplayer. The rest is just bloat.

Please post a comment if you disagree (It would help if you explained why you think users need ECMAScript, Flash and Java).

Written by gaffa

2007-11-03 at 15:10