RSA Public Key Encryption
January 23rd, 2008As part of my final project I will be implementing some encryption routines, in order to ensure that I can translate the maths involved I created a basic 'proof of concept' test. I have attached the class to this, I'll put up a JUnit test as well soon as I'll be needing that throughout the development of my project.
Once compiled just run it as such, both command lines are optional, defaults are 1024 & false respectively.
java RSAtest [bit_length (int)] [debug (Bool)]
KDE 4
January 22nd, 2008Firstly a quick install guide on Kubuntu (see http://www.kubuntu.org/announcements/kde-4.0.php for more detail):
sudo echo "deb http://ppa.launchpad.net/kubuntu-members-kde4/ubuntu gutsy main" >> /etc/apt/sources.lists
sudo apt-get update
sudo apt-get install kde4-core
I have used KDE over Gnome for a long time, simply because KDE is much more configurable than Gnome and with the leap that Vista has taken (not that I can say I like it) I was secretly looking forward to the the KDE response and managed to wait until after release.
RFC compliant POP3 Protocol C# class
January 19th, 2008For a recent project I was completing to shift email into a SQL server I produced the following, it's a bit like re-inventing the wheel but I had my own vision of how it would work and it was a simple enough process.
The Visual C# 2008 project attached builds to class library, it has a few custom exceptions and is pretty simple to use. It's RFC 1969 compliant but it doesn't support MIME attachments.
The project can be found here: http://www.blamires.co.uk/development/POP3Protocol/POP3Protocol-0.1.zip
Active Directory - account lockout monitor
January 19th, 2008In my place of work with several hundred advisors account lockouts are a very frequent occurance, and of course the system administrators must unlock them, not a difficult or time consuming task but certanly one that could be easier.
Late last year I had written a ASP.NET page which enumerated the accounts on a domain and allowed them to be unlocked on the site, so this application simply takes it into the application domain and adds some functionality sugar to the core function.
The application sits in the system tray and checks at the specified interval, listing locked accounts in a drop down. Accounts can be unlocked at once or all together.
There is a hellishly annoying pop up option that displays a bubble alert from the system tray when locked accounts are detected on the domain. It's crude but works, I'll update it here if I update it.
Requirements:
- .NET Runtime 2.0
- Permissions on the domain to modify accounts (i.e. Domain Admin)

It's compiles to a single executable file, the Visual C# Express 2008 (including binaries) can be found at http://www.blamires.co.uk/development/AccountUnlock/AccountUnlock-0.1.zip
Note to self: should be in the pub or bed.
More Javascript Love - JQuery and the mystical remove
August 30th, 2007Today I have started sewing my JQuery hat for a project at work. It really does take all the pane out of working with and manipulating the DOM in some very fancy ways, especially when it comes to cross browser compatibility.
There seem to be a few nuances within it but by enlarge it is comprehensive, very simple to use and very extensible. The one that did take a little getting around was appending to and removing the parent element. For example, I want to dynamically add to add divs to the page and when you hover over the items a 'remove' button appears, until you move off which lets you remove the item from the list.
So I have the following snippet to run when the DOM is complete:
$(document).ready(
function () {
$('.element1').hover(
function () {
$(this).addClass('hover');
$(this).append('<p class='removeButtonP'><input type='button' value='x' class='removeButton' id='removeButton'></p>');
$('.removeButton').click(
function () {
//this event needs to remove the div (.element1)
}
)
},
function () {
$('.removeButtonP').remove('p');
$(this).removeClass('hover');
}
)
}
)
I would expect the DOM (very representative!) to look like this after we had moved over the first of three divs:
document
|
|-html
|
|-head
|-body
|
|-[0] div className='element1'
|-[1] div className='element1'
|-[2] div className='element1'
|
|- p
|
|- input type='button'
so when the click(function) is called $(this.parent) should refer to element1 but it doesn't, p.parentNode is null so the DOM isn't laid out as you would expect.
To combat this i have modified the code to the below to add a dynamically created id to the div you are hovered over and places this id also in the click() function parameter. The code is commented so I won't go over it here.
$(document).ready(
function () {
$('.element1').hover(
function () {
//create a random 'GUID' value
var guid = generateGuid();
//when we add our remove button as we hover over
//we also set the id of the element we are accessing
$(this)[0].id = guid;
$(this).addClass('hover');
$(this).append('<p class='removeButtonP'><input type='button' value='x' class='removeButton' id='removeButton'></p>');
$('.removeButton').click(
function () {
//remove the specific element we are hovered over.
//remember: as this is nested in .click(function)
//$(this) refers to the input element withe the
//class .removeButton $('#'+guid).remove('div');
}
)
},
function () {
$('.removeButtonP').remove('p');
$(this).removeClass('hover');
}
)
}
)
// with thanks to http://blog.shkedy.com/ for the handy function
function generateGuid() {
var result, i, j;
result = '';
for(j=0; j<32; j++) {
if( j == 8 || j == 12|| j == 16|| j == 20)
result = result + '-';
i = Math.floor(Math.random()*16).toString(16).toUpperCase();
result = result + i;
}
return result
}