Web

addusers.pl for Confluence

by lhl ( | | | )

Here's a script I wrote a couple weeks ago for easing user management for Confluence. It turns adding users and users to groups into a much less painful affair.

Requires:

WWW::Mechanize
HTML::TokeParser
Crypt::RandPasswd

Should be an easy breezy install w/ CPAN (perl -MPCAN -e shell)

Instructions are included with the code, and the code is pretty straightforward as well. If you're dealing with lots of users, trust me, it'll save you time.

flickrer - automatic Flickr uploading

by lhl ( | | | )

Here's a script I've been using for the past couple of weeks since I started really using Flickr.

Requires:

File::Basename
File::Copy
LWP::UserAgent
Flickr::Upload

Should be an easy breezy install w/ CPAN (perl -MPCAN -e shell)

flickrer first checks that it isn't already running via a process search, then looks the files from the dropbox and locks (via . rename) while uploading. This makes it pretty safe to run at regular intervals via cron. Once it finishes it moves the file to the sentbox. I run sips, OS X's built in image processing utility to reduce the size of the images, as even w/ a Pro account (1GB/mo), u/ling full photo files would be quickly pass quota.

DropCash PHP Output

by lhl ( | | | | | )

I started my first Dropcash campaign today. and coded up a large custom "badge" for my campaign with a little bit of PHP glue.

If you're using PHP5 you'll probably want to use SimpleXML, which looks totally rockin', but for us less adventurous shlubs, give PEAR::XML_Serializer an install (you might need to -f for since it's still 'beta') and check this out:

<?php
  // Caching
  $cache = '/tmp/dropcash';
  $agelimit = 5 * 60; // 5 minutes
  $timestamp = @filemtime($cachefile);
  $age = time() - $timestamp;

  if($age > $agelimit || $_SERVER['QUERY_STRING'] == 'update') {
    $f = fopen($cache, 'w');
    fwrite($f, file_get_contents('http://www.dropcash.com/campaign/[user]/[campaign_name]/xml'));
  }

  $xml = file_get_contents($cache);

  require_once 'XML/Unserializer.php';
  $u = &new XML_Unserializer();
  $u->unserialize($xml);
  $dc = $u->getUnserializedData();

  $percent = $dc['percentage'];
  $percentpx = floor($percent * 4); // 400px bar
  $goal =  $dc['goal'];
  $collected = $dc['total_collected'];
?>

This will probably make more sense w/ the rest of the badge code since it's a bit style-based (for the percentpx).

Self-Updating Web Software

by lhl ( | | | | | )

Anil announced the recent release of MT 3.12, which has, among other things, automatic generation of .htaccess files for dynamic pages.

One of the great things about Drupal is its integrated URL handling, so that's definitely part of the way to go. Apache, or 'full system' integration is certainly a big step for web software to take. Of course, there are those pesky permissions problems and securities risks...

Here's a little bit I wrote a while back for a file that's in a public folder listing (labeled '!!!_donotclick_youwillbebanned.foo' and w/ a robots.txt Deny rule) to block aggressive spiders:

SkipList.js - A JS Skip List Class

by lhl ( | | | )

Now, you might be saying to yourself, "Ahh, a skip list, one of my favorite data structures!" However, much more likely, you're probably wondering WTF a skip list (NIST reference) is.

A skip list is a randomized variant of an ordrered linked list with additional, parallel lists. This is a probabilistic alternative to balanced trees that in general practice gives O(log n) searching w/ easy inserts and deletions (no tree reshuffling).

This OOP JavaScript implementation was created almost entirely from Pugh's original publication, Skip Lists: A Probabilistic Alternative to Balanced Trees.

XML feed