<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent">]>
<rss version="2.0" xml:base="http://randomfoo.net/code" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>random($code) - Public Domain</title>
 <link>http://randomfoo.net/code/taxonomy/term/5/0</link>
 <description>&lt;a href=&quot;http://creativecommons.org/licenses/publicdomain/&quot;&gt;Public Domain&lt;/a&gt;</description>
 <language>en</language>
<item>
 <title>addusers.pl for Confluence</title>
 <link>http://randomfoo.net/code/Confluence/addusers.pl</link>
 <description>&lt;p&gt;Here&#039;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.&lt;/p&gt;

&lt;p&gt;Requires:&lt;/p&gt;
&lt;pre&gt;WWW::Mechanize
HTML::TokeParser
Crypt::RandPasswd&lt;/pre&gt;

&lt;p&gt;Should be an easy breezy install w/ CPAN (&lt;code&gt;perl -MPCAN -e shell&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;Instructions are included with the code, and the code is pretty straightforward as well.  If you&#039;re dealing with lots of users, trust me, it&#039;ll save you time.&lt;/p&gt;</description>
 <comments>http://randomfoo.net/code/Confluence/addusers.pl#comment</comments>
 <category domain="http://randomfoo.net/code/taxonomy/term/21">Major</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/39">Perl</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/34">Web</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/5">Public Domain</category>
 <enclosure url="http://randomfoo.net/code/files/addusers.pl.txt" length="2788" type="text/plain" />
 <pubDate>Mon, 25 Apr 2005 12:37:36 -0700</pubDate>
 <dc:creator>lhl</dc:creator>
 <guid isPermaLink="false">19 at http://randomfoo.net/code</guid>
</item>
<item>
 <title>iTunes Opener</title>
 <link>http://randomfoo.net/code/iTunes/iTunes Opener.sitx</link>
 <description>&lt;p&gt;I&#039;ve been horrible about releases, here&#039;s one that fixes iTunes&#039; crap M3U handling.  Here&#039;s the &lt;a href=&quot;http://randomfoo.net/blog/id/3348&quot;&gt;original blog entry&lt;/a&gt; I wrote about it.&lt;/p&gt;
&lt;p&gt;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).&lt;/p&gt;
</description>
 <comments>http://randomfoo.net/code/iTunes/iTunes Opener.sitx#comment</comments>
 <category domain="http://randomfoo.net/code/taxonomy/term/53">AppleScript</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/21">Major</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/55">OS X</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/5">Public Domain</category>
 <enclosure url="http://randomfoo.net/code/files/iTunes Opener.sitx" length="54821" type="application/octet-stream" />
 <pubDate>Sun, 17 Apr 2005 21:51:47 -0700</pubDate>
 <dc:creator>lhl</dc:creator>
 <guid isPermaLink="false">18 at http://randomfoo.net/code</guid>
</item>
<item>
 <title>DropCash PHP Output</title>
 <link>http://randomfoo.net/code/node/16</link>
 <description>&lt;p&gt;I started &lt;a href=&quot;http://www.dropcash.com/campaign/lhl/octobernovember_bandwidth/&quot;&gt;my first Dropcash campaign&lt;/a&gt; today. and coded up a large custom &quot;badge&quot; for my campaign with a little bit of PHP glue.&lt;/p&gt;

&lt;p&gt;If you&#039;re using PHP5 you&#039;ll probably want to use &lt;a href=&quot;http://www.zend.com/php5/articles/php5-simplexml.php&quot;&gt;SimpleXML&lt;/a&gt;, which looks totally rockin&#039;, but for us less adventurous shlubs, give &lt;a href=&quot;http://www.sitepoint.com/article/xml-php-pear-xml_serializer&quot;&gt;PEAR::XML_Serializer&lt;/a&gt; an install (you might need to -f for since it&#039;s still &#039;beta&#039;) and check this out:&lt;/p&gt;

&lt;pre&gt;&amp;lt;?php
  // Caching
  $cache = &#039;/tmp/dropcash&#039;;
  $agelimit = 5 * 60; // 5 minutes
  $timestamp = @filemtime($cachefile);
  $age = time() - $timestamp;

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

  $xml = file_get_contents($cache);

  require_once &#039;XML/Unserializer.php&#039;;
  $u = &amp;new XML_Unserializer();
  $u-&gt;unserialize($xml);
  $dc = $u-&gt;getUnserializedData();

  $percent = $dc[&#039;percentage&#039;];
  $percentpx = floor($percent * 4); // 400px bar
  $goal =  $dc[&#039;goal&#039;];
  $collected = $dc[&#039;total_collected&#039;];
?&amp;gt;&lt;/pre&gt;

&lt;p&gt;This will probably make more sense w/ the rest of the badge code since it&#039;s a bit style-based (for the percentpx).&lt;/p&gt;</description>
 <comments>http://randomfoo.net/code/node/16#comment</comments>
 <category domain="http://randomfoo.net/code/taxonomy/term/29">Example</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/21">Major</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/38">PHP</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/12">random($foo)</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/34">Web</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/5">Public Domain</category>
 <enclosure url="http://randomfoo.net/code/files/dropcash.php.txt" length="3883" type="text/plain" />
 <pubDate>Fri, 22 Oct 2004 22:27:14 -0700</pubDate>
 <dc:creator>lhl</dc:creator>
 <guid isPermaLink="false">16 at http://randomfoo.net/code</guid>
</item>
<item>
 <title>Weighted Round-Robin Redirection</title>
 <link>http://randomfoo.net/code/node/7</link>
 <description>&lt;p&gt;Here&#039;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&#039;s not the &lt;em&gt;most&lt;/em&gt; inefficient way to do it ever (a more efficient way is to call &lt;code&gt;rand(1,100)&lt;/code&gt; and then have a big switch, but it&#039;s a PITA to shuffle, especially as you add more sites).&lt;/p&gt;

&lt;p&gt;Anyway, the following example shows 50% of the traffic going to url-3, 37.5% to url-2, and 12.5% to url-1:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://randomfoo.net/code/node/7&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://randomfoo.net/code/node/7#comment</comments>
 <category domain="http://randomfoo.net/code/taxonomy/term/29">Example</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/12">random($foo)</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/33">Redirection</category>
 <category domain="http://randomfoo.net/code/taxonomy/term/5">Public Domain</category>
 <pubDate>Mon, 18 Oct 2004 02:15:40 -0700</pubDate>
 <dc:creator>lhl</dc:creator>
 <guid isPermaLink="false">7 at http://randomfoo.net/code</guid>
</item>
</channel>
</rss>
