How To Extract HTML Tags And Their Attributes With PHP

October 20th, 2009

There are several ways to extract specific tags from an HTML document. The one that most people will think of first is probably regular expressions. However, this is not always – or, as some would insist, ever – the best approach. Regular expressions can be handy for small hacks, but using a real HTML parser [...]

Continue Reading...

How To Make a “Falling Sand” Style Water Simulation

September 29th, 2009

Have you ever wondered how all those “falling sand” games work under the hood? If so, read on. Today I will discuss one of the possible ways how you could implement the “falling” part of the game – sand particles falling under the effects of gravity, water (or other liquids) flowing down a hillside, and [...]

Continue Reading...

Simple Fluid Simulation With Cellular Automata

September 1st, 2009

Last week I couldn’t use my regular dev. machine (broken graphics card), so all my WordPress-related plans were on hold. To pass the time, I built a simple water simulation in Processing. Today I’m going to show you this little application and explain how it works. Online demo and source code are included.
Big Words, or [...]

Continue Reading...

Changelog Generator For WordPress Plugins

August 20th, 2009

A few months ago, WordPress.org introduced a new feature available to plugins hosted in the Plugin Directory – changelogs. Having an easily accessible changelog is certainly a usability plus, but I felt it created unnecessary work for plugin developers. Personally, I usually provide meaningful log messages (example) when uploading a new version of a plugin [...]

Continue Reading...

How To Speed Up Your JavaScript (Video)

August 10th, 2009

JavaScript has become an integral part of the modern Web. Some would praise it as the miracle stuff that ties together diverse web technologies and creates more responsive user interfaces, the stuff that makes glorious mashups and truly interactive web apps possible. Some would rather liken it to a sticky sludge that attaches itself to [...]

Continue Reading...

Calculating Readability Metrics In PHP

April 28th, 2009

Readability metrics, also known as readability formulas, are a set of algorithms that estimate the readability of text. Most tests are fairly primitive as they only take into account things like sentence length and the average number of syllables per word, but ignore deeper factors like sentence structure and semantics.
Still, readability metrics can be useful [...]

Continue Reading...

How To Get Per-Core CPU Usage

April 17th, 2009

It’s pretty easy to get the average CPU usage, but how about calculating the per-code load on multicore systems? Turns out it’s also simple enough if you use performance counters.
Windows API includes a subset of functions that provide various performance-related information, which includes data on how busy individual processors or cores are. In this [...]

Continue Reading...

Text Classification With PHP

March 7th, 2009

Text classification is probably the most popular real-world application of machine learning and other AI techniques. This is because the adaptive spam filters that guard our inboxes, comment forms and guestbooks are basically specialized text classifiers that only deal with two categories – “spam” and “not spam”. Text categorization can also be used to detect [...]

Continue Reading...

Top 4 Free Embedded Databases

February 25th, 2009

I need an embedded database for my next project. During the last few days I’ve done a lot of virtual leg-work researching and comparing the various alternatives, trawling through documentation and forums. The results are below. Hopefully, if you’re ever in the same situation, this list will make your life a bit easier.
Of course, the [...]

Continue Reading...

Make Your Plugin Faster With Conditional Tags

February 22nd, 2009

One of the reasons why WordPress can be slow is that it loads all active plugins on each and every page, even if some of those plugins aren’t actually used on that page. For example, an active anti-spam plugin will still be loaded even if the current page doesn’t contain a comment form (e.g. category [...]

Continue Reading...

WordPress API Resources

January 14th, 2009

[Here's some list-cliche-filler stuff while I fight off a (hopefully) temporary bout of unproductivity and dentists]
WordPress internals are documented pretty well, but sometimes finding the right API/Codex page can take a while. That’s why I’ve decided to put together a comprehensive list of all APIs used by WordPress to serve as a “jump-off point” for [...]

Continue Reading...

Get Google Search Results With PHP – Google AJAX API And The SEO Perspective

January 5th, 2009

If you’ve ever tried to write a program that fetches search results from Google, you’ll no doubt be familiar with the excrutiating annoyances of parsing the results and getting blocked periodically. Run a couple hundred queries in a row and bam! – your script is banned until proven innocent by entering an captcha. Even that [...]

Continue Reading...

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

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 parse [...]

Continue Reading...

JavaScript Splitters And Resizable Panels

October 23rd, 2008

In this post I’ll review* several splitter components for JavaScript. A splitter is usually a vertical or horizontal bar that you can drag to change the size of the surrounding elements. Most splitter scripts also depend on, or are part of a JS framework, which may be an important consideration if you’re already using some [...]

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 sentient.
Copy [...]

Continue Reading...

The Benefits of Using Hooks Instead Of Plugin-Specific Functions

September 21st, 2008

Lets talk about that plugin-related code you have to put in your theme files when you want to add something nifty to your blog, like a “Related posts” feature or AdSense ads. It occurs to me that most plugin authors have been handling this the same way – you get a custom function that you [...]

Continue Reading...

How To Get Redirect URL In PHP

July 5th, 2008

HTTP redirects usually have the response status 301 or 302 and provide the redirection URL in the “Location” header. I’ve written three complementary PHP functions that you can use to find out where an URL redirects to (based on a helpful thread at WebmasterWorld). You don’t even need CURL for this – fsockopen() will do [...]

Continue Reading...

How To Create a MySQL Database In cPanel With PHP

June 24th, 2008

A PHP class that uses cURL to log in to cPanel. Can create MySQL databases and users, add users to databases, list existing databases, and more.

Continue Reading...

TOR : How To Switch To a New Identity Using PHP

June 20th, 2008

A simple PHP function that can make TOR switch to a new identity. The script also supports TOR authentication.

Continue Reading...

Improved Thread Simulation Class for PHP

May 24th, 2008

Two classes that use asynchronous HTTP POST requests to simulate multithreading (works on Windows, too!). The Thread class simulates a single thread of execution, whereas ThreadManager is an utility class that makes handling multiple threads easier.

Continue Reading...

Building a DeviantArt Recommendation Engine

April 29th, 2008

DeviantArt, with its huge number of artworks and a large userbase, is just the kind of site that could use a good recommendation engine. A recommendation engine is basically a program that analyzes your tastes and recommends some images that you might like. There do not seem to be any official plans to create a recommendation system. So I went ahead and started building my own recommendation engine for DA.

Continue Reading...

Plugin Updater 2.1

April 21st, 2008

Here’s another upgrade for the One Click Plugin Updater. Now with even more potentially deadly features!
What’s New
Global update notices (≥ WP 2.5)
Displays an update notification bar on all admin pages when there are new plugin updates available. The update notice will list all available upgrades and include a link to perform them all [...]

Continue Reading...

Simple Text Summarizer In PHP

April 12th, 2008

I’ve written a simple text summarizer that can find the most important sentences in any given (English) text and produce a summary of the specified length. It would be pretty easy to adapt the PHP script to other languages, too.

Continue Reading...

One Click Updater Plugin 2.0

April 6th, 2008

This version of the WordPress plugin has a lot of new features, and, quite probably, a lot of new bugs, too. In fact, it’s so experimental it even glows in the dark
The plugin, which I’ve alternatively called “One Click Updater” and “Single Click Updater” in the past (no doubt to confuse everyone, [...]

Continue Reading...

Scrape Google Blog Search With PHP

March 28th, 2008

I’m currently lacking real “bloggable” ideas, so here’s something simple and hopefully useful – a PHP script to get the blog search results from Google. The script is provided strictly for educational purposes, blah blah blah.
And by the way, if you only need the top X results, it would be simpler to use the Blogsearch’s [...]

Continue Reading...

Free Tools for Natural Language Processing

March 13th, 2008

I’ve compiled a list of various Python modules and functions that I found most useful in certain Natural Language Processing tasks. For easier skimming, the list is grouped by NLP task, such as tokenization and tagging.

Continue Reading...

Get Google Image Search Results With PHP

February 28th, 2008

Google Image Search doesn’t get as much time in the spotlight as the “normal” Web Search, but it’s still useful for things like finding suitable illustrations for an article (Flickr also comes to mind). Whatever you use it for, you can often get results faster with a bit of automation. Here’s a simple PHP script that can parse and return the results of any Image Search query. For education purposes only.

Continue Reading...

Extracting The Main Content From a Webpage

January 25th, 2008

I’ve created a PHP class that can extract the main content parts from a HTML page, stripping away superfluous components like JavaScript blocks, menus, advertisements and so on. The script isn’t 100% effective, but good enough for many practical purposes. It can also serve as a starting point for more complex systems.

Continue Reading...