Great New Web Resource

CoderZone.org launched recently.

It’s great new resource for web people, from ‘n00bs’ to ‘w00ts’. What makes it special:

  • A great team of moderators. These guys are experienced and know the web.
  • A library of code snippets, little bits of code that will save you a tremendous amount of time. You can contribute code, too.
  • XHTML/HTML & CSS sandboxes so you can test out ideas quickly.
  • An SQL sandbox for testing queries.
  • It’s free.
  • A very cool design.
  • No ads, the forum is there to help people, not distract you with ads you aren’t going to click on anyway.

bash ImageMagick Image Slicer

This is a bash script which accepts an image file, determines the width and height, and creates five vertical segments. It can be used to create a ‘puzzle’, tiles, CAPTCHA sequences and other interesting visual effects.

#!/bin/bash
if [ "$#" -le 2 ]; then
       echo "usage: $0 <base directory> <image file> <segments> [<imagemagick directory>]"
else
BASE_DIR="$1"
ORIGINAL_IMAGE="$2"
SEGMENTS="$3"
if [ "$#" -ge 4 ]; then
        IMAGEMAGICK_DIR="$4"
else
        IMAGEMAGICK_DIR=''
fi
RESIZED_IMAGE="image.jpg"
IMAGE_WIDTH=300
"$IMAGEMAGICK_DIR"convert "$BASE_DIR$ORIGINAL_IMAGE" -resize "$IMAGE_WIDTH"x +repage "$BASE_DIR$RESIZED_IMAGE"
IMAGE_DIMENSIONS=`"$IMAGEMAGICK_DIR"identify "$BASE_DIR$RESIZED_IMAGE" | cut -f 3 -d ' '`
SEGMENT_WIDTH=$((`echo "$IMAGE_DIMENSIONS" | cut -f 1 -d 'x'`/$SEGMENTS))
SEGMENT_HEIGHT=`echo "$IMAGE_DIMENSIONS" | cut -f 2 -d 'x'`
echo '<?php'
echo define\(\'SEGMENTS\',"$SEGMENTS"\)\;
echo define\(\'IMAGE_WIDTH\',"$IMAGE_WIDTH"\)\;
echo define\(\'IMAGE_HEIGHT\',"$SEGMENT_HEIGHT"\)\;
echo define\(\'SEGMENT_WIDTH\',"$SEGMENT_WIDTH"\)\;
echo define\(\'SEGMENT_HEIGHT\',"$SEGMENT_HEIGHT"\)\;
for A in `seq 0 $(($SEGMENTS-1))`
do
       SEGMENT_OFFSET=$(($SEGMENT_WIDTH * $A))
       "$IMAGEMAGICK_DIR"convert "$BASE_DIR$RESIZED_IMAGE" -crop "$SEGMENT_WIDTH"x"$SEGMENT_HEIGHT+$SEGMENT_OFFSET+0" "$BASE_DIR"segments/"$A".jpg
done
"$IMAGEMAGICK_DIR"convert "$BASE_DIR$RESIZED_IMAGE" -colorspace gray -level 0,80%,4.0 "$BASE_DIR"target.jpg
fi

The last convert command creates a a faded version of the image.

Further customization could include segmentation on a different axis, different image file formats, etc.

BlackBerry Web Development - SDK

BlackBerries now have a very cool widget development approach, you can build a web interface, run it through an SDK and it will create the widget or .cod file.

My goal was to learn, to see what it is, what it can do, and decide whether I can use it for some of my projects.

What is it? - I chose to use the command line version of the SDK, because I don’t use Eclipse or Visual Studio (which the SDK can plug into). I had to install some Java DK files as well, you can find references to them in the BlackBerry installation and set up documentation. I didn’t set up a path to the bbwp.exe, I used a relative path to reference it from the widget directories. Worked fine.

What can it do? - I saw the Widget SDK as a tool which would allow me to create cross-platform widgets, where a common core of code could provide key features, and device specific APIs would allow access to device stores such as the call logs, events, phone features, and audio. BlackBerry has an excellent API into those features, and I suspect it will be extended as this approach gains momentum. It’s an excellent balance of proprietary and custom features with a common access method. The two APIs I tested with audio and contact interfaces.

Can I use it? - Yes, but not yet. After I finished, I felt the greatest advantage was that it allows you to create a web application packaged as a widget. Potential issues include ensuring the widget version is updated to stay synchronized with the server, which would not be an issue if the code was delivered directly from a server. It does allow an off-line version. I had a general application in mind, and I think I would wait to see the system mature a little before building.

What I learned

  • It’s Windows based. I may be wrong, but it looks like you need a Microsoft machine for development.
  • It’s new. Everyone is still learning, and I would expect things to change.
  • It works. The process to assemble a widget with the SDK/widget packager does work without any surprises.
  • If it doesn’t work (meaning I made a mistake), it doesn’t work (meaning there aren’t any packaging or run time errors, it just doesn’t work.)
  • The command line packager process was not streamlined. My approach was the following:

    1. Use Windows Explorer to navigate to my widget source code directory
    2. Edit with Notepad
    3. Zip with 7Zip
    4. Navigate to the widget source directory on the command line
    5. Run bbwp.exe using a relative path to the executable
    6. Load the .cod file into the simulator (delete any existing versions first, or reset the simulator)
    7. Test
  • The .jar files referenced must be included in the .zip file prior to packaging. The documentation says to place them under the ext directory, and the ext directory has to be at the same level as the index.html and config.xmlfiles. Be sure to add them into the .zip file
  • A great appreciation for the approach. Although I’m not likely to use it (to me a Smartphone is just a phone, not worthy or in need of nifty software), it is definitely a revolutionary way to allow developers to support multiple devices with a core set of functionality. That said, adoption by other mobile device makers is necessary to make this of value. In all likelihood, there will be some common ground and some custom elements for every device. Innovative package assembly may make it possible to create platform independent applications and widgets. If that is the long range goal, the application architecture must be designed carefully, separating the core functionality from device specific interfaces.
  • Using Eclipse would probably speed the edit/test/revise cycle.
  • If I was a BlackBerry developer, I’d definitely test it out.
  • Audio file delivered through the browser to a BlackBerry are not cached on the device (http://docs.blackberry.com/en/developers/deliverables/5687/BlackBerry_Browser-4.7.0-US.pdf)

    Streamed content is not saved; users cannot replay media unless they download it again.

    This was a side trip.

  • SmartPhones will play an increasingly important role in content and application delivery, web applications should consider providing suitable interfaces for them.

http://www.blackberry.com/developers/docs/widgetapi/
http://docs.blackberry.com/en/developers/subcategories/?userType=21&category=BlackBerry+Widgets&subCategory=BlackBerry+Widget+Sample+Applications

Create Database with MySQL

If you don’t have phpMyAdmin, cPanel, or Plesk, you can SSH into the server and use the following commands:

create user dbuser@localhost identified by 'password';
create database db;
grant all on db.* to dbuser@localhost;

mysql -udbuser db -p

Content Feeds - Facebook and Twitter - Source, Sink or Both?

Facebook and Twitter have become integral parts of web marketing and outreach. Many companies use them in innovative ways to reach people.

Twitter - Twitter is an extremely efficient distribution medium. Tweets are easy to issue from a phone, laptop or desktop. In seconds, you can share a message. The value of the message is directly related to the content. If the message is ‘the service is back up, we’re sorry for the outage’, your clients will be relieved and happy to receive it. An alert that you posted substantial content for review may not be as welcome, unless you are a news service. Take the time to determine where site visitors are coming from for whitepapers and videos to decide whether to post that type of information. This is vital, because diluting a twitter feed with content people aren’t interested in will reduce its effectiveness. Your tweets will be dismissed without even being read. If you aren’t a realtime, high energy organization, twitter may not be a good tool.

Facebook - Facebook is powerful because people can select to receive your posted content, and it allows more content to be posted. Thus, facebook content is distributed within a community that is choosing specifically to follow you. Examining the site stats and facebook participation can help you to decide whether to invest the time in creating and managing a facebook presence or to push content from your site into facebook.

Twitter and Facebook help you reach people, but they also dilute posted content by surrounding it with unrelated material, which may be more interesting than yours.

An excellent approach is to invest in high quality content on your site which engages visitors by assisting them. Do your products and services save people and organizations money? Show them how with a calculator that they can use. The output should be easy to understand, include plenty of explanation, and, if appropriate graph or plot the data for a quick visual assessment. If possible, include comparisons and adjustments to allow further analysis. Explain the services you offer, if you can’t explain them concisely, consider changing them until you can. Educate site visitors with whitepapers, but only if it is informative, not advertising. Posting videos on your site, or sourcing them from YouTube is good, but only if the videos are well done. Well done may mean funny, creative, or entertaining, as well as informative. Video is primarily an entertainment media, many people want to be amused as they receive your message.

The site content will draw visitors from search engines, they will stay on the site if it has value, answering their questions, or entertaining them.

The home page of the site should include a ‘new content’ feed, and the same feed should be filtered out to facebook and twitter if appropriate. Sourcing facebook and twitter content on your home page will filter out unrelated posts, but, once people are on your site - the facebook and twitter content may not justify the page space it consumes. A link so people can connect into those resources is often better.