Twitter
It's March the 9th and it's snowing... 2 days ago
June, 30 2009

WordPress Configuration Tricks

Take a look at this post for a list of useful “hidden” configuration settings for your WordPress installation.
I found some nice tricks that I’ve applied to my wp-config.php:

// Number of post revision to keep
define('WP_POST_REVISIONS', 3);
 
// Installation path and template path to reduce database queries
define('WP_HOME', 'http://your_site_url.com');
define('WP_SITEURL', 'http://your_wordpress_directory_url.com');
 
define('TEMPLATEPATH', '/absolute/path/to/wp-content/themes/active-theme');
define('STYLESHEETPATH', '/absolute/path/to/wp-content/themes/active-theme');
 
// Security keys to improve cookies encription
define('AUTH_KEY', 'randomKey');
define('SECURE_AUTH_KEY', 'randomKey');
define('LOGGED_IN_KEY', 'randomKey');
define('NONCE_KEY', 'randomKey');

via Digging Into Wordpress.

June, 22 2009

Compact font styles

This is a simple tip that can help you reduce your style sheet size. Take a look at this CSS portion:

font-family: Arial, Verdana, Helvetica, sans-serif;
font-size: 1.1em;
font-weight: bold;
font-style: italic;
line-height: 1.5em;
font-variant: uppercase;

All these properties can be condensed into a one row expression using this syntax:

font: fontSize/lineHeight weight style variant family;

See the example below:

font: 1.1em/1.5em bold italic uppercase Arial,Verdana,Helvetica,sans-serif;

Just remember that this syntax will only function if you specify both font-size and font-family.

Remove leading zeroes in XSL

A useful XSL template for removing leading zeros

<xsl:template name="removeLeadingZeros">  
  <xsl:param name="originalString"/>  
  <xsl:choose>  
    <xsl:when test="starts-with($originalString,'0')">  
      <xsl:call-template name="removeLeadingZeros">  
        <xsl:with-param name="originalString">  
          <xsl:value-of select="substring-after($originalString,'0' )"/>  
        </xsl:with-param>  
      </xsl:call-template>  
    </xsl:when>  
    <xsl:otherwise>  
      <xsl:value-of select="$originalString"/>  
    </xsl:otherwise>  
  </xsl:choose>  
</xsl:template>

Just insert it into your XSL file and use it as usual:

<xsl:call-template name="removeLeadingZeros">  
  <xsl:with-param name="originalString" select="$myOriginalString"/>  
</xsl:call-template>
June, 21 2009

Zipped folder backup

A simple bash script that zips a folder and sets the archive name to the current date.

#!/bin/bash
 
# Archive name structure: ddMMYYYY_HHmmss.zip
 
archiveName=`date +%d%m%Y_%H%M%S`.zip
folderName=MyFolder
 
zip -r $archiveName $folderName
June, 20 2009

Custom taxonomies in WordPress 2.8

A really good tutorial on building custom taxonomies in WordPress 2.8.

Custom taxonomies in WordPress 2.8

June, 18 2009

Wordpress permalinks best practices

Dougal Campbell wrote some interesting notes on permalinks structure and best practices in Wordpress.  Worth reading:

Efficient permalink strategies for WordPress – Dougal Campbell’s geek ramblings.

Writing text files using Java

This simple method shows hot to write to text files using Java.
If the file exists it will append the new text to it, otherwise it creates a new file. This is achieved using the FileWriter class and its constructor:

public FileWriter(String fileName, boolean append) throws IOException

Constructs a FileWriter object given a file name with a boolean indicating whether or not to append the data written. JavaDoc.

public void writeToFile(String text, String filePath){
 
  try {
 
    File thisFile = new File(filePath);
 
    BufferedWriter writer = new BufferedWriter(
                                new FileWriter(filePath, thisFile.exists()));
    writer.write( text );
    writer.newLine();
 
    writer.flush();
    writer.close();
 
  } catch (IOException e) {
    e.printStackTrace();
  }
}
June, 03 2009

Today Links