Monday, December 22, 2008
Publishing to Blogger with Google Docs
Google Docs
I recently took Google Docs out for a test drive and was impressed with how easy it was to write rich text documents through a web page. You can easily make format changes, build tables, and insert images. Google Docs also allows you to create presentations and spreadsheets.
Posting to Blogger with Google Docs
While working on a test document, I noticed there is a share button on the top right hand corner of the page. When you click the Share button, there are a couple of options available. If you select Publish as Web Page, you will presented with an option to Post to Blog. There will also be a link there so that you can setup your blog account settings. Once your Blogger account settings are saved in Google Docs, you can now easily post documents from Google Docs to your Blogger blog. Give it a try, I have been using this setup for a few weeks now and I have to say that it is the best way I have found to create Blogger posts.
Meld: Open Source diff and merge tool for Linux
Easy Installation
Since Meld is in the Ubuntu package archives, you can easily install it by opening Applications > Add/Remove. When Add/Remove opens, search for Meld and select to install Meld Diff Viewer. From the command line, you can also install Meld through apt with the following command: sudo apt-get install meld
In Place Editing
The main feature that has blown me away with Meld is the capability to edit files while you are comparing them. Not only can you do normal merge operations with files you are comparing, but you can actually edit the files as though they are in a text editor and Meld does realtime comparisons as you do this. This really comes in handy in all sorts of situations.
You can see in the image that while comparing the two files, I decided to throw in some extra text into file2 and it immediately updated the comparison. Of course if I want to move the change over to file1 all I have to do is click the black arrow and it will update file1. This is a very powerful feature and really saves time when you need to be able to make changes in a hurry to multiple files.
Easy Integration with RapidSVN
If you miss the file comparison feature found in TortoiseSVN under Windows, you can setup Meld to be your file comparison tool under RapidSVN in Linux. In RapidSVN, click on View from the menu bar and select Preferences. Once the Preferences Menu opens, click on the Diff Tool tab, type meld in the command text box and click OK. Now when you choose to diff files from within RapidSVN, it will use Meld to compare files.
Integration with Nautilus
- Set the Label to Meld. This is the text that will show up when you right click.
- Set the Icon to wherever your Meld icon image file is. Mine is located at /usr/share/pixmaps/meld.png.
- Set the path to meld
- Set the parameters to %M. If you look at the legend, this will pass in a space-separated list of the selected files/folders with their full paths.
- Click the Conditions tab.
- Set Filenames to * and check the Match Case check box.
- Set Mimetypes to */*
- Select the Both radio button and check the Appears if selection has multiple files or folders check box under "Appears if selection contains."
- Click OK
Thursday, December 18, 2008
Pandora for the iPhone
How to search for a percent (%) sign in a like query
SELECT * FROM my_table WHERE some_column LIKE '%\%%' ESCAPE '\';The query above defines the backslash as an escape character so that it will search for any row that has a percent sign in some_column.
Wednesday, December 17, 2008
Generate Charts and Graphs in Java Using JFreeChart
One of the first things I noticed was that there is very little to no documentation on how to use JFreeChart and I am assuming that is because they sell their Developer's Guide to support the project. While that is definitely a good way to support their project, it makes it hard for people to test out the API. So, hopefully, I can help you get started with using JFreeChart. I strongly encourage purchasing the Developer's Guide if you plan on using JFreeChart in your projects.
A Simple Line Chart
We'll take a look at a simple dataset that would be used in a basic line graph using JFreeChart. Our datasets will represent the number of visitors counted at local parks over a 7 day period.
| Park 1 | |
|---|---|
| Day | Number of Visitors |
| 1 | 10 |
| 2 | 4 |
| 3 | 6 |
| 4 | 12 |
| 5 | 11 |
| 6 | 39 |
| 7 | 33 |
| Park 2 | |
|---|---|
| Day | Number of Visitors |
| 1 | 23 |
| 2 | 15 |
| 3 | 18 |
| 4 | 5 |
| 5 | 52 |
| 6 | 66 |
| 7 | 83 |
We are going to create a graph using the dataset above with the JFreeChart API. The sample class below will show how to generate a line graph using the data above.
This is just a basic example of how you can generate charts using JFreeChart. You can see at the end I also show an example of another useful feature found in JFreeChart, the capability to write out charts as images. In this example, I wrote out the chart as a PNG file. Here is an example of how that chart would look if you ran the code above.
package org.javaconfessions.sample;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.chart.ChartUtilities;
import java.io.File;
import java.io.FileOutputStream;
class XYChartSample {
public void buildChart() throws Exception {
XYSeriesCollection dataset = new XYSeriesCollection();
XYSeries xySeries = new XYSeries( "Park 1" );
xySeries.add( 1, 10 );
xySeries.add( 2, 4 );
xySeries.add( 3, 6 );
xySeries.add( 4, 12 );
xySeries.add( 5, 11 );
xySeries.add( 6, 29 );
xySeries.add( 7, 33 );
XYSeries xySeries2 = new XYSeries( "Park 2" );
xySeries2.add( 1, 23 );
xySeries2.add( 2, 15 );
xySeries2.add( 3, 18 );
xySeries2.add( 4, 5 );
xySeries2.add( 5, 52 );
xySeries2.add( 6, 66 );
xySeries2.add( 7, 83 );
dataset.addSeries( xySeries );
dataset.addSeries( xySeries2 );
JFreeChart chart = ChartFactory.createXYLineChart( "Park Chart",
"Day",
"# of Visitors",
dataset,
PlotOrientation.VERTICAL,
true,
false,
false );
FileOutputStream out = new FileOutputStream( new File( "parkchart.png" ) );
ChartUtilities.writeChartAsPNG( out, chart, 400, 200 );
}
}
