Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Wednesday, August 31, 2011

Dynamic subversion repositories with WebSVN

I am a careful man. For every development project, I have a corresponding Subversion repository that stores all assets relating to the project. For browsing (and blaming diffs), I use WebSVN to provide a friendly interface. I currently use DreamHost to host my repositories.

However, I got tired of updating the WebSVN configuration every time I added a repository. Therefore, I developed a short, dynamic method of just listing them all without need for reconfiguration. Add the following snippet to your config.php:

$repository_root = '/CHANGE/TO/YOUR/PATH/svn/';

foreach(glob($repository_root . '*', GLOB_ONLYDIR) as $repository_dir) {
  $repository = basename($repository_dir);
  $config->addRepository($repository, 'file://' . $repository_root . $repository);
  $config->useAuthenticationFile($repository_root . $repository . '.access', $repository, $repository);
}

Friday, January 19, 2007

Free desktop revolution, new domain and using ezSQL

Inspired by a recent experience, my latest entry at FSM offers my perspective on the question, has the free desktop revolution arrived? My wife's computer had hardware issues, so as a stop-gap I gave her an account on my Ubuntu desktop, then asked her about her experience.

I registered a new domain through DreamHost. They have very reasonable plans, starting at $7.95 a month, and I've used their services for several other sites that I've administered and had a positive experience working with them. My new site, the confluence is intended to be a collection of web applications that I've written and released to the public. Most programs will be released as GPL, as I believe fully in contributing to the community.

I'm working finishing a few applications; the tag cloud generator (name pending), eManiuplator (email address extraction, validation and list operations), eBrother (visualizes server usage), an email newsletter generator (name pending), and a service inspired by the old lowbrow.com site. The first three work, but need to be secured and cleaned up. The last two are in development.

I've discovered a new database class that assists in rapid application development; ezSQL v2.00. In their words, "ezSQL is a class that makes it ridiculously easy to use mySQL, Oracle8, SQLite (PHP), within your PHP script." It's got automatic query caching, built-in debugging functions, and works with Smarty. I really, really like the way it returns responses and the built-in functions are very useful. I suggest you give it a try.

Thursday, January 11, 2007

Finding Linux replacements for Windows software, developing with phpMyEdit

When discussing ways to switch to GNU/Linux, one of the biggest difficulties I've found is finding answers to the question, "What can I replace this program with?" It's completely understandable; people don't want to lose functionality. However, Googling for answers can easily lead to confusion and frustration if you don't have the background or knowledge to be able to differentiate between the wheat and the chaff. In my new entry for FSM, I discuss resources that can be used for Finding GNU/Linux replacements for Windows software.

Good news; the article that I wrote for Free Software Magazine has been accepted! Once it's published, I'll link to it here. I'm proud; it's my first real published article, not just an opinion, letter or article in a student publication.

Today, I've been going through my notes, snippets and ideas from the past few weeks and tried to catch up on some back entries (my apologies to the feed subscribers). I've posted everything chronologically, so if you look at the blog itself, it should sense.

Yesterday, I tried using phpMyEdit to develop a forms based front-end to a MySQL database. I've found it to be simultaneously useful, simple, complex, flexible, and limited. It allows for rapid development of CRUD (Create, Read, Update and Destroy) forms, which greatly reduces development time. However, when you want to use an advanced MySQL join or contextual input, you start to find a bit of roughness.

The documentation does a decent, but not thorough job of listing all the functionality. I'm particularly annoyed by the comment, "Note that the above example contains additional features..." yet there are no instructions on how to use the new functionality anywhere else in the manual.

Another issue I have with the documentation is the inclusion of code examples that only apply to "future development" and not the current version... this sort of thing should be in the bug tracker, not the production documentation.

I've asked a question on how to do contextual input on their support forums, and if I get a response, I'll publish it here. Overall, I think phpMyEdit is a good free tool for PHP development.

Wednesday, January 10, 2007

Analyzing President Bush's Speech on Iraq with a Tag Cloud

In the build-up to President Bush's speech on Iraq, I've heard a lot of speculation on what the emphasis of the speech was going to be about, and how the content was going to be less rhetoric and catch phrases and more of a persuasive argument. Out of curiosity and inspired by the US Presidential Speeches Tag Cloud, I used an application I wrote using free tools and scripts that extracts key phrases and words from a document and represents the results as a tag cloud (weighted list). Here are the results of the tag cloud analysis of the transcript of the speech.

Background

One of my tasks as a programmer was to find a way to process a large body of text (committee suggestions), pick out key phrases or words that occurred more often, and display them in an easily understood format. However, if I just did a word count, then I'd get high occurrences of out-of-context nouns, adverbs and verbs, which wouldn't be useful.

Term Extraction

The Yahoo! Developer Network offers a very useful tool as part of their Content Analysis Web Services - Term Extraction. The service "provides a list of significant words or phrases extracted from a larger content." To use the service, you'll need a free Yahoo! Application ID. The only limit on the service is 5,000 queries per IP address per day, which for most users is more than sufficient. To get around some hosting limitations, I used the HTTP POST from PHP without cURL script from netevil.org

As the service provides a unique terms, I couldn't just submit the whole body of text, which would have resulted in a few key words and phrases occurring only once. I had to split the source text into individual paragraphs, submit each paragraph separately, and push each resulting term into an array.

Tag Clouds

A fairly recent innovation in web development has been the use of tag clouds. A tag cloud is an alphabetized way of visually representing the frequency of a word or phrase using font sizes that correspond to precedence, or some other similar emphasis. If a word or phrase occurs more often, it'll be displayed larger than the other members of the list. For more information and the history of tag clouds, read the wikipedia entry.

I combined the Term Extraction with a modified version of the excellent free PHP tag cloud generator from 15tags. The script just counts the occurrences of strings within an array and displays the top few items that occurred the most often in a tag cloud. You can adjust the number of items in the tag cloud; while I've displayed over 100 items, it works best with around 25-30.

Results

I took the committee suggestions, pasted them into the tool, pasted the result into a word processor, added a little formatting, and gave the printed document to my supervisor. She found the results useful and visually interesting; it a good tool for arbitrary analysis, and the resulting tag cloud could be used as the basis of a cover for the report. I think tag clouds are a useful method of visually representing the importance of a term, tag, or key words.

For fun, I also ran the application on some erotic literature and IRC logs. I won't share the results in public, but believe me, it's a hoot.