August 20th, 2007 by Andrew
I'm a big fan of Xplanet and every year during the hurricane season there's no better way to liven up your desktop than to download the latest cloud maps and watch the path of the storm. Here's a screenshot of my desktop showing hurricane dean (larger view):

I cron a script to download the latest cloud maps every 4 hours or so. The xplanet command I run is as follows:
xplanet -origin sun -north orbit \
-config xplanet.conf -label \
-marker_file brightStars \
-target earth \
-latitude 22 \
-longitude -78 \
-radius 30 \
-labelpos +30+30
Here's my xplanet.conf:
[earth]
cloud_map=clouds_2048.jpg
magnify=20
[moon]
magnify=20
Posted in Linux | No Comments »
August 14th, 2007 by Andrew
When creating a chart that has rather long labels for the x-axis it is sometimes desirable to rotate them a bit so they fit on the plot. The method to use is setCategoryLabelPositions(..) on the CategoryAxis class. Here's a quick example:

And the code..
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.ChartColor;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.data.category.DefaultCategoryDataset;
public class RotateLabels {
public static void main(String[] args) {
DefaultCategoryDataset dataSet = new DefaultCategoryDataset();
dataSet.addValue(51, "series", "Colonel Forbin");
dataSet.addValue(92, "series", "The Lizards");
dataSet.addValue(33, "series", "Wilson");
dataSet.addValue(77, "series", "Rutherford the Brave");
dataSet.addValue(37, "series", "The Unit Monster");
dataSet.addValue(97, "series", "The Famous Mockingbird");
dataSet.addValue(67, "series", "Poster Nutbag");
JFreeChart chart = ChartFactory.createBarChart(
"Gamehendge",
null,
null,
dataSet,
PlotOrientation.VERTICAL,
false,
false,
false
);
CategoryPlot plot = (CategoryPlot)chart.getPlot();
CategoryAxis xAxis = (CategoryAxis)plot.getDomainAxis();
xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
chart.setBackgroundPaint(ChartColor.WHITE);
try {
ChartUtilities.saveChartAsPNG(new File("chart.png"), chart, 400, 300);
} catch(IOException e) {
e.printStackTrace();
}
}
}
Posted in Java | 6 Comments »
July 16th, 2007 by Andrew
One nuance I recently ran into while using iBATIS was inserting data into MySQL bigint unsigned columns. iBATIS doesn't seem to have a way to handle BigInteger data types and throws an exception when attempting to do an insert. Fetching data out seemed to work OK because if iBATIS doesn't know how to handle a certain type it just returns a java.lang.Object. The way to go about inserting BigInteger types is to set up a type handler. Here's an example type handler for BigInteger types:
package org.qnot.util;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.SQLException;
import java.sql.Types;
import com.ibatis.sqlmap.client.extensions.ParameterSetter;
import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;
public class BigIntegerTypeHandler implements TypeHandlerCallback {
public Object getResult(ResultGetter getter) throws SQLException {
if(getter.wasNull()) {
return null;
}
Object o = getter.getObject();
if(o instanceof BigDecimal) {
BigDecimal bd = (BigDecimal)o;
return bd.toBigInteger();
} else if(o instanceof BigInteger) {
return (BigInteger)o;
} else {
return o;
}
}
public void setParameter(ParameterSetter setter, Object parameter)
throws SQLException {
if (parameter == null) {
setter.setNull(Types.BIGINT);
} else {
BigInteger i = (BigInteger) parameter;
setter.setBigDecimal(new BigDecimal(i));
}
}
public Object valueOf(String s) {
return s;
}
}
Then all you have to do is register the type handler in your sqlmap-config.xml file like so:
xml version="1.0" encoding="UTF-8"
<!DOCTYPE sqlMapConfig PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
<settings useStatementNamespaces="true" />
<typeHandler javaType="java.math.BigInteger"
callback="org.qnot.util.BigIntegerTypeHandler"/>
<sqlMap resource="sql/example.xml"/>
</sqlMapConfig>
Posted in Java | 1 Comment »
July 13th, 2007 by Andrew
Eight windmills now line up the shore of Lake Erie at the site which was once home to the old Bethlehem Steel plant. It's exciting to see Buffalo on the forefront of renewable energy and this new wind farm dubbed "Steel Winds" is the first urban wind farm in the country. It’s also the world’s first commercial project to use Clipper Windpower’s Liberty series turbines.
Here's some quick stats about the turbines:
- Stand approximately 255 feet tall (410 feet with blades extended)
- Can potentially produce 20 megawatts of pollution-free electric power
- Could provide the annual electrical needs of more than 6,000 homes
- Total project cost around $40 million
There's also talk about expanding the project to include as many as 19 additional windmills.

Posted in Personal | No Comments »