Blog
12090th since April 04, 2007
R
Jul 19, 2008 ( Saturday )
( 29 )
bash to automate generating thumbnails
 Generating a thumbnail from the original image is not hard, just read the command-line options for Linux convert command (frontend for ImageMagick). While batch handling over 1M images files at one shot need some scripts. This is where bash kicks in and make your life easier. Below is a short bash script I wrote last night which worked perfectly for my work:

#!/bin/bash
# Usage : ./mkthumb.sh

imagedir=/data/pictures
thumbdir=/data/thumbnails

find "$imagedir" -type f -print | while IFS='\n' read -r image; do
    thumb=${image/$imagedir/$thumbdir}
    thumbfiledir=${thumb%/*}
    if ! [ -d "$thumbfiledir" ]; then
        mkdir -p "$thumbfiledir"
    fi
    echo " |-- $(( i++ )) converting '$image' to '$thumb'"
    convert "$image" -thumbnail 120 "$thumb"
done


and then run it as follows:

bash~ ./mkthumb.sh >20080718.thumbnail.log 2>20080718.thumbnail.err &
bash~ tail -f 20080718.thumbnail.log

...More
Add tags: automation bash

by xicheng
10:41:53 | Add a comment | Read article
Feb 1, 2008 ( Friday )
( 214 )
Auto rotation for "Monthly archives"
 Records in Monthly archives box of the right-hand-side toolboxes are influenced only by the "Insert" and "Delete" operations of blog entries. currently the result are saved in the MemoryCache, to update the results and make it rotate automatically, only two lines of code are needed.

my $cache = myweb_get_cached_obj_from_memory();
$cache->remove('_cached_monthly_archive');

huh, so simple. I used to update these at some specific time on the first day of each month which is stupid and often get me '0' record for a specific time period.. :-(

Sometimes we have to learn thinking from the other way around. :-)
...More
Add tags: Cache

by xicheng
03:29:21 | Add a comment | Read article
Jan 30, 2008 ( Wednesday )
( 185 )
Update with "Photo Album" page
 (1) switched most hyperlinks to AJAX calls, so instead of changing the whole webpage, only photo image and its corresponding title are refreshed when clicking the listed photo hyperlink.

    Photo Album

the jQuery function used is pretty simple:

function showphoto(pid) {
    $.getJSON('/photos/showphoto.html', { p : pid }, function(sdata) {
        $('div#photo').html(sdata.image);
        $('h1#photoTitle').html(sdata.title);
    });
}


(2) removed some mouseover event settings of toggling hide/show of photo list.. many of them are kind of annoying.
...More
Add tags: AJAX jQuery Photo

by xicheng
23:16:08 | Add a comment | Read article and comments(2)
Jan 29, 2008 ( Tuesday )
( 216 )
My WBEditor
 Inspired by Alex Brem's fieldSelection jQuery plugin, I began to make my own WBEditor(WebBlogEntry editor), see the following plot or a GIF demo (2.9MB):



Currently, five typies of buttons are available:
 1) Fonts: B(bold), U(underline), I(italic)
 2) Links: a(link)
 3) Multi-medias: wmv(movie), wma(audio), img(image)
 4) Find: string search in the textarea
 5) Undo, redo: (maximum 10 times)

Also added some validations from the server-side code(MyApp::Regex.pm)

Still in experimental stage (only contains some basic <c /> tags).
...More
Add tags: blog jQuery site WBEditor

by xicheng
00:49:47 | Add a comment | Read article and comments(2)
More entries: 1 2 3 4 5 6 7 8 9 10 Next » End