>>> print "".join(" hello world ".split())
helloworld
The key to the above is that split() separates the string on
any amount of whitespace when no separator is specified.
Posted on in Programming
Posted on in Programming
If you need to debug what queries your WordPress site is making, try adding the
following PHP to your theme:
<?php
foreach ( $wpdb->queries as $query ) {
echo "$query[0]<br />";
}
?>
For this code to work, you need to add the following line to wp-config.php:
define('SAVEQUERIES', true);
After that …
Posted on in Programming
This is one of those annoying little things I have to do ever so often. There are two different commands to accomplish this task depending on the specific situation.
If you've made a lot of changes to a file and need to back all of those changes out, you can …
Posted on in Programming
If you get this error when trying to save something in the Django admin, it's probably because you forgot to synchronize the database after adding the admin application. If you are using a pre-1.2 version of Django, you can simply:
$ ./managy.py syncdb
Django 1.2 (which is currently …
Posted on in Programming
For some reason, sorting a dictionary by its keys seems to be one of the most frequently asked Python questions. I'm not sure if this is because it's just much easier to do in other languages, or if the semantics of the language just confuse new Python developers. I guess …
Posted on in Programming
For me, fixing this problem just meant reading more carefully!
I am updating some shared contacts via the Google Apps Shared Contacts API and curl. I was able to create new shared contacts with no problem, but unable to update an existing contact. The answer to the problem was to …
Posted on in Programming
For the last couple of years, I've used the Tag Suggest Thing WordPress plugin to recommend tags for my posts based on the post content. Beginning with WordPress 2.5, that plugin started to have problems interacting with the WordPress administration pages. In August 2009, Yahoo! announced that they would …
Posted on in Programming
In the early stages of an organization, it is common for most data to be stored in spreadsheets. Spreadsheet applications are common and easily understood by most small business people. Unfortunately, spreadsheets become burdensome when tasks move beyond calculations and into querying (Churcher, 2007). Fortunately, databases are designed with querying …
Posted on in Programming
Having built an entire application, the time has come to consider the possibility of redistributing the application for a wider audience. Since the original application was designed to meet the needs of a specific business, one of the primary considerations will be how the application must be modified to meet …
Posted on in Programming
The widespread use of computers has made database interaction a daily occurrence. Although databases can be large and complex, they are generally defined by basic terms that come together to create the larger system. Understanding these database basics helps users understand the underlying structure of the system and how they …
Posted on in Programming
Modern programs are not developed as singular, autonomous applications. Programmers have learned that many different programs use the same routines over and over again. By developing these routines as independent modules or libraries, programmers gain the advantage of quickly adding functionality to their programs. Modularization allows the detail of often-repeated …
Posted on in Programming
In his excellent series on WordPress Theme SEO, Nathan Rice describes a method to include META tags in WordPress themes rather than relying on plugins. Since I recently updated the Slaptijack theme to include META descriptions and keywords, I thought I would detail the process. If you are interested in …
Posted on in Programming
Decision structures (also known as selection structures) are used in programming to take an action based on the result of a question (Farrell, 2008). An if-then-else statement is the most basic kind of decision structure. The question is represented as a Boolean expression that results in a true or false …
Posted on in Programming
Referential integrity and business rules are two subjects that individuals new to database design find confusing. Relational databases use tables to represent things and events. It is often necessary for a table to refer to another table. In this case, the two tables have a relationship. Referential integrity ensures that …
Posted on in Programming
For those not acquainted with the vernacular of relational databases, many frequently used terms can be hard to grasp. These terms are often difficult to comprehend, but the concepts they describe can be illustrated in plain English. When a database administrator or developer is working with someone not fluent in …