Image Gallery Revamped

The image gallery has been revamped to fit into the new iframe structure of our version 3 site. To check it out, click on the “Archives” link, then “image” link in the sidebar nav.

The animations utilize the Javascript Motion Tween classes written by Philippe Maegerman from Brussels, Belgium. Thanks, Pim!

Links

jstween.blogspot.com

Some Good WordPress Hacks

Impact sent us a link to this article about some useful WordPress hacks:
http://www.smashingmagazine.com/2009/04/15/10-exceptional-wordpress-hacks/

The ninth entry, “Highlight Searched Text In Search Results” is a tiny code snippet god-send if you are regular expression illiterate like us:

<?php
$content = nl2br ( strip_tags ( get_the_content ( __( 'more…' ) ) ) );
$keys = explode ( " ", $s );
$content = preg_replace ( "/(" . implode ( "|", $keys ) . ")/iu",

'<strong class="search-excerpt">\0</strong>',
$content);

?>

Works like a champ!

There is also another helpful trick in this article. Up at number four, “Create A Maintenance Page For Your WordPress Blog”. This one is an .htaccess modification to keep visitors from seeing your site while you are making updates…

RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$
RewriteCond %{REMOTE_ADDR} !^123\.123\.123\.123
RewriteRule $ /maintenance.html [R=302,L]

Replace the IP Address with yours and you’ll be able to see your pages but everyone else will get redirected to the maintenance.html page. Brilliant!

Callback Format for FuseKit

clip.slideTo ( x_value, y_value, duration, easing, delay, callback );

Where callback is structure as follows:

clip.slideTo ( […], { scope:this, func:”function_name”, args:argvalue } );

To send multiple args values, send as an array

MixBlendr

A new Java-based application for mixing audio tracks right in your web browser has just launched. MixBlendr is open source and available for download to use on your own website. Right now they have a contest running until April 9, 2009 for best mix of the tracks they posted on their site.

Check it out: mixblendr.com

WordPress Migration with MySQL

We need to move a WordPress 2.7 install from a development domain to the live environment via straight FTP transfer and phpMyAdmin dump. We bypass the Export / Import functions in WordPress admin so that we can preserve our myriad plugin settings when making the domain switch. But now our links are all pointing at the old URL and the upload path is all wonky. WTF? Fear not, you can fix all those problems by running this tasty little SQL script on your WordPress database via phpMyAdmin (don’t forget to replace the values with the appropriate values for your environment):

## — replace absolute URLs that point to the old domain
UPDATE wp_posts

SET guid = REPLACE ( guid, ‘www.oldsite.com’, ‘www.newsite.com’ )
WHERE guid LIKE ‘%www.oldsite.com%’
;

UPDATE wp_posts

SET post_content = REPLACE ( post_content, ‘www.oldsite.com’, ‘www.newsite.com’ )
WHERE post_content LIKE ‘%www.oldsite.com%’
;

UPDATE wp_options

SET option_value = REPLACE ( option_value, ‘www.oldsite.com’, ‘www.newsite.com’ )
WHERE option_value LIKE ‘%www.oldsite.com%’
;

## — replace absolute server paths
UPDATE wp_options

SET option_value = REPLACE ( option_value, ‘/old/server/path/’, ‘/new/server/path/’ )
WHERE option_value LIKE ‘%/old/server/path/%’
;

UPDATE wp_postmeta

SET meta_value = REPLACE ( meta_value, ‘/old/server/path/’, ‘/new/server/path/’ )
WHERE meta_value LIKE ‘%/old/server/path/%’
;

SMS Stats

SMS text messaging is the most widely used data application on the planet, with 2.4 billion active users, or 74% of all mobile phone subscribers sending and receiving text messages on their phones.

en.wikipedia.org 2009.01

Handling large mysqldump import with PHP

Client’s intranet is on an Apache / Windows box on the other side of the continent and we needed a quick way to synch up our development environment with theirs. Their database has been accumulating production data for over 36 months and the filesize of the export from phpMyAdmin reads 11.7MB. To avoid manual export from phpMyAdmin, we used the PHP system function to automate creation of the dump file as follows:

$cmd     =     “\path\to\mysql\bin\mysqldump.exe ”

.    “–skip-extended-insert ”
.    “–skip-add-locks ”
.    “–skip-add-drop-table ”
.    “–skip-set-charset ”
.    “–skip-comments ”
.    “–result-file=$filepath/$dump_filename -r $filepath/$dump_filename ”
.    “–user dbusername ”
.    “–password=dbpassword ”
.    “dbname”
;

system ( $cmd );

The resulting dump file from mysqldump is 15.4MB. We couldn’t use phpMyAdmin to import w/out suffering through several timeouts before the import was completed. What to do? We found this amazing script by Alexey Ozerov: BigDump

The BigDump script basically times itself out every 2 to 3 seconds (configurable) and restarts the dump where it left off from the previous import. It has a progress bar so you get visual status on the import.

Links

system: PHP function for CLI executable.
phpMyAdmin: PHP based MySQL administrative tools.
mysqldump: MySQL database backup program.
BigDump PHP script: awesome script that assists in huge dump file imports via http.
Notepad++: Windows text editor that preserves carriage return or line feed (CRLF, \r\n) format of the original document. Really helpful when editing a dump file created for use with BigDump.

Clearing Browser Cache

Update 2010.07.09: wikiHow has a great article on clearing browser cache.

Internet Explorer 6:

Tools (menu) -> Internet Options (menu) ->
Internet Options (control panel) -> General (tab) ->
Temporary Internet Files -> Delete Files (button) ->
OK (button)

Internet Explorer 7:

Tools (menu) -> Delete Browsing History (menu) ->
Temporary Internet Files -> Delete Files (button) -> Yes (button)

Firefox 2:

Tools (menu) -> Clear Private Data (menu) ->
Cache (checkbox) -> Clear Private Data Now (button)

Firefox 3:

Tools (menu) -> Clear Recent History (menu)
Time Range -> Everything (select menu)
Details -> Cache (checkbox)
OK (button)

Safari:

Safari (menu) -> Empty Cache (menu) -> Empty (button)

For more information on web cache: wikipedia.org/Web_cache

Email to SMS

Trying to figure out how to email a grocery list to our street team, we ran across this list of major US cell phone providers and how to format emails to send text messages:

Provider Email Format
Alltel: {number}@message.alltel.com
AT&T: {number}@mms.att.net
Nextel: {number}@messaging.nextel.com
Sprint: {number}@messaging.sprintpcs.com
Suncom: {number}@tms.suncom.com
T-mobile: {number}@tmomail.net
Voicestream: {number}@voicestream.net
Verizon (text only): {number}@vtext.com
Verizon (pics and vids): {number}@vzwpix.com

Replace the {number} with the 10 digit phone number of our recipient and now we can hand down our directives to the street team without ever picking up the cellie. Booyah!

Apply Dynamic Style to a Class

We recently needed to create an HTML page and dynamically hide/show an entire class of <div> tags that were interspersed throughout the page. Using the getElementsByTagName javascript method, we were able to iterate over all of the <div> elements in the document. Then check the CSS class by accessing the className DOM element:

oDivs = document.getElementsByTagName ( “div” );
for ( d = 0;  d < oDivs.length;  d++ ) {

// cl_name = oDivs[ d ].getAttribute ( “class” ); // does NOT work in IE
cl_name = oDivs[ d ].className;
if ( cl_name == “bio” ) {

oDivs[ d ].style.display = “none”;

}

}

Note that the getAttribute method does not work in IE since class is a reserved word for IE. Took us a little while to figure that one out.