A coworker of mine has been keeping a blog with Typepad for several years now. As of recently he decided he wanted to switch to using WordPress on one of our servers. This is usually easy; you export your blog from the original site and import it using the appropriate plugin. WordPress provides great plugins for importing a blog from various other sources, so an import usually doesn’t require too much work. The current Typepad plugin has one big flaw though; it doesn’t import your photos! To make matters worse my coworker’s blog is a photography website with several hundred posts and even more photos. The photos are essentially stuck on Typepad’s servers since manually linking each picture through WordPress would be an incredibly grueling process.
I decided the only way to make this work was to modify the plugin and add the much needed image downloading functionality. Thanks to some of WordPress’ excellent building functions and a lightweight open source HTML parsing library I was able to do this with relative ease. Here’s how it works... Continue reading
Here’s an HTML5 experiment in progress…
This is just an experiment, the code was not optimized for performance, and I do not recommend using it for any projects, however I will post a working engine sometime in the near future.
I ended up doing this all in just under an hour, and I have to say it was pretty easy getting everything to work together. I have not included graphics yet, so for now everything being displayed on the screen is text. I mostly focused on collision detection and sprite movement. Via key presses the sprite will move either horizontally or vertically around the canvas. The sprite will also bump into the edges of the defined map using via the collision detection I wrote. Finally the sprite has been configured to handle parameters such as which direction it is facing, if it is standing still or moving, etc. I might expand these parameters down the road to support things like health or special behaviors.
The explanation of code is broken down into 4 main chunks: the environment, keyboard detection, sprites, and movement. Each code section has unique attributes and functions, and the environment section controls what is displayed on the canvas as well as refreshing and redrawing the canvas. Continue reading
There are a few examples within ESRI’s sample page, however I wanted to provide two examples outlining how I use the Query Task on a regular basis.
Example #1 shows how to use the Query Task’s where clause and pull data directly from a map service. ESRI’s provides a similar example, however it requires the user to submit a query within the page. My example allows you to have the query pre-canned and the results load with the page.
Example #2 takes this a step further and introduces the ability to access the same functionality via POST or GET. This is perfect for anyone interested in loading data into the page via URL variables (example2.php?name=Idaho) or perhaps someone that would like to call this function via AJAX.
I use example #2 all the time, so hopefully you’ll find it as useful as I do.
DOWNLOAD: EXAMPLES 1 & 2
*All data is provided via ESRI's hosted map services. Example 2 requires PHP.
Sometimes you wind up working on a page that switches back and forth between php and html. It can be tricky keeping track of code or making the mistake of over using the echo function. Luckily php supports an alternative syntax for control structures allowing you to jump in and out of php and html. Any code (html, php, anything) nested within a conditional will only parse if the defined conditions are matched. The end result is clean, organized, efficient code.
One of my interns once put all his html code into an array and printed each part while looping through function calls. It worked, but it his source code was so hard to read that when I asked him to take a look at it a few months later he couldn’t even make sense of what he wrote.
PHP's alternative control structure syntax makes it easy to identify code blocks and it’s widely used in many popular open source projects. Continue reading