Here are the steps:
1. Go to http://downloads.jmagick.org/6.3.9/.
2. Download ImageMagick-6.3.9-0-Q16-windows-dll.exe and install. The PATH environment variable should be updated with the install directory.
3. Download jmagick-win-6.3.9-Q16.zip and unzip. The directory contains jmagick.jar and jmagick.dll. You may move both files subject to #4 and #5.
4. Make sure jmagick.jar is in the Java classpath.
5. Make sure your VM arguments (e.g. in Eclipse or from the command line) contain a pointer to the directory containing jmagick.dll. E.g. -Djava.library.path=C:/dcs/tools/jmagick-win-6.3.9-Q16.
Monday, October 27, 2008
Wednesday, September 10, 2008
A safer way to iterate over arrays in JavaScript
We'd had a piece of JavaScript that iterated over an array using the "for (var x in arr)" syntax working fine, until... we included json.js into the file. The trouble began... You see, json.js extends all arrays by tacking an extra key => value pair as the array's last element. The key is something like "toJSONString" and the value is a function which converts the object into a JSON-format string. Using the "for (var x in arr)" syntax to iterate over arrays still worked, but the code in the for loop was assuming that the value was a piece of text, not a function. Hence my code was crapping out. Thanks to FireBug (THANK YOU!) I determined the cause of the crap. The solution, however, was provided by this wonderful post, the take-away of which is: Use the "for (var x = 1; x < arr.length; x++)" syntax. It's safer. The End.
Wednesday, August 13, 2008
EL Map won't work with numerical index
Assume you're using JSTL in a JSP. You create a Map in the JSP's backing class (e.g. SimpleFormController in Spring):
Map map = new HashMap();
map.put(0,115);
map.put(1,226);
This map is provided to your JSP as a variable with the name exampleMap. You then attempt to access the map's values in the JSP:
${exampleMap[0]}
${exampleMap[1]}
It doesn't work. For an explanation, see this dialogue which does a phenomenal job of describing the reason.
Map
map.put(0,115);
map.put(1,226);
This map is provided to your JSP as a variable with the name exampleMap. You then attempt to access the map's values in the JSP:
${exampleMap[0]}
${exampleMap[1]}
It doesn't work. For an explanation, see this dialogue which does a phenomenal job of describing the reason.
Thursday, July 24, 2008
JavaScript == operator
Keep in mind that 0 == "" returns true in JavaScript. For a more detailed explanation (and a lover's lament) see Chipmunkan's blog post.
Tuesday, July 8, 2008
Dynamically altering a form's onsubmit event handler
Suppose you have a form and you wish to alter the form's onsubmit event handler on-the-fly...
For example, your form might consists of two radio buttons and a submit button. Depending on which radio button has been selected prior to the user's submitting the form, you want the onsubmit event handler to change.
This works in Firefox, but not IE:
form.setAttribute("onSubmit", "alert('hi'); return false;");
This works in both:
frm.onsubmit=test;
function test() {
alert('hi');
return false;
}
For example, your form might consists of two radio buttons and a submit button. Depending on which radio button has been selected prior to the user's submitting the form, you want the onsubmit event handler to change.
This works in Firefox, but not IE:
form.setAttribute("onSubmit", "alert('hi'); return false;");
This works in both:
frm.onsubmit=test;
function test() {
alert('hi');
return false;
}
Wednesday, April 2, 2008
Inserting timestamp in Postgres
Here's an example of inserting a timestamp in Postgres:
insert into timeexample values ('2007-1-1'::timestamp)
insert into timeexample values ('2007-1-1'::timestamp)
Subscribe to:
Posts (Atom)