Public Domain

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.

iTunes Opener

by lhl ( | | | )

I've been horrible about releases, here's one that fixes iTunes' crap M3U handling. Here's the original blog entry I wrote about it.

Basically, this will intercept M3Us and then create individual playlists for them instead of dumping the songs directly into your Library (where after playing the first song, the songs in the lists are scattered to whatever your Library ordering is).

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).

Weighted Round-Robin Redirection

by lhl ( | | | )

Here's a quick and dirty way to do weighted round-robin redirection. I assign the key rather than the entire array for weighted array creation so it's not the most inefficient way to do it ever (a more efficient way is to call rand(1,100) and then have a big switch, but it's a PITA to shuffle, especially as you add more sites).

Anyway, the following example shows 50% of the traffic going to url-3, 37.5% to url-2, and 12.5% to url-1:

XML feed