Unfortunately Microsoft over the years has left us disappointed year after year with their web browser Internet Explorer. Yes, I know we all have had frustration with the little quirks that all browsers have but Internet Explorer has been the bane of the web developer. IE 8 like previous incarnations appears at first to be step up until you look closely and notice the issues with its animation rendering capability.
Anyhow enough rambling, Recently I came across a nifty little meta tag that IE 8 supports that tells it to render the page content as IE 7 would. Quickly and easily removing any quirks introduced to your website that are IE 8 specific. Now instead of 2 or 3 version of IE that you need to support you are back down to simply IE 7 or if you are one of the unfortunate ones, IE 6 as well.
<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible">
Enjoy, and here is to hoping that for IE 9 they do a full rewrite of this web browser known as Internet Explorer
IE7, IE8, Internet Explorer, META, X-UA-Compatible
When developing within a large web application it may be needed to check if a JavaScript function/object exists prior to being calling. The benefits to checking if the method exists are:
- No JavaScript errors are Generated.
- if needed you can dynamically load and initialize your method or object
In most cases you won’t need to test for a function but in the rare cases that you find yourself not sure of what has been loaded into the DOM (Document Object Model) you can check by simply calling window.methodName. By wrapping it in a if statement it will let you know if the method exists.
if( window.methodname ) {
// method exists
} else {
// method does not exist
function methodName() {
}
}
Exists, Javascript
Ever find yourself wanting to create a custom feed of your WordPress managed website? Lucky for you they have the handy add_feed hook that allows you to define as many feeds as you want, Just be careful not to duplicate any existing feeds. I personally find myself using this feature to output xml of data that I then utilize in Flash presentations. The add_feed function works like all other WordPress hooks in that it calls the user defined function when the named feed is to be rendered.
For illustration purposes lets walk through the basic steps for creating a Custom Feed.
Define a function to output the xml
Before adding the feed you first need to define the function that will render the xml to be returned when the feed is called. Depending on your needs you can define this in a custom plugin or in the functions file of your theme. The below snippet outputs your posts in a basic xml structure.
function outputXMLFeed()
{
$posts = query_posts('showposts=5');
echo '<?xml version="1.0"?>';
echo '<items>';
foreach ($posts as $post) {
echo '<item>';
echo '<title>' . get_the_title($post->ID) . '</title>';
echo '<link>' . permalink($post->ID) . '</link>';
echo '<guid>' . get_permalink($post->ID) . '</guid>';
echo '</item>';
}
echo '</items>';
}
Add the feed to WordPress
Now to add the feed we simply need to call add_feed where we pass in the name of the feed and the function that will output the feed contents (xml). One caveat exists however in that WordPress needs to be fully initialized before the add_feed function can be called. This forces us to wrap up the add_feed call behind another function that gets called on the WordPress init hook.
add_action('init', 'add_my_feed');
function add_my_feed( ) {
add_feed("myFeed", "outputXMLFeed");
}
Calling your Custom Feed
To access your feed you simply need to append ?feed=Name of your Feed to your site’s url. In this case the final url would be http://www.example.com/?feed=myFeed
That is all there is to creating your custom feeds. Depending on your needs you can create them in your theme functions or in a standalone plugin. If you are using additional plugins like Pods CMS then feeds can be extremely useful in rendering pods contents into xml for use by Flash, JavaScript or other applications.
Feed, Plugin, Wordpress, WP, XML
One issue that I always come across when creating a shell script is referencing files dynamically based on the location of the shell script. A hack I often used was to pass the script’s path to the script on execution because the readlink command was not available to me. However recently I have revisited this issue and have found a solution for obtaining the absolute path of the executing shell script without readlink. For your convenience both scripts are found below.
Absolute Path using readlink
#!/bin/sh
PATH= $(dirname $(readlink -f $0))
echo ${PATH}
Absolute Path without using readlink
#!/bin/sh
ORIGINAL_PATH=`pwd`
cd "`dirname ${0}`"
PATH=`pwd`
cd "${ORIGINAL_PATH}"
echo ${PATH}
absolute path, pwd, readlink, Shell Script, Tips & Tricks, Unix
One of the main maintenance issues with running a Java application from a shell script is keeping your classpath up-to-date with the new and updated jars. To make things more difficult you can’t specify a folder as the classpath as it doesn’t include the jars in it only .class files. However through the use of a basic for loop we are able to dynamically generate the classpath.
CP=
for i in `ls ./lib/*.jar`
do
CP=${CP}:${i}
done
-cp, bash, Classpath, Java, Shell Script, Tips & Tricks, Unix