Peacock Software Blog Posts

Java Associative Arrays (Sort Of)

Ever wish that Java had associative arrays (aka assoc arrays) like in PHP?  As in, $x["name"] = "Bill" ?  Well, I created a helper class for Java which comes close to approximating it.  It can even loop through it similar to foreach().

ipad-java.jpgI call the class PseudoAssocArray, because it actually uses a HashMap to do the behind the scenes work. 

Click here to download the source file (CC BY 3.0 "Open Source" license)

Simply download and import the file in your project, then use it like so:

 

Dropbox and Programming - A Match Made in Heaven

For those that don't know, Dropbox is a free service which lets you share a folder across multiple computers, even with different OSes like Mac, Windows, and Linux.  It's great for keeping all your personal files with you on both your work and home PC (without the need for a USB drive).  But where it really shines for me is when it comes to programming.

Dropbox-Review-2.jpgProgramming from multiple computers is always a bit of a pain.  What I used to do is keep all my source files on a USB drive, and just have to remember to carry it with me every where I go.  I'm always worried about breaking or losing it, so I have to back it up frequently.

Everyone Should Use Ninite.com

If you've never heard of ninite.com, you should head over right away and check it out.

Simply put, it's a 1-click solution to installing most commonly used free software, and keeping it up to date.  From the site, you select which applications to download, and you are given a custom installer (for free).

When you run the installer, it will download and install all of the software for you, skipping tedious screens asking you where to install, and automatically declining any offers of extra toolbars or other adware.

Design Java UI Like Visual Basic

One of the most frustrating and time-consuming tasks in Java is creating basic, ordinary UI.  As in, windows, buttons, scroll bars, text fields, etc.

This is in stark contrast to, say, Microsoft Visual Basic / Visual Studio, where you can just drag and drop elements onto a form, and what you see is what you get.  And when you double-click a button on your form, you get to the code which is executed when the button is clicked.  In Java, if you want anything other than just the basics, you're going to have to do a lot of typing.

That is, unless, you are using the WindowBuilder Engine and Eclipse.

 

MySQL Temporary Tables

If you have ever needed a routine which rebuilt a large database table every night, you've probably run into the following situation:  while the table is being rebuilt, whatever scripts which read from it will be broken, and you risk users of your system (or site) seeing the data when its still only half-populated.

For those MySQL gurus out there, you're probably screaming "use transactions!"  But, if you are using a MyISAM table instead of InnoDB, that isn't an option.

Symlinks in Windows 7+

Did you know you can create a symlink in Windows 7/8,10, etc just like in Linux?  If you don't know what that is, imagine a directory somewhere which is actually displaying the contents of another directory, maybe on an entirely different hard drive.

The command needs to be run from the command line, and looks like this:

MKLINK [options] link target
Example:  MKLINK /J data "C:\Dropbox\MySQL Folder\data"

Pages