Tuesday, January 29, 2013

Keeping Track of App Settings in Java

Recently I was working on a Java application which required certain settings to be saved and reloaded, such as window positions, user data, etc. I thought it would be a great idea to use a centralized object which could keep track of the settings as many of them are shared between objects. As I got to thinking about how I could implement this centralized class, I imagined an XML file being saved to the drive which I would parse using a SAX parser, manually picking out the fields I wanted, and overall taking a ton of work. Everytime I wanted to add a new setting it involved going into my Settings class and adding a field and some custom SAX parsing code.

However, I realized that there was a much better way to do things, and that's to take advantage of the default Java Serialization API. This automatically handles the transfer of a Java object over a stream, which in my case are file streams so I can save and load the class. I also realized that rather than trying to push for efficiency and having the code completely valid by compile time, I would switch to a runtime management type approach. This involved Using a simple HashMap which would match objects with string key identifiers.

Tuesday, January 22, 2013

msysGit Context Menu Missing Issue Fix

This is a short fix for msysGit's context menus.

Something that's bothered me about the way msysGit context menus work is that they only work when you actually have a directory selected. You can't just click on the Windows Explorer "background" and launch the bash at that location.

The issue was brought up to the msysGit team but they didn't actually make any changes to fix the issue. Whether they haven't done it yet, don't know how, or intend this to be the correct behavior, I don't know. I just know it's not how I want it to be.

I could fix this by using the git-cheetah dll, but I don't really like this because it creates tons of menus I don't really want. It really doesn't fit into the way I use Git.

I use TortoiseGit for simple day-to-day use and the Git Bash when I need to do some heavy lifting. The less items I can have cluttering my already large explorer context menu the better.

Tuesday, January 15, 2013

Setting up a SVN Server

Introduction

I've recently added some revision control to my Ubuntu virtual server. I added Subversion and Git support. Here I'm documenting the process I used to setup a Subversion server.

I'm following for the most part Ubuntu's SVN tutorial.

Tuesday, January 8, 2013

SSH Key-Pair Authentication

Introduction

In the past I've limited SSH access to my Ubuntu virtual server by using static IP addresses. This works, but I've recently implemented a better method for ensuring SSH security for my virtual server. It uses the private/public key authentication method.

This is actually the method used pretty much everywhere else because it doesn't require hard-coded static IP addresses.

This is based mostly on the HowtoForge article about Key-Based SSH Logins with PuTTY.

Sunday, January 6, 2013

Commenting should now work

A quick service announcement, commenting should now work. You must be a registered user (either have a Google Account or some other OpenID account) in order to post a comment.

This is changed from previous settings where only members of the blog could post. I thought this meant that only people who joined the blog could post comments, and I would only have to remove/ban a user to keep spam down. Turns out this is not how this functions; it only lets people authorized to post in this blog to comment, too (currently only me).

As far as I can tell, there's no way to ban/block a particular user from posting. I'll see how these new settings work out, if it becomes a problem I may have to switch to a different scheme.

Tuesday, January 1, 2013

Automatic Preview

Introduction

This is a fun little post. I created a client-side preview box which automatically updates as the user types. It supports Alex Gorbatchev's Syntax Highlighter and MathJax.