Fast Weighted Random Choice In PHP

December 10th, 2008

Sometimes you may need to randomly select items from a list so that some items are selected more frequently than others. For example, you might take a list of applications and their download counts, and randomly pick a “featured application” based on the number of downloads. There are several ways to accomplish this in PHP. […]

Continue Reading...

Cross-Domain POST With JavaScript

November 20th, 2008

Normally you can’t send cross-domain requests in JavaScript due to restrictions imposed by the same-origin security policy. There are many clever hacks that circumvent this by using remote script includes (even CSS includes) or proxy scripts, but so far I haven’t seen anything useful for client-side, cross-domain POST requests. However, it turns out you can […]

Continue Reading...

Displaying Recent Posts On a Non-WordPress Page

November 15th, 2008

Listing recent posts on a WordPress page is easy – there are various widgets and theme functions available just for that purpose. But what about a non-WP page, or even a different site? That’s not that hard either – simply grab some posts from the blog’s RSS feed and output them on your page. In […]

Continue Reading...

Parse, Edit And Create Torrent Files With PHP

November 11th, 2008

A .torrent file contains assorted metadata that is stored in a “bencoded dictionary” format. Bencoding is a relatively simple cross-platform encoding used by BitTorrent and a dictionary is basically an associative array. You can find a high-level overview of the file structure here. To open or edit a .torrent file in PHP you can either […]

Continue Reading...

Private Message Sender Script For vBulletin Forums (PHP)

October 9th, 2008

Random script time! Here’s a PHP function that can send messages to any user on a vBulletin forum. I wrote it because somebody asked me if I could help with their code and I figured it would be easier to write it from scratch. Also, I predict it will be useful to more than one […]

Continue Reading...