Category — Blogging
How To: Replace a Partial String in MySQL
When developing web sites, sometimes things change from how they were in development to how they need to be in production, especially when it comes to machine names and IP addresses, etc. If these values are stored in a database, chances are you’ll need some quick SQL magic to help finalize the migration.
For those of you that just want the info, here you go. This is a quick and easy way to directly replace one string with another for all rows in a column/field. DISCLAIMER: If you don’t know what you are doing, you can really screw up your database. Please take care to do a backup and by all means, if you can’t fix what you break, don’t attempt this.
UPDATE MyDB.MyTable
SET MyDB.MyTable
= REPLACE(MyDB.MyTable.MyField,'OldString','NewString')
WHERE MyDB.MyTable.MyField like '%OldString%';
January 1, 2009 2 Comments
Support Wikipedia
Have you ever used Wikipedia? I do - all the time.
If you don’t contribute articles, information or services to them in direct proportion to your usage, please consider giving a small donation to help them stay afloat and advertisement free.
Wikipedia has changed the face of collective global information. While it certainly has some flaws, the overall benefit to humanity is quite considerable. Do your part and pitch in where you can!
December 31, 2008 No Comments
WordPress Plugin Generator
This is a neat tool if you like to mess around with WordPress Plugins.
Its a Plugin Generator that will generate a customized code skeleton for your newest plugin idea - pretty neat!
The little web app asks you a bunch of questions, like what the plug in should be named, does it require saved settings, etc. and then it spits out a tidy zip file that contains a new plugin.php file along with any other files that are required based upon your answers. It supports a number of neat options, like making a new DB table, Shortcodes, Filters, Admin Menu Integration, etc.
Of course, the resulting code doesn’t DO very much - its just the structure that you need to make a plugin. You have to add the actual functionality with your coding wizardry. Still, this is a nice way to make sure that you’ve covered all your bases when writing a new plugin. It simply shortcuts the process of Idea -> Reality, which is always welcome in my book.
Check it out!
UPDATE: Check out the new URL: http://www.funwithwizards.com/ for the latest version and some other cool tools!
WordPress Plugin Generator December 15, 2008 2 Comments
Postcasa Accepted on WordPress.org!
My Postcasa plugin for WordPress for easily embedding Picasa slideshows in your blog has officially been accepted at the WordPress Plugin Database and will be hosted there from now on.
Of course, you can always access the latest information on my local Postcasa Page but you can also visit its official Plugin Page hosted at the WordPress Codex. Now that it is officially hosted there, you’ll also be able to automatically update the plugin from within Wordpress as new versions are released. Pretty cool stuff!
Dang, how I love WordPress!
WordPress Plugin, Picasa, Postcasa, Shortcode December 3, 2008 3 Comments
A New Way to Put Picasa Slideshows in Wordpress
My original post on this topic got a lot of traffic, so it seems that people are interested in this topic.
As a result, I’ve written a new Wordpress plugin called Postcasa to help people add a simple Picasa Slideshows inline to their posts.
It is extremely simple to use. All you have to do is put the Picasa RSS link between this simple shortcode, and the plugin does the rest.
Example:
[postcasa]http://MyRSSurl[/postcasa]
easily becomes:
Head on over to the Postcasa homepage to get the code and peruse the options! Adding Picasa slideshows to your posts has never been easier!
Examples of what’s possible:
[postcasa size=small]http://MyRSSurl[/postcasa]
[postcasa width=100 height=100 align=center]http://MyRSSurl[/postcasa]
[postcasa size=small align=right bgcolor=0fb2c3 showcaptions=yes]http://MyRSSurl[/postcasa]
wordpress, Picasa, web development November 26, 2008 No Comments
WPTouch: A Custom Wordpress Theme for the iPhone Browser
With the use of the iPhone and iPod Touch growing every day, maybe it makes sense to have a special view of your blog optimized for their included browser.
The iPhone and iPod Touch web browsing feature is pretty neat (from what I’ve seen), yet a full sized blog site is still a bit hard to see even in horizontal mode.
Enter WPtouch.
WPtouch formats your Wordpress blog with an iPhone specific (and reminiscent) theme, complete with Ajax loading articles and effects. The theme only appears to users who are viewing your online masterpiece from an iPhone or iPod touch.
Of course, it can only go so far - Flash, etc still won’t work on the iPhone. Shame on you two, Adobe and Apple. Can’t you work your crap out and stop screwing up the world this way?
Anyway, I digress. Installation of WPtouch is a snap: simply upload the plugin folder to your webhost and enable it from Admin’s plugin screen. After it is enabled, you can cruise on over to the Admin Settings -> WPtouch screen to set the various options that the theme supports. Settings include the icons you want the theme to use verification of certain compatibility issues with the plugin’s capabilities. Once you are satisfied, simply save your options to fully enable the new theme.
Easy-peasy.
Taking your new look and feel for a spin however is a different matter completely. While there are some iPhone emulators out there, only one that I know of semi-accurately mimics the actual web browser by making an iPhone User Agent setting available. This is essential to actually see the changes that WPtouch makes to your blog.
The problem is that to use the accurate emulator requires using a Mac. If you happen to be one of the enlightened few (haha, cool your jets, I’m writing this on a PC!) cruise on over and download iPhoney, a nifty little Mac app that allows you to emulate the iPhone right from your desktop. You can even “rotate” the phone to see what landscape view looks like. Pretty neat!
Sorry - PC users need not apply. If you have nary a measly hunk of Cupertino Lovin’ readily available for use, try iPhoneTester instead. Not as cool (no user agent switching, etc.), but it gives you an idea of what your regular theme will look like on the iPhone. Even with this, for the full experience, you’ll need Safari on your PC. Yes, I did just say that.
Of course, if you are an Apple Fanboy who ISN’T locked into a long term relationship for RIM Blackberry devices and therefore addicted to free-basing their direct push MS-Exchange crack, you can just fork over yer cash and get a darn iPhone. Lucky buggers. Last option is to bug one of your cooler friends to let you borrow their iPhone. Who knows, you may even get a subscriber out of the deal!
Either way, remember that your normal theme will still be the go-to look for all other browsers, so if you surf back to your blog from your normal Firefox, IE or Chrome, it should all look as it did sans-WPtouch. Only the iPhone and iPod Touch users will see the new theme. WPtouch even gives them the option to switch back to your normal theme if for some reason that is preferable.
Overall, this is a great idea for a Wordpress plugin and I’m fairly impressed with the apparent quality of the software. It seems very professional, is easy to use and did what it was supposed to do on the first try. In my book, that goes a long way, and always will!
I’ll post again with any other info as it become apparent.
In the meantime - a big shout out to Dale and Duane for their great work!
Web Development, Wordpress, Wordpress plugin, iPhone, iPod Touch November 24, 2008 No Comments
Having PHP Problems With JSON and file_get_contents()?
Chances are your webhost doesn’t allow this type of access for security reasons.
If you are even remotely handy with PHP, there is a very simple fix: Using CURL.
First, open the PHP file that is giving you the problem (make a backup of the original, just in case!).
Second, add this function to the file (make sure you do it outside of any other function definitions, and preferebly before you use it in the rest of the file…):
// function to replace file_get_contents()
function new_get_file_contents($url) {
$ch = curl_init();
$timeout = 10; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_ e x e c($ch); // take out the spaces of curl statement!!
curl_close($ch);
return $file_contents;
}
Then, search through your file for “file_get_contents” and then replace those words with “new_get_file_contents”. In a nutshell, you are replacing the original function that doesn’t work on your webhost (file_get_contents() ) with one that WILL work on your host (new_get_file_contents() ).
I usually leave a commented out copy the original line in the source, so that I can easily go back to the original if necessary.
So, for example:
$myVar = file_get_contents($url);
becomes:
// $myVar = file_get_contents($url);
$myVar = new_file_get_contents($url);
Pretty easy! I’m not sure that this will work in all situations, but I have yet to find a place where it doesn’t work. I was easily able to replace file_get_contents() with CURL in about 5 minutes in altPWA, an excellent Wordpress Plugin for adding Picasa photos and albums to your blog.
Nice and easy!
Wordpress, web development, PHP, CURL, file_get_contents, JSON November 22, 2008 No Comments








