La Vita è Bella

Wednesday, March 21, 2007

Bash script: batch resize your photos

If you toke some photos by your camera, and want to post them to somewhere (for example, I want to post the photo of my Treo 650 because I'm going to sell it), you may need to batch resize your photos.

This bash script shows how to uses ImageMagick to batch resize your photos:

1 #!/bin/sh
2
3 for file in *.JPG; do
4         convert -resize 1024x768 $file ${file%.JPG}_resize.jpg
5 done



tags: , , , ,

21:28:36 by fishy - linux - Permanent Link

1 comment - no trackbacks yet - karma: 2 [+/-]

Tuesday, March 20, 2007

Note: set proxy for wget

wget -Y -e "http_proxy=host:port" url

"How to set proxy for wget?" I've been asked this question for many times, but it seems didn't appears in the "-h" output nor man page, so I always forgot it.

That's why I'm making a note here :)



tags: , , ,

00:42:01 by fishy - linux - Permanent Link

4 comments - no trackbacks yet - karma: 10 [+/-]

Sunday, March 11, 2007

My first ever Obj-C hack: Google Reader Notifier

UPDATED: Troels Bay have use another way to do it, please wait for his official build :P

Google Reader Notifier by Troels Bay is a great open source application that provide a desktop notifier for Google Reader, the online feed reader, and also a feed subscriber. As I'm using Camino as my browser, which didn't have a build-in RSS support, I need it even more to subscribe feeds to Google Reader with one click. (not just "notifier" :D )

But when subscribe with preview, if there's a "?" in the URL, the problem is that Google Reader will ignore the part after "?". So that for example my photos on Flickr, "http://api.flickr.com/services/feeds/photos_public.gne?id=76236359@N00&format=rss_200" , will be recognised by Google as "http://api.flickr.com/services/feeds/photos_public.gne".

So I wrote this patch to escape URL before submit to Google.

 1 --- Google Reader copy/GRController.m   2007-03-11 18:45:56.000000000 +0800
 2 +++ Google Reader/GRController.m        2007-03-11 18:49:46.000000000 +0800
 3 @@ -1610,7 +1610,15 @@
 4  
 5         if ([[prefs valueForKey:@"dontVerifySubscription"] boolValue] != YES) {
 6  
 7 -               [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[[NSString stringWithFormat:@"%@://www.google.com/reader/preview/*/feed/", [self getURLPrefix]] stringByAppendingString:url]]];                    
 8 +               NSMutableString * escapedUrl = [NSMutableString stringWithCapacity: ([url length]*3)];   // for the worst case the length will growth to 3 times
 9 +               [escapedUrl setString:url];
10 +               [escapedUrl replaceOccurrencesOfString:@"?" withString:@"%3F" options:0 range:NSMakeRange(0, [escapedUrl length])];
11 +               [escapedUrl replaceOccurrencesOfString:@"&" withString:@"%26" options:0 range:NSMakeRange(0, [escapedUrl length])];
12 +               [escapedUrl replaceOccurrencesOfString:@":" withString:@"%3A" options:0 range:NSMakeRange(0, [escapedUrl length])];
13 +               [escapedUrl replaceOccurrencesOfString:@"/" withString:@"%2F" options:0 range:NSMakeRange(0, [escapedUrl length])];
14 +               [escapedUrl replaceOccurrencesOfString:@"=" withString:@"%3D" options:0 range:NSMakeRange(0, [escapedUrl length])];
15 +
16 +               [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[[NSString stringWithFormat:@"%@://www.google.com/reader/preview/*/feed/", [self getURLPrefix]] stringByAppendingString:escapedUrl]]];                      
17                         
18         } else {
19  



tags: , , , , ,

21:13:23 by fishy - opensource - Permanent Link

no comments yet - no trackbacks yet - karma: 7 [+/-]

Friday, March 02, 2007

Some (not so many) handy aliases

Under my Debian Linux, when I use screen, I always get some keymap/TERM setting problems, for example, the backspace key never work.

But if I set TERM to "vt100" before launch screen, it's OK, so this alias can resolve the problem:

alias screen='env TERM=vt100 screen'

For the poor network, I always need a multi-thread http downloader. Firefox has a extension DownThemAll!, but after I finish surfing websites (but didn't finish downloading yet), I used to press Command+Q to quit Firefox, and the download was interrupted. lftp has a built-in downloader: pget, so use pget is a good idea:

alias pget="lftp -c pget"

Put the codes into your bashrc file, and restart your terminal, it's done.



tags: , , , ,

21:25:26 by fishy - linux - Permanent Link

1 comment - no trackbacks yet - karma: 7 [+/-]

May the Force be with you. RAmen