JAVA: Built-in FTP Functionality

Today I am continuing my work on a Java-based desktop program for image compression, upload and assignment; upload and assignment are the goals for today.

A quick Google search returned http://www.nsftools.com/tips/JavaFtp.htm, which has been incremental in me completing this phase of my application. A big healthy dose of kudos goes out to Julian Robichaux for his great article.

Nick

PHP: sample output of integer-based array after serialize()

I was hoping to avoid writing a script to give me this basic information, but alas, I did not.

There are plenty of examples of serializing string-based arrays, but I found none with integers — granted I did not waste much time searching. Anyway, below is the PHP code, the the appropriate output.

<?php echo serialize(array(1,2,3)); ?>

a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}

Nick

Passing/calling a function by its name in JavaScript

Today, I needed some code that would allow me to pass a function name as a parameter, and then call that function on the fly. Well, today, I found out something very useful. You can actually pass the function itself into the function, and then use the built in method called apply to call the function.

To help you more easily understand this, I have included an example:

function callMe( useThisFunction, parameter )
{
    useThisFunction.apply( useThisFunction, Array(paramater) );
}

/**************************************************/

function test( outputMe )
{
    alert(outputMe);
}

/**************************************************/

document.onload = function()
{
    callMe( test, ‘Look at me, I have been outed!’ );
};

Enjoy!

Nick

Turning off ‘An error occurred on the server … ’

The full error message actually reads:

An error occurred on the server when processing the URL. Please contact the system administrator

I recently needed a more descriptive error message when debugging a script, and had too much trouble finding the answer I needed. The good news is, if you are reading this, I will tell you how to easily disable the default error message so that IIS will display a much more appropriate error message.

Before I go on, I do want to let you know that this setting should only be set when debugging a script. There are security risks with showing the exact error message to a [malicious] visitor.

  • Open IIS
  • Expand the local computer directory
  • Expand the ‘Web Sites’ directory
  • Right-click the website you are interested in showing detailed errors, select ‘Properties’.
  • Select the ‘Home Directory’ tab across the top
  • Select the ‘Configuration…’ button in the lower-right
  • Select the ‘Debugging’ tab across the top [far right]
  • Under ‘Error messages for script errors’, make sure you have the first radio button selected; ‘Send detailed ASP error messages to client’.

And there you have it. Go back to your browser and hit refresh. Presto!

Nick

MySQL Data Type INT: Signed vs. Unsigned

I have been meaning to actually look at the storage differences between signed and unsigned for a few months now, and I have finally remembered to do it! A quick Google search returned just the information I was looking for, so I thought that I would repost the blurb that was worthwhile.

An UNSIGNED INT can go from 0 to 4294967295 (aprox 4 billion). A SIGNED INT , on the other hand, starts at -2147483648 and goes to 2147483648 (aprox 2 billion).

source: http://www.verysimple.com/blog/2006/10/22/mysql-data-type-optimization-tips/

Nick