Saturday, October 31, 2009

Restored The Guestbook

— Matt Harris @ 11:52 am

The previous guestbook was being overwhelmed with spam, so I disabled it many years ago. Part of the site upgrade plan was to redo the guestbook as a WordPress Page, as Spam Karma 2 manages to deal with all of the spam quite nicely.

Creating the page was easy enough, and I was getting it. The difficulty was in linking it properly on the navbar. When I clicked on the navbar link, the entire site would end up nesting inside the main frame, doubling up the navbar:

Nested Navbar

For a long time, I thought this was due to the javascript file I used to make sure the navbar showed up. Turns out it wasn’t – I fixed it by simply having the link target “_parent” as opposed to the main frame.

One more mystery solved. Eventually, I want to get rid of the frames entirely. They are a legacy of the days when this site was strictly static HTML. Still, that is a task for another day.

Comments Off on Restored The Guestbook
Friday, October 30, 2009

Upgraded to WordPress 2.8.5

— Matt Harris @ 7:18 pm

Finally upgraded the site to the latest version of WordPress, after I learned that the 2.0 branch, which was supposed to be supported into 2010, was dropped early this year. Upgrading the site was painless. Upgrading my home mirror took about 6 hours, as I ended up having to install new versions of Apache, PHP & MySQL.

Also added a new logo – I think it looks much better than the old logo. Took out a couple of items on the navbar to the left. The links were very outdated, I don’t really use ICQ much anymore and the guestbook didn’t work on my home version of PHP. I plan on switching the guestbook over to a WordPress page sooner or later.

Comments Off on Upgraded to WordPress 2.8.5
Monday, October 19, 2009

Adventures In Java – The Perils Of Encoding & Decoding

— Matt Harris @ 8:23 pm

A little while ago, I decided to get off my duff (figuratively speaking) and finally learn how to program Java. I installed the latest version of the JDK and Netbeans three weeks ago, did the usual “Hello, World” type programs and then began working in earnest.

I decided that I wanted to do a fanfiction downloader, similar to this program. I condsidered use Netbeans’ GUI builder, but decided to do the GUI coding by hand for my first project, for educational purposes. It was educational…and a pain.

Anyway, I had the following after a couple of hours of work:

Screenshot of Alpha Fiction Downloader

Once that was done, this weekend I began writing the backend code to download stories from fanfiction.net. After another couple of hours, I had something that would download a story – buggy and no error trapping to speak of, but a pretty decent alpha. As part of my testing, I decided to run it outside of the Netbeans IDE. It didn’t work. The stories would download, but they had gibberish in the place of quotes and some other punctuation.

Having be around the web a few times, I figured this was an encoding issue. What I didn’t understand is why it would work perfectly when I ran the program from inside Netbeans and screw up the encoding when I didn’t. I spent hours playing around with the URL and HttpURLConnection classes, without any success. I then stumbled upon a webpage that mentioned that the Scannerclass (which I used to download the webpage) would default to the system’s charset. I added some code to show the current system charset via the Charset.defaultCharset() method. Turns out the inside Netbeans, the charset is “UTF-8”. When I ran program outside the IDE, the charset was “windows-1252”.

Thinking I had solved the problem, I changed the Scanner constructor to use “UTF-8” encoding. I ran the program outside the IDE and the output html was still messed up, but in a different way. I switched the encoding inside my browser for UTF-8 to windows-1252 and everything looked perfect. Turns out the PrintWriter class also uses the system charset as the default. Added UTF-8 encoding to the PrintWriter constructor and things looked good. I decided to test the output file in Firefox (my default browser is Opera) and it rendered just fine. When I tried it in IE 6.0, more garbage. Opera and Firefox recognized the file as being UTF-8, but IE defaulted to my system settings. Added a couple of lines to the header of the file being generated, specifying that it was UTF-8, and even IE 6 read it fine.

I have to admit, I never expected the IDE to use different encoding internally than the system. Despite the several hours of frustration this caused, I had a fun and educational weekend.

Comments Off on Adventures In Java – The Perils Of Encoding & Decoding
Archives

  • 1530s Europe Campaign (15)
  • Books (7)
  • BTVS & Angel (24)
  • Cormaria (22)
  • Doctor Who (1)
  • Fanfiction Recs (19)
  • General (36)
  • Harry Potter (19)
  • Humor (16)
  • Java (1)
  • Microsoft Office (2)
  • Northridge Pathfinder (24)
  • OpenOffice.org (1)
  • Pathfinder (30)
  • Politics (4)
  • Programming (6)
  • Programs (5)
  • Reviews (2)
  • Role-Playing Games (D&D et. al.) (85)
  • Science (1)
  • Site News (120)
  • Smallville (2)
  • Stargate (2)
  • Tips (4)




  • Powered by Wordpress