Friday, October 1, 2010

Tips for filing a support ticket with properietary software that you use at work

1. Be friendly but make the case that you're incapable of doing some part of your job properly. People that yell the loudest (but are friendly) and make a strong case will typically have their issues fixed first. You want to create a sense of guilt at the vendor, not hate, so someone will be more likely to work overtime or bust their ass to fix your problem.
2. You describe clearly what the problem is (more than just "it doesn't work")
3. Describe clear steps to reproduce the problem from start to finish. Include your starting point, relevant data entered and items clicked. This is very important, because it takes forever to fix a bug that can't be easily duplicated. Further, you might get stuck with nothing happening because they think you're doing something wrong.
4. Describe the results you're seeing ("Error Message _____", calculation is 10 cents off, field that's allowed to be blank is required, etc)
5. Describe the results you should be seeing. This is important because the software developer should have a QA team and be able to take the steps from #2 and make sure they've actually fixed the problem instead of simply breaking something in a different way.

Thursday, August 5, 2010

Capturing Variable Type Data By Running PHP

PHP is hard to automatically convert to other languages because there is little type information hardcoded into it. Here's some sample code that uses the debug interface to extract type information out for variables. For now, it just dumps the type data to stdout. Presumably you would need to save this to some sort of sqlite database and run all of your automated tests to ensure full code coverage. Then you could translate your parsed PHP to another language with the additional information known.



// Use xdebug to determine type information about all of the executed parts of your script
// to run, 1: execute this
// 2: export XDEBUG_CONFIG="idekey=session_name remote_autostart=1 remote_host=127.0.0.1 remote_enable=1"
// 3: run your cli php script

// Set time limit to indefinite execution
set_time_limit (0);

// Set the ip and port we will listen on
$address = '127.0.0.1';
$port = 9000;

// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
// Bind the socket to an address/port
socket_bind($sock, $address, $port) or die('Could not bind to address');
// Start listening for connections
socket_listen($sock);

/* Accept incoming requests and handle them as child processes */
$client = socket_accept($sock);

// Read the input from the client – 1024 bytes
$input = socket_read($client, 1024);
echo($input);
echo("\n");
// Strip all white spaces from input
$output = preg_replace("/[ \t\n\r]/","",$input).chr(0);
$doc = new DOMDocument();
function read_debugger()
{
global $client;
$string = '';
$char = socket_read($client, 1);
while(! socket_error() && $char <> "\0") {
$string .= $char;
$char = socket_read($client, 1);
}
return $string;
}
while(! socket_last_error($client)) {
$i++;
socket_write($client, "step_into -i ".$i."\0");
$file_line_info = socket_read($client, 1024);
preg_match('/filename="(.*?)"/', $file_line_info, $matches);
$line_no = $matches[1];
preg_match('/lineno="(.*?)"/', $file_line_info, $matches);
$filename = $matches[1];
echo("$filename : $line_no ");
$i++;
socket_write($client, "context_get -i ".$i."\0");
$dummy = read_debugger();
$context_info = read_debugger();

if (!($doc->loadXML($context_info))) {
die("FAIL ON ".$context_info);
}
$propertyNodes = $doc->getElementsByTagName('property');
for($j = 0; $j < $propertyNodes->length; $j++) {
$property = $propertyNodes->item($j);
echo($property->getAttribute('fullname').':'.$property->getAttribute('type').' ');
}

echo("\n");
}
// Close the client (child) socket
socket_close($client);

// Close the master sockets
socket_close($sock);

Wednesday, April 28, 2010

Bumper Stickers

A friend is selling some here: http://getoffyourfuckingphone.com/