Tuesday, May 26, 2009

Create Messagebox / popup for Java

//Assuming that the current object is a JFrame:

JOptionPane.showMessageDialog(this, "Some Message");

Monday, May 25, 2009

Php declare a constant

define("CONSTANT", "Hello world.");
echo CONSTANT; // outputs "Hello world."

Monday, April 20, 2009

For loop of death

This is a way to somewhat defend yourself when a process keeps on respawning itself and won't go away. This happens quite a bit when XP gets infiltrated by malware.




for /l %a in (1,1,1000000) do taskkill /im malware.exe /f

Universal scripted uninstall (XP)

Given the displayname value, this vbscript will go and find it in the registry and uninstall the corresponding program.

This is where it searches:

hklm\software\microsoft\windows\currentversion\uninstall



' arg 1 - displayname


if (wscript.arguments.count > 0 ) then

set shell = wscript.createobject("wscript.shell")
strcmd = "reg query hklm\software\microsoft\windows\currentversion\uninstall /s"

set oexec = shell.exec(strcmd)

temp = 0
parent = ""

do while not oexec.stdout.atendofstream

strline = oexec.stdout.readline


if len(strline) > 0 then
a=split(strline,vbtab)
if mid(trim(a(0)),1,4) = "HKEY" then
b = split(trim(a(0)),"\")
parent = b(ubound(b))
temp = 1
end if
alen = ubound(a) + 1
if alen >= 3 then
if trim(a(0)) = "DisplayName" and trim(a(2)) = wscript.arguments(0) and temp = 1 then
wscript.echo "msiexec /x " & parent & " /qn"
temp = 0
shell.exec("msiexec /x " & parent & " /qn")
exit do
end if

end if
end if
loop




end if

Sunday, April 19, 2009

Solution to generating markers along a route at a regular interval

I found this neat javascript extension for the google map api. Here is the link:

http://econym.org.uk/gmap/epoly.htm

You specify the distance and give it a polyline and it returns an array of points along the route.



map.setCenter(new GLatLng(42.351505,-71.094455), 15);
var directionsPanel = document.getElementById("directions_div");
var directions = new GDirections(map, directionsPanel);
var address = "from: trenton, nj to: philadelphia, pa";

directions.load(new_address);
if (directions == null){
alert("Error: directions object is null");
return;
}

var pl = directions.getPolyline();

if (pl == null){
alert("Error: polyline object is null");
return;
}

var points = pl.GetPointsAtDistance(1609.344);

if (points == null){
return;
}

for (var i=0; i
map.addOverlay(new GMarker(points[i]));
}



Friday, December 19, 2008

Viruses are back again!

Just when you thought XP Antivirus 2008 died out, enter AntiSpyware 2009. This piece of crap gets on your machine by screwing up internet explorer and the startup environment. The damn thing protects itself even in safe mode. I'm not sure how it does this; usually this is done with winlogon.exe, but the winlogon registry key seemed to be clean. We've just been reghosting the machine. Watch where you click! When you see a dialog box about spyware (and it's definitely not your antivirus software) restart your machine (this dialog box is from internet explorer).

Blackberry desktop manager

Working with the BDM has not been a general pleasure for me and other technicians where I work. It doesn't sync all the time, most likely due to corrupt organizer data and/or buggy software. The weird thing is that it was working kind alright when we had an Exchange server, but it got crappy when we migrated to a MAPI connector with Sun. I got it syncing by installing the exchange redirector BDM (we're still using outlook) and disabling redirection?! In the process of stumbling on this, I became familiar with just about every troubleshooting BB trick. Fun!