Friday, March 19, 2010

Getting data from HTML

I had this issue on an old project.

The problem was how do I pull data from html easily. I found a tool on the gotdotnet website to do this. You can now find it here http://code.msdn.microsoft.com/SgmlReader.

This takes in html and outputs valid xml. Now all you have to do is work with xml.

Simple enough.

Monday, March 8, 2010

Easy way to scale images

Goal: A bucket full of images from Bike week to upload to Flikr.

Issue: Images are to big to upload.

Solution 1: edit each pic manually.

Solution 2: script scaling.

I went with Solution 2.
  1. Installed Imagemagick ( exe
  2. I have cygwin to script, you'll need it.
  3. create script in directory with images:
  4. Run script.
Script:
#!/bin/bash

for i in `ls *.JPG`;
do
n=`echo $i| awk -F "." '{print $1"a."$2}'`
echo $n
/cygdrive/c/Program\ Files/ImageMagick-XXXX/convert.exe $i -scale 800x600 $n
done


That is it. This will convert all JPG files in directory to 800 x 600, creating a copy with an 'a' in the name.

You are welcome. :)

Monday, March 1, 2010

AJAX JSON Information Fetch


Need a web page which fetches information given some arguments from a web service? here you go.

  • Web Service reference 
  • JavaScript
  • Web Service

Address:
City:
State:
Zip: