CartMetrix - Do you know yours?

5/15/2007

Adding Human Readable Date to MySQL Query

SELECT *, FROM_UNIXTIME( 't_stamp_column') AS date FROM 'tablename'

For formatting the date see MySQL's date functions information.

Popularity: 19%

5/7/2007

Qmailscan Report

more /var/spool/qmailscan/quarantine.log | grep “`date ‘+%d %b %Y’`” | cut -f5 | sort | uniq -c | sort

Popularity: 16%

5/4/2007

Centering a Page with CSS

Add this to your stylesheet:

body    {
        text-align: center;
}

div#main        {
        margin: 10px auto;
        width: 600px;   
        text-align: left;
}

Use this for the page body:

<body>
<div id=“main”>

… main body html …

</div>
</body>

Popularity: 12%

4/9/2007

Wordpress Hack to Debug Themes on a Live Site

How can a Wordpress them be debugged privately without showing the wizard behind the curtain to everyone else? This simple hack will use the specified theme only for one remote IP... yours. This can be used when creating a new theme by configuring Wordpress to present the original theme and specifying your new theme in development in place of THEME_NAME below. Also replace YOUR_IP_ADDR with your local IP address. THEME_NAME must be an existing theme directory in wp-content/themes/.

To debug an existing theme, copy your theme directory to a new directory under /themes/ (maybe THEME_NAME-dev). Leave Wordpress configured to serve the original theme at THEME_NAME and configure the hack to serve THEME_NAME-dev to your IP address.

Edit wordpress/wp-includes/theme.php as below:

Before

function get_template() {
   return apply_filters('template', get_option('template'));
}

After

function get_template() {
if($_SERVER['REMOTE_ADDR'] == 'YOUR_IP_ADDR')   {
   return 'THEME_NAME';
}
   return apply_filters('template', get_option('template'));
}

Depending on how the template links to it's stylesheet, the get_stylesheet() function (in the same file) may need a similar hack:

Before

function get_stylesheet() {
   return apply_filters('stylesheet', get_option('stylesheet'));
}

After

function get_stylesheet() {
if($_SERVER['REMOTE_ADDR'] == 'YOUR_IP_ADDR')   {
   return 'THEME_NAME';
}
   return apply_filters('stylesheet', get_option('stylesheet'));
}

This will not work with a private IP address like 192.168.x.x or 10.10.x.x. The IP must be the external address of your router or firewall. To find your external IP address use this link:
http://emailurl.com/myip

Also remember that if you change local IP addresses, you need to update the IP address configured in the snippet above. Most DSL/cable connections use a dynamic IP address that changes every few hours or daily.

Once the theme is good to go, merge the changes into the live template and comment out the code to disable the hack.

Popularity: 24%

3/20/2007

Selecting Filenames with Non-Standard Characters in the Filename from the Shell

An erroneous cut and paste in an iTerm left me with a group of empty files named after hex color codes.

-rw-r--r-- 1 root root 0 Mar 20 16:54 #ffffb0,
-rw-r--r-- 1 root root 0 Mar 20 16:54 #ffd850,
-rw-r--r-- 1 root root 0 Mar 20 16:54 #ff50a8,
-rw-r--r-- 1 root root 0 Mar 20 16:54 #cceedd,
-rw-r--r-- 1 root root 0 Mar 20 16:54 #c8c8ff,

Trying to delete them provided a little bit of a problem:

[root@atlas bugs]# rm #*
rm: too few arguments
Try `rm --help' for more information.

The problem was the pound (#) character, the initial character in the filenames.

A little trial and error and I remembered a trick from my DOS day and working with long file names:

[root@atlas bugs]# rm "#"*
rm: remove regular empty file '#c8c8ff,'? y
rm: remove regular empty file '#cceedd,'? y
rm: remove regular empty file '#ff50a8,'? y
rm: remove regular empty file '#ffd850,'? y
rm: remove regular empty file '#ffffb0,'? y

Quoting the entire string "#*" won't work because of globbing the quotes make the asterisk part of the string and are never expanded.

Popularity: 21%

3/6/2007

SVN Tips

To create a new repository at: /home/damonp/svn/project1/

svnadmin create /home/damonp/svn/project1/

Import original source

svn import  project1/ file:///home/damonp/svn/project1/

To get a working copy move original source tree out of the way and checkout the project

svn checkout file:///home/damonp/svn/project1/ project1/

Set keyword properties so source file keyewords will be updated on commit

svn propset -R svn:keywords "LastChangedDate Author Id" project1/*

Commit changes

svn commit project1/

Popularity: 8%

« Previous Page Next Page »


damonparker.org is proudly powered by WordPress
Entries (RSS) and Comments (RSS).

copyright © 2002-2008 damonparker.org. all rights reserved.

Close
E-mail It