Wednesday, September 12, 2012

Google User Content API?


Last night I wanted to download an originally sized image from Google+, which lead me to this odd little user content API.  I should note that the image that I'm using as an example here is in my instant upload.  I haven't shared it in any way on Google+  Yet, if you can construct the URL (obviously not a trivial task) then you can access it.

Here is the basic image URL:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ_4MAcZSc0ILAHsvDPPNSkaHhA4xZ4jXPwEyxN4JHpGg9ByRPmYDQFm897BP7SQvNAAqEvyrrFT6_hxRN3Pj-2DetuAm1t_tulfFs5EHZ3Fu5jJUUjUj3LpUkuF1-2HZu1kXuG-2NuAGa/IMG_20120912_092939.jpg <- Default sized at 512px height

Here are the simple parameters that I was able to flush out.  Each is placed in a /parameters/ path section before the image name:

/s768/IMG_20120912_092939.jpg <- Sized at 768px height
/h768/IMG_20120912_092939.jpg <- Sized at 768px height
/w768/IMG_20120912_092939.jpg <- Sized at 768px width
/c/IMG_20120912_092939.jpg <- Cropped (defaults to 512x512)
/d/IMG_20120912_092939.jpg <- Downloads the image (defaults to original resolution, but is effected by other parameters)
/g/IMG_20120912_092939.jpg <- Produces XML used by Google's pan/zoom, see: http://howiprovedit.com/archives/74
/h/IMG_20120912_092939.jpg <- When h is given without being followed by an integer it wraps the image in html (image effected by other parameters)
/o/IMG_20120912_092939.jpg <- Adds a "Play" circle to the center of the image
/p/IMG_20120912_092939.jpg <- Crops the image in the same manner as /c/ (odd)

These seem to hint at other parameters that I have not been able to ascertain:

/b/IMG_20120912_092939.jpg
/k/IMG_20120912_092939.jpg
/r/IMG_20120912_092939.jpg
/e1234/IMG_20120912_092939.jpg
/h1234/IMG_20120912_092939.jpg
/q123/IMG_20120912_092939.jpg
/t123/IMG_20120912_092939.jpg
/v/IMG_20120912_092939.jpg

It also looks like you can do some mix and match on the parameters:

/w123-h768/IMG_20120912_092939.jpg <- Sized at 123px width and scaled height (h parameter ignored) 
/h768-w256-c/IMG_20120912_092939.jpg <- Cropped at 341x341 ???
/h768-w123-c/IMG_20120912_092939.jpg <- Cropped at 164x164 ???
/h543-c/IMG_20120912_092939.jpg <- Cropped at 543x543
/s123-h543-c/IMG_20120912_092939.jpg <- Cropped at 123x123...s takes precedence over h
/h543-s123-c/IMG_20120912_092939.jpg <- Cropped at 123x123...s still takes precedence over h
/w123-h768-c/IMG_20120912_092939.jpg <- Cropped at 123x123...w takes precedence over h
/h768-w123-c/IMG_20120912_092939.jpg <- Cropped at 123x123...w still takes precedence over h
/h256-c-o/IMG_20120912_092939.jpg <- Cropped at 256x256 with a "play" button in the middle
/b-h768-c-o/IMG_20120912_092939.jpg <- Cropped at 768x768 with a "play" button in the middle, b has no obvious effect
/c-s256-h/IMG_20120912_092939.jpg <- Cropped at 256x256 and wrapped in html
/h512-o-h/IMG_20120912_092939.jpg <- Height of 512 with a "play" button and wrapped in html

...then I got bored.  Is this documented anywhere?  I wasn't able to find anything and am doubting that I ever will.


Saturday, March 19, 2011

I have a confession. (re: #tigerbloodtourney)

I cast false ballots in Fired Up! Missouri's Tiger Blood Tournament. In fact, it is likely that I decided the race between Speaker Steve Tilley (NBPP - Perry/Ste.Genevieve) and Jolie Justus (D - Freedom).  It was a decision that happened by fits and starts, but it was my decision.  I am not a man to step back from my decisions.  As such, I submit to you the facts of the situation as they presented themselves.  Mistakes were made.  Yet, I know without a doubt that, ultimately, I did what was right.  I took the action that no one else would and set the course of destiny down its true and proper path.

On Thursday evening, I checked in on the immensely enjoyable Tiger Blood Tournament.  At that time, there was nothing particularly stunning happening in the voting, although there was a lot of jocularity on twitter surrounding the event.  I noticed that most of my picks were doing pretty well, watched a couple of the YouTube videos and headed to bed.  However, the following morning I was treated to this shocking tweet from Senator Jolie Justus.

Now, any fool can see that either Tilley had members of his New Black Panther Party up all night clicking on tiny radio buttons while plotting to give St. Louis control of the Missouri Highway Patrol and install NBPP members to the controlling board giving Tilley his own private army just in time to wrestle control of the state from Lt. Gov. Tweets-a-lot (R - Where the hell did we get this guy?)...OR somebody was running a votebot. As the votes for Tilley continued to soar, I contemplated the situation.  How could this have happened? As her previous contests had shown, Jolie Justus has to be the most universally liked politician that has ever held elected office.  Not long ago, I would have sworn that politicians had developed a forcefield to keep all that was good and honest out of the halls of every Capitol in the country.  Then Jolie Justus came along.  For goodness' sake, just look at her name.  Now, say it out loud it sounds even better.  Clearly this woman came directly from the planet Krypton to fight for truth, justice and the Missouri way.

Something had to be done...

Now, I'm no Jolie Justus. Which is good, because that would be weird.  However, I've heard a cliché or two in my day and it just so happens that "fight fire with fire" is one of them.  I really don't understand that, because I thought you were supposed to fight fire with water.  Water beats fire, fire beats earth, earth beats water.  Am I right??  Anyway, I happen to have written a little program or two in my day.  So, I set out to even the score. FOR GREAT JUSTUS!

While the robot minions of Team Tilley stuffed the ballot boxes with thousands of fraudulent votes, I toiled away through my lunch hour.  I gave up sushi!  Damn you, Steve Tilley.  Despite already being behind by what looked like an unrecoverable margin, I dedicated myself to leveling the playing field for the sake of justice (or at least Justus, but whatever).  In less than the amount of time it would have taken for me to consume a delicious caterpillar roll at Sushi Sen, I had created a monster.  Well, actually a robot...or...an Android.

That's right.  I defeated Team Tilley's band of robot minions with a single, solitary cellphone.

It comes down to this: I had to be home in time for dinner.  I simply couldn't sit around the office until 5 waiting for voting to finish so that I could be sure that the NBPP hadn't swarmed the polls in a last ditch effort to keep the lead.  So, my votebot went mobile.  While I drove home, my phone executed a program that I am lovingly calling "Absentee Ballot".  It gave back to Jolie Justus the comfortable lead that she so rightly deserved.

I am proud of my little Samsung Captivate.  She did her part to restore Justus to the Tiger Blood Tournament.  Now that the world has been set right and Missouri snatched from Steve Tilley's clutches, I am retiring my little program.  But let this be a warning to those who would try to take the reins of Democracy from the hands of The People...wherever voter fraud rears it's ugly head, Absentee Ballot will be there and so will the Justus League.

Friday, December 18, 2009

A Reply from and an Open Response to Dan Rastatter

While I have not yet received a response from Dr. Alvin Goldstein, I did hear from Dan Rastatter this evening.  I was disappointed in the response on a variety of levels.  Not only did he give no indication that he intended to change the content of his abstract with regards to the Jerry Parker case, but he also accused me of desiring revenge, being callous and complacent with regards to police corruption.  Here is his replay in its entirety.

Dear Mr. Kimberlin,

I read your email in regards to my summary of the Jerry L. Parker molestation case.  You raise a few claims that conceivably chip away at Parker's defense.  However, the case against Parker is so weak that the points you make would have little effect in changing an evaluation of his case based on the information presented in Dr. Goldstein's account.  Parker may now be attending parole hearings, but innocent persons often feel coerced into doing so.

Because of the girls' youth, it is questionable whether they were old enough to give credible testimony.  Individuals that young are quite susceptible to believing and parroting opinions of adults rather than what they actually witnessed.  Secondly, the girls all failed to identify Parker in the first photo lineup they saw.  The case against Parker should have died there. Even if one ignores the girls' youth and their failure to initially identify Parker, there are many aspects to the case that are not very credible.

Your email suggests you allow emotion to enter into your evaluation of the case.  The severity or emotional impact of a crime does not logically affect what the evidence proves.  Apparently you are callously willing to subject a possibly innocent person to decades of imprisonment because it is "poor taste" to seriously question his accusers.

Judging from Dr. Goldstein's account, I am not at all sure the girls were molested, even if not by Parker.  It would be easy to believe that the girls got their stories from an actual event, but the details of their stories suggest that the molestation could not have happened in the way they describe.  If the girls were molested, they don't seem particularly upset about it, as they appear willing to cavalierly add to their account.

In your letter to Dr. Goldstein you dispute Parker's claims and write "I tend to desire a higher level of proof for claims of any kind in order to be swayed."  However, the burden of proof is on you or the prosecution to prove Parker guilty, not on him to prove his innocence.  I am not aware of any clear evidence that a crime was committed by anyone.

I am sorry that Parker murdered members of your family, if the evidence does indeed prove that.  Nevertheless, the fact that Parker may have murdered people does not mean he molested the girls.  It is unfortunate that Parker was less than polite to members of your family during his most recently trial, but few individuals take kindly to others who attempt to put them in jail.

In reading Goldstein's account, I wondered why police seemed to be framing Parker.  The evidence you relate suggests that police framed him because of his past murder convictions.  Police initially told the girls that they did not believe their stories; then they suddenly decided to focus on Parker as a suspect and kept pursuing him even after the girls failed to identify him.

I realize you want revenge on Parker, which he may deserve, but I would only seek such revenge in regard to provable crimes he committed.  If courts refuse to incarcerate him for these crimes, you just have to live with that. If you support police corruption in your desire for revenge, you are doing evil and are hurting people other than Parker.  Keep in mind that Parker's incarceration is never going to not provide you justice.  It is never going to bring back family members that were killed.

Sincerely,

Dan Rastatter
I felt it necessary to address his points and criticisms.  My response was as follows:
Mr. Rastatter,

I must admit that I am disappointed by your interpretation of my correspondence.  I would like to clarify the fact that I do not in any way desire revenge upon Jerry Parker.  While I would have loved to have known my grandmother and uncle, and while there is no doubt that he committed their murders, it would be completely antithetical to my own personal ethics to wish harm or hardship upon him.  Having never known my slain relatives, my sense of loss with regards to them is of more a theoretical nature than a personal or emotional one. Personally, I have nothing to gain by convincing you or Dr. Goldstein of Mr. Parker's guilt.  Furthermore, I have made no attempt to convince anyone of his guilt with regards to the molestation of the three young girls.  Quite the contrary, I explicitly stated that I would "not attempt to further argue Parker's guilt in this case".

You should be aware that Dr. Goldstein made his living as an expert witness.  He was paid to testify against the credibility of eyewitness testimony.  This in and of itself is reason to read his account with a skeptical eye.  Furthermore, the evidence presented on the page in question was provided by Mr. Parker.  Dr. Goldstein readily admits that he had nothing to do with the case.  His interest in the case is to make use of it as an example of why eyewitness testimony is imperfect.  My assertion is simply that the facts that are presented on his page are questionable and incomplete.  If Dr. Goldstein feels the need to relay the story of Mr. Parker, it should be the entire story.  Putting forth only those pieces of information which support the idea that one is trying to espouse while ignoring contrary and/or harmful information is a classic example of confirmation bias.  It is foolish to take the word and evidence of the convicted as truth and parrot it as fact without investigation.  The information surrounding the handling of the investigation comes from Mr. Parker.  Dr. Goldstein did not speak with the investigators.  He did not speak with the prosecutors.  He did not speak with the defense attorney, the judge, the witnesses or even the court clerk.  He spoke with no one with any relationship to the case whatsoever, with the exception of Mr. Parker.

There may well have been issues with the handling of the investigation.  There may have been serious flaws.  That does not change the fact that Dr. Goldstein's account of it is one sided and incomplete.  Anyone who reads the entirety of Dr. Goldstein's article can plainly see the bias that is displayed.  The article is peppered with unnecessary quotations used to convey sarcasm and skepticism. They are so prevalent that it detracts from the article.  Dr. Goldstein's desire to persuade the reader of the problems relating to eyewitness testimony is so strong that it colors the arguments and the text as a whole.

As for my being 'willing to subject a possibly innocent person to decades of imprisonment because it is "poor taste" to seriously question his accusers', I would suggest that you read my email to Dr. Goldstein again.  I have absolutely no desire to see any innocent person imprisoned.  My comment regarding Dr. Goldstein's "poor taste" was directed exclusively to his use of quotation marks around the words victim and crime.  Of the 23 jurists who heard the testimony and evidence in the case, 22 felt that he was guilty beyond a reasonable doubt.  Neither you nor Dr. Goldstein were present for that testimony and I find it rather arrogant on the part of Dr. Goldstein to claim superiority of reasoning over all 22 of those men and women.  The simple facts of this matter are that Dr. Goldstein obtained his information from Mr. Parker and based his arguments on that information.  You obtained your information from Dr. Goldstein's account.  As such, you are working from a set of half-truths provided by a convicted murderer and pedophile and filtered by a man with a career interest in the argument that he is expressing.  You claim below that the girls "don't seem upset" about their victimization and that they "cavalierly add to their account".  I can tell you from having seen these young girls give testimony that they were upset beyond what I can describe.  The trial and testimony was clearly very difficult for them.  If you have children, as I do, you should know that it is difficult for a 10 and 11 year old to tell any story the same way twice...much less while under interrogation from a defense attorney.  So, the fact that there were differences and/or discrepancies in their testimony is not surprising.  I will agree that this makes their testimony less reliable.  However, your statement that they do not seem upset is unfounded and ill conceived.

You told me in your reply that "the burden of proof is on you or the prosecution to prove Parker guilty, not on him to prove his innocence".  I agree completely that the burden of proof was on the prosecution to prove his guilt.  However, it is certainly not on me. I have nothing to do with Mr. Parker, his case or his guilt or innocence.  A jury of his peers concluded that the prosecution met that burden of proof beyond a reasonable doubt.  Therefore, he was convicted and jailed.  I do not ask you or anyone else to believe one way or the other with regards to Mr. Parker's guilt in this matter.  I only asked that the entire story be told accurately or that no story be told at all.  I cannot imagine that anyone would find this to be an unreasonable request.  Simply regurgitating information supplied by the accused is not only irresponsible, but also disrespectful to the victims of Mr. Parker's crimes and their families.

I am by no means a "callous" man.  I believe that we all make mistakes in our lives and that we all should be given the opportunity to atone for those mistakes.  Mr. Parker has at no point in his incarceration made any attempt to do so.  As for your insinuated skepticism of Mr. Parker's responsibility for the 1970 murders of my grandmother and uncle (as read from "if the evidence does indeed prove that" and "may have murdered"), I would direct you to the Missouri Supreme Court verdict on the matter.  It clearly elicits a variety of physical evidence, testimony and admissions on the part of Mr. Parker which led to his conviction.  I am confident that no one, even Dr. Goldstein, would question the merits of that case.  For your reference, that verdict can be found here:

http://mo.findacase.com/research/wfrmDocViewer.aspx/xq/fac.%5CMO%5CMO2%5C1974%5C19740408_0017.MO.htm/qx

At the risk of repeating myself, I would like to directly address the last paragraph of your email.  I wish for no revenge of any kind.  The penalties prescribed by the courts for Mr. Parker's convictions on the charges of murder and with regards to the molestation of the three young girls are more that sufficient for me.  Clearly the courts have not refused to incarcerate him, quite the contrary.  I have in no way supported, nor will I ever support, police corruption of any kind, in any form or for any purpose.  In fact, I find it abhorrent and take exception with any attempt to suggest otherwise.  Those who abuse the power that society grants them are even more despicable than the common criminals that they are tasked to attend.

It seems clear to me that you have dismissed my email as emotionally driven.  I can assure you that it was not.  I simply desired to express to both you and Dr. Goldstein that Mr. Parker is not the innocent victim that he is made out to be and to ask that either his entire story be told or that it be removed in its entirety.  An unwillingness to provide all of the information relating to Mr. Parker would only illustrate a desire to prop up an argument against the legal system over a desire to see the truth of his story told.  It is certainly your prerogative to maintain your site in whatever way you see fit.  However, I honestly hope that you are not so blinded by your desire to put forth a belief as to be unwilling to give a complete account of the stories that you use to support it.  I am sure that you can understand how detrimental that would be to the integrity of your site and your desire to see justice served.

Sincerely and respectfully yours,
-Michael Kimberlin

Thursday, December 17, 2009

An Open Letter to Alvin G. Goldstein, PHD

Forgive me for stating the obvious, but I rarely write blog posts. Every now and again something comes up that prompts me to put in the time and effort needed to construct something in a longer form.  This is one of those occasions.  I recently came upon a website that contains information that I believe to be both factually inaccurate and misleading.  It paints a picture of a man wrongly accused and victimized by the police, his attorney and the court system.  The man in question is Jerry Lynn Parker.  Mr. Parker was convicted of the 1970 murder of both my grandmother (Hazel Marie Kimberlin) and my uncle (Michael Wayne Kimberlin) who was only eleven at the time.  An abstract of that case can be found in the appeal judgment issued by the Missouri Supreme Court. While he maintained his innocence for many years, he has since admitted to these senseless slayings.  While out on parol, Mr. Parker was arrested and convicted of the molestation of three young girls (aged 10, 11 and 13).  In my opinion, Mr. Parker is a predator and a danger to society.

What follows is an email response of the contents of the page EYEWITNESS ERROR --AGAIN.  This has been sent to Dr. Goldstein in an attempt to have him either remove the page in question or, at the very least, update it for accuracy and completeness of the story of Jerry Parker.  Please note that the statements here are my opinions and should be read as such.  If there are inaccuracies, please feel free to bring them to my attention in the comments.

Dr. Goldstein,

I am writing to you with regards to your website relating the case of Jerry Lynn Parker.  As I understand, I am a bit late in getting this email to you as my father has already sent you a rather emotional response.  You should know that while seeing your site brought forward feelings of anguish and anger for him, there is no hate involved...only the pain that accompanies the loss of a parent and a sibling.  I wish that I would have gotten the chance to send my correspondence in advance of his email, as I should like to address some of your points and I fear that you are unlikely to be receptive now that you have already heard from our family.  Nonetheless, I shall attempt to persuade you against using Mr. Parker as an example for your campaign against eyewitness testimony.  As you now know, Jerry Parker murdered both my grandmother and my young uncle.  This took place before I was born.  While it saddens and frustrates me that he took away my opportunity to know them both, I also do not have the acute sense of loss that my father and aunts must have.  As such, I am able to view your arguments with a bit more detachment. I also attended the trial of Mr. Parker that concluded in his conviction for the molestation of the three young girls.  So, I have a perspective that you could not possibly attain from examining court documents.

I am curious. Have ever seen a picture of Mr. Parker that was not a mug shot?  I can tell you that when the trial occurred, Mr. Parker did not have the pronounced double chin that you point to as a discrepancy between the description from the girls and the mug shots on your page. His appearance in the mug shots is largely a result of Mr. Parker pulling his head back, creating the exaggerated appearance of a double chin.  This can be plainly seen in the side-view photo on your site. The assertion that he had "fatty tumors" may be true, however he is clearly attempting to make them more prominent in the photo. Furthermore, Jerry Parker was thin at the time.  This means that the girls' assertion that the man that accosted them was less "chunky" than the man in the initial photo line up appeared was accurate.  He does appear to be carrying more weight in that picture.

As for the questions regarding the differences in the cars described by the girls, I am sure that you are aware that young girls this age are not likely to be able to identify the make and/or model of a car on sight.  I am 32 years old and I am not capable of doing this without seeing it on the rear of the vehicle.  The same is true for the gun identification.  No eleven or thirteen year old girl could be expected to tell the make and caliber of a weapon.  These girls were young and frightened.  They endured a horrendous event that they likely barely understood.  To expect that their testimony would be iron clad and completely without inconsistency is simply not reasonable.

You also raise questions about the defense attorney's refusal to call witnesses that would profess to his being elsewhere at the time.  If you spoke to his attorney, you would probably be aware that these witnesses were not called because they were deemed to be a liability to Mr. Parker's case rather than a help.  Mr. Parker never took the stand to defend himself either.

It is clear from your site that a good deal of the information that you have was given to you by Mr. Parker directly.  You would be wise to view his stories and claims with a grain or two of salt.  I am a skeptic by nature.  I tend to desire a higher level of proof for claims of any kind in order to be swayed.  As such, I understand the problems inherent in eyewitness identification.  So, I am sympathetic with the desire to see convictions made on the basis of physical evidence.  Therefore, I will not attempt to further argue Parker's guilt in this case.  What I will say is that Mr. Parker is not an innocent victim of poor police procedure, improper defense, etc.  He is a predator.  As for his "refusal" to attend parole hearings,because of his desire to maintain his innocence, he must have had a change in conviction.  He attended his hearing in 2008 and is going to be having another hearing in January.  He also maintained his innocence in the 1970 murders until he confessed it to a bailiff during the trail involving these girls.  Yet he did not hesitate to attend the hearings that set him free to inflict harm on the innocent again.  Mr. Parker likes attention.  During the trail for this most recent crimes he would wave and sneer at our family.  He made lewd gestures toward my older cousin while leaving the courthouse.  He was snide and arrogant in demeanor throughout the trial. For years he sent Christmas cards to my family members, pouring salt in the already painful wounds that he had inflicted.  He has brought a number of law suits against the state and employees of the state on a variety of grounds, many of which are frivolous.  All of these cases have been dismissed.  Mr. Parker is no innocent man and is by no means a victim nor a model for your cause. I would request that you build your case against eyewitness testimony on a different case and leave Mr. Parker to his own faculties.

Also, I would like to say that your use of quotations around the words crime and victim is in poor taste.  These young girls were victims of a horrible crime, whether you believe that Jerry Parker was the perpetrator of that crime or not.  They were deeply affected by these events and in at least one case it led a family to be torn apart. This was not something in the imagination of some silly little girls. At the very least, please treat the events with the respect and gravity that they deserve and tell Mr. Parker's complete story.

Very sincerely yours,
-Michael Kimberlin
In addition to this email, I sent a request to Dan Rastatter regarding his abstract based on Dr. Goldstein's write up of the Parker case found on the Victims of the State website.  That email was as follows:
Mr. Rastatter,

I am writing you with regards to Jerry Lynn Parker.  You have him listed on your Victims of the State website with regards to his conviction on charges relating to the molestation of three young girls.  Your site led me to the source of your information, one Dr. Goldstein.  I have written Dr. Goldstein in an attempt to persuade him that Mr. Parker is by no means an innocent man.  I am including that correspondence below.  I should also like to request that you give your abstract of the case a second look and consider its removal from your site.

I appreciate your consideration and look forward to your response.

Sincerely,
-Michael Kimberlin
As of the time of this post, I have not received a response from either individual.

Friday, October 10, 2008

The Kimberlin Acting Dynasty

Since I have demonstrated my prowess in front of the camera in a previous post. I thought I would let my dear old dad get in on the action. Here he is playing the creepy school teacher (check out that jacket and bow tie) for a Springfield, MO CVB film. Enjoy!

Tuesday, July 8, 2008

You don't have to answer that...

So, I had another funny interaction with Jeremiah Holly Abraham-Castlevania yesterday. This one was on the phone, but it went basically like this:

(While trying to debug an issue in her application...)
Me: Okay, I just sent you an email with a couple of configuration changes. Put those in and we'll try it again.
Jeremiah Holly Abraham-Castlevania: Okay, I got it. Do you want me to put those in?
(crickets: *chirp*chirp*chirp*)
Jeremiah Holly Abraham-Castlevania: Okay, you don't have to answer that.
Jeremiah Holly Abraham-Castlevania: Alright, they are in.
Me: Okay, now try it out.
Jeremiah Holly Abraham-Castlevania: Do you want me to run it now?
(again with the crickets: *chirp*chirp*chirp*)
Jeremiah Holly Abraham-Castlevania: You don't have to answer that either...
Me: You don't really need me here for this conversation, do you?

Tuesday, July 1, 2008

Another victim of The Wall of Erasure

Ahh, Erasure....  Today I was implementing an extension to a class that performs traversing of tree-like object structures (think UI component hierarchies).  The parent class extends another type-parameterized version of an abstract class which provides general tree traversal logic.  The problem is that I wanted to check that the current node is of a type beyond that of the type parameter provided to the parent class.  So to put that into something that might actually be understandable:

public class ParentFinder<T extends Component> extends ComponentVisitor {

private T parent = null;

public ParentFinder() {
// Set up things to travel up the tree...
...
}

public void visit(Component node) {
if(T.class.isAssignableFrom(node.getClass())
parent = (T)node;
}
}

Survey says! *BZZZZ* XXX *BZZZZ* This line is no good thanks to erasure:

  if(T.class.isAssignableFrom(node.getClass())


And, no...you cannot do "instanceof" either. The JVM couldn't tell you if it wanted to. That info is G-O-N-E, gone!

How dare you want to know what you are working with!

Monday, June 30, 2008

It's a Hate-Really Hate kind of relationship...

So, I have a lot of interesting little chats with a co-worker of mine. We have what I can only describe as a pseudo hate-hate relationship. Pretty much the whole thing revolves around the intentional antagonizing of one another at every opportunity. Generally, our conversations go something like this:

Abraham-Castlevania, Jeremiah Holly [9:22 AM]:
Michael, I can't get to my test environment!
ME [1:18 PM]:
Is the application server running?
Abraham-Castlevania, Jeremiah Holly [1:18 PM]:
Yes.
ME [3:02 PM]:
Are you sure?
Abraham-Castlevania, Jeremiah Holly [3:02 PM]:
No.
ME [3:53 PM]:
Check.
Abraham-Castlevania, Jeremiah Holly [4:01 PM]:
I hate you.

I have changed her name to protect the far-from-innocent. I will state that the name that I have given her, believe it or not, is no more ridiculous than her actual name. ;) Here is one of our more recent interactions.

Abraham-Castlevania, Jeremiah Holly [10:02 AM]:
Michael, I see this error...JVM appears hung: Timed out waiting for signal from JVM.
Abraham-Castlevania, Jeremiah Holly [10:02 AM]:
could that have caused the problem?
ME [10:06 AM]:
uh...yeah...
Abraham-Castlevania, Jeremiah Holly [10:07 AM]:
don't be smart
Abraham-Castlevania, Jeremiah Holly [10:07 AM]:
what causes the jvm to hang
ME [10:07 AM]:
goblins
Abraham-Castlevania, Jeremiah Holly [10:07 AM]:
I can't stand you
ME [10:07 AM]:
maybe fairies...
Abraham-Castlevania, Jeremiah Holly [10:07 AM]:
really really can't stand you

Monday, October 8, 2007

Confessions of a Geek...

Just in case there was ever any question about it, my geekiness goes WAY back.  The way I figure it, better to admit fully to the existence of this tape well before my run for president.

Wednesday, October 3, 2007

@BFNH This is a Big Fat Nasty Hack. Be ye' warned!

The above is my recent favorite @ tag. We all come upon those times when, no matter how much we try to avoid it, a Big Fat Nasty Hack is required. We try to make them pretty. We roll them in perfume, wrap them in silk and adorn them with flowers, but they remain BIG, FAT and NASTY. It's like a warthog in a wedding dress. Let's just call them what they are. The @BFNH tag calls these hacks out and exposes them to the world. Use it wisely.

I ran across this situation most recently when trying to insert cells into an Excel workbook that contained functions with references to named ranges. It would seem that Apache POI does not really support this. POI can read these cells in, but it is unable to provide a valid "function value" for the cell when calling HSSFCell.getFunctionValue(). Instead of a good function string, it gives something like "COUNT( NO IDEA )" or some such nonsense. Not being able to produce a function string for this type of function call, it also fails to parse a function of this type for insertion. I really needed this functionality. As I described in my previous post, I came upon a way to provide dynamic charts in Excel from Java. Seeing what could be done with this, my users went a little over-the-top. Excel reports with charts are something they have been requesting for a while, only to be rejected. So, I set upon the creation of the plethora of new "must have" reports. Many of the reports they want involved breaking up data into ranges and reporting on range statistics. They also wanted to be able to play with the raw data and see the results in the charts. This was a task.

What I decided to do was create named ranges referencing the desired "raw" data ranges for periods. Because this data is being queried based on the users parameters, the ranges must be calculated and created on the server. I planned to then reference these ranges in the cells of a table of period statistics. This would free me from calculating the statistics on the server and allow Excel to alter the charts as data in the ranges is changed. The only thing that was missing was how to go about setting a cell value to something like "MEDIAN("MyWorkbook.xls"!MyNamedRange)". I looked everywhere for a solution. I scoured the POI mailing lists and APIs, I tried a number of variations on the formula string, I searched Krugle like mad and I got nowhere. Not getting any response on lists or forums, and being one to take defeat likely, I took up my trusty debugger and set to probing the depths of POI. Let me warn those of weak constitution to stop reading here. The resulting code involves accessing the inaccessible, breaking the rules that the makers have set out for us and generally doing nasty things.

I created a number of cells that contained references of the type that I required, then created expressions in the debugger to expose the internal representation of the file that POI uses. I found that formulas are parsed into a list of references (to functions, ranges, etc.). I found that I could create formulas that resembled the ones that I desired, using a dummy static reference as a place holder and then swap the static reference for a dynamic one of my creation. This converts a formula like "AVERAGE(A:A)" to something like "AVERAGE("MyWorkbook.xls"!MyNamedRange)". The thing is, the POI guys/gals didn't really intend these things to be accessed directly. So, naturally, I promptly went against their wishes. The following is the result. Use it at your own risk, observe the comments and stated limitations, expand it, generalize it, whatever...but I would appreciate it if you relay any improvements back to me as well. ;)

    /**
* The purpose of this method is to HACK OUT a static range reference from
* POI's internal representation of a single range parameter function cell
* and replace it with a reference to a existing named range. Because the
* necessary fields and methods are not meant for general use, they are
* inaccessible. As a result, reflection was used to obtain the necessary
* references. This provides an opportunity for undetected errors to creep
* in, as changes to these methods would not be detectable at compile time.
* Furthermore, as non-accessible methods, they are more likely to be
* subject to change with future releases.
*
* The process for replacement of references is as follows: - Retrieve the
* FormulaRecordAggregate from the target cell. - Reduce the FormulaRecord's
* expression length by 2 (area references are larger than name references). -
* Set the calculate on load option for the cell to true (options = 2). -
* Create a new named range reference and set field_2_ilbl to the index of
* the desired name in the workbook's name table. - Remove the static area
* reference from the parsed expression (index = 0). - Insert the newly
* created named range reference into the parsed expression (index = 0). -
* Smile.
*
* @BFNH This is a Big Fat Nasty Hack. Be ye' warned!
* @param results the workbook being dealt with
* @param targetcell the cell in which the formula reference
* @param nameName the name of the named range to reference
*/
@SuppressWarnings("unchecked")
protected void hackFunctionCellToSetNewNamePointer(HSSFWorkbook results,
HSSFCell targetcell, String name) {
try {
short nameIndex = (short) (results.getNameIndex(name) + 1);

// Get the original formula record aggregate. This must be done
// via reflection, as it is not an accessible method.
Method method = HSSFCell.class.getDeclaredMethod(
"getCellValueRecord", new Class[] {});
method.setAccessible(true);
FormulaRecordAggregate original = (FormulaRecordAggregate) method
.invoke(targetcell);

// A static area reference is a couple of bytes larger than a name
// reference. So, if we don't reduce the formula record size, we
// will get corruption of the produced file.
List parsedExpression = original.getFormulaRecord()
.getParsedExpression();
short length = (short) (original.getFormulaRecord()
.getExpressionLength() - 2);
original.getFormulaRecord().setExpressionLength(length);

// Now we want to make sure that we cause the cell to be calculated
// on-load. The following line should accomplish that. Note, that
// if you have other options on the cell, they will be wiped out by
// this. Chances are that won't effect you though.
original.getFormulaRecord().setOptions((short) 2);

// Now we create a name pointer...the constructor I'm using here has
// not been implemented yet. If it were, we would likely not need to
// set the "field_2_ilbl" value. From what I can tell, this field is
// essentially the pointer to the name table in the workbook. We
// give it the name index and leave the rest alone.
NameXPtg nameptr = new NameXPtg(name);
Field nameTableIndex = NameXPtg.class
.getDeclaredField("field_2_ilbl");
nameTableIndex.setAccessible(true);
nameTableIndex.setShort(nameptr, nameIndex);

// Now we remove the static area reference from the parsed
// expression and add our name pointer in it's place. Please note
// that I have only tried this with functions that take a single
// name pointer and of those, only functions with 1 or 2 total
// parameters. In the case of two parameters, I have only tested
// when the second parameter is a constant. For example,
// This should work with: COUNT("MyFile.xls"!MyName) or
// AVERAGE("MyFile.xls"!MyName) or even
// QUARTILE("MyFile.xls"!MyName, 1). I would imagine that the
// process is similar for more complex function cells, but this is
// all I have needed, so that's as far as I've gone. My guess is
// that the length would have to be decremented once for each Area
// to Name conversion you do and I have no speculation about where
// the other area pointers might land in the parsed expression (in
// terms of their index).
parsedExpression.remove(0);
parsedExpression.add(0, nameptr);
} catch (Exception e) {
// You screwed up and I don't care...write your own error handling.
// ;)
log.error("Bad developer...BAD!");
}
}