Skip to main content

Posts

Showing posts from 2011

Using a Servlet to generate chart images for BIRT

I've been working with Google's chart tools -- specifically their Image Chart tools .  My problem -- I'm using BIRT as my PDF report engine, but I have a web interface.  I want the report to look the same on the web as it does in BIRT (which has it's own excellent native charting library).  I decided the easiest way is to use an image tag, but I have the potential for copious data, so I have to use a POST instead of a GET. Google lists an excellent hack using a form and an Iframe as a way to submit the post and that works for me from the web.   It does not work inside of BIRT -- because as far as I know there is no way to submit a form inside of a report.  Instead I decided to use an image tag which runs through a servlet I host. So now I can write on my web page: <img src="../chart/chart.png"> and I can include in a dynamic text in my BIRT report "<img src='http://mywebserver/chart/chart.png'>"  //outside quotes requ...

Followup to the Integer toggle code

My good friend  Greg  mentioned that I should use bitwise operators to perform a toggle, as opposed to my  earlier method of using integer math to manipulate the state .  I had not done that because the bitwise implementation is imho not comprehensible by a developer who does not have a CS degree. As an example it is not at ALL clear to most people that  ~2<<10 != ~(2<<10) Although I suppose that's the point of a method name. /** * A simple way to implement a toggle switch using an integer to store the state * and bitwise operators to manipulate the toggle * * @author Dan Fishman http://www.fishdan.com * * This code released to the public under the CreativeCommons 3.0 license by * the author on 8/21/2011 * * http://creativecommons.org/licenses/by/3.0/ */ public class TestToggle { public static int toggleState=0; public static void main(String argv[]){ for ( int x=0;x<32;x++){ ...

Using an integer to implement a binary toggle switch in Java

We were talking about a way to use an integer to indicate teh state of a series of switches.  e.g. if there were 5 switches and the first 3 were on we would say think of that as 11100, or 28 Not a bad method -- you can very quickly toggle switches on and off by calling toggle(boolean on,int position) and you can quickly check it the toggle at a position is on by calling toggleIsOn(int position); The code snippet is below, comments welcome.  you have to declare toggleState yourself of course...; public int toggleState=0; /** * if onOff==true we set the value at pos == 1 aka on * else we set it to 0; * @param onOff * @param pos */ public void toggle(boolean onOff, int pos){ if (toggleState== null ){ toggleState=0; } if (onOff== true ){ if (toggleIsOn(pos)){ //do nothing, already on } else { //we wa...

Fishman's law

The corporation was initially a construct of government to enable efficiency in business.  Now government is a construct of corporations to enable efficiency in business.

Thoughts about power

The problem with power is that... well... it's POWERFUL.  It can be used for both good and ill, but regardless of it's usage, the more power there is behind a command, the harder it is for the individual to resist.  That's pretty close to the definition of power. It's become clear that throughout history there are some people who are driven to accumulate power.  It's also become clear that there is no correlation between a person's ability to accumulate power and his/her desire to use it to benefit mankind.  Certainly there have been examples of power being used very wisely, and for the benefit of man -- but there more than numerous regrettable examples. The Libertarian viewpoint is that the only way to prevent these tragedies is to prevent the accumulation of power.  We believe that all power originates from the people as individuals, thus governments and corporations only acquire power by a lessening of the power of the people.  If governmen...

Concatenating BIRT reports via servlet

I've been using BIRT a bit and in our project we generate alot of PDFs and have found BIRT to be the beswt product there is for that.  One thing BIRT does NOT allow you to do is to combine reports.  The below is my Servlet based solution for that which correctly renumbers the pages  It borrows the concatenation from Abhi on Java. I also bought IText in Action   A must have for the serious developer of PDF's in Java. I've stripped out the company specific part of this code, but have not tried compiling this version.  it should be pretty damn close to what you need though.  Ask if you have any questions. Of course this code is completely free to use and is released under the Academic Free License ********************************** import javax.servlet.*; import javax.servlet.http.*; import com.itextpdf.text.Document; import com.itextpdf.text.PageSize; import java.io.*; import java.net.URL; import java.util.*; public class PDFServlet exten...

Calvin R. Hill for City of Worcester School Committee

My co ex- MGH Institute of Health Professions colleague and generally good guy Calvin R. Hill is running for School Committee in Worcester MA. Calvin and I worked together for a year, and that was enough for me to form a pretty good impression of the guy. Calvin's a person who get's things done, but he doesn't act before he understands the situation.  In my role as Software Architect at the IHP, I worked with Calvin (who was the Chief Diversity Officer) on adding diversity questions to the course and faculty evaluations the students completed every semester.  It would have been easy to just hand me a few cookie cutter questions and have them thrown into the evaluations, but Calvin made me wait a few days, while he researched and consulted with some faculty and students so that the questions that ended up in the evaluation were specific about the IHP and the medical profession.  After that I had several more opportunities to work with Calvin, and though we were natur...

Some thoughts on the world oil market, and the lesson of the last mile

Oil goes to $200/barrel -- an almost certainty in the next 20 years. You don't think that cost constraint will affect the nations that can't afford oil like we can? Maybe they'll be the ones who engineer their way out of this. This may end up being a cell phone type situation. Because the US was SO wealthy, we were able to wire phones to every house in the US. This wealth made us a late adopter of cell phone technology, because who needed a cell phone when there was a phone in every home and a phone on every corner. As a result other countries pioneered cell phone technology. We've happily adopted it because it is obviously superior -- but the market brought cell phones to the US when they were finally superior to what the US, with it's enormous wealth could already afford. The same thing will happen with green technology. China is already the world's leading producer of Solar technology. In fact, our consuming all the oil makes them NEED green technology....

Ubuntu on Asus 900a

I just installed ubuntu on my asus 900a. If your flash drive isn't being recognized, try a different usb slot. Third time was the charm for me.  The front right slot was the one that worked.  Others have reported left only works for install, so try them ALL Sent from my Samsung Captivate(tm) on AT&T