Oh, and, hi.

February 7th, 2010

Been a long time since I’ve blogged. As the last post can show, I’ve been wrapped up in programming. I’ve been doing alot of it lately. I might start making more posts with something programming related.

The (extremely) hard way of extracting data…

February 7th, 2010

Anybody familiar with Java will have a good laugh at this.

Today I was messing with Minecraft’s protocol. The client sends a login packet that looks like this:
[code="plain""]07 PlayerName asdfpasswordstring 0[/code]
Now, to authenticate a player, you need to extract the PlayerName and password hash (asdfpasswordstring above. :P ) from this.

Well, I started fiddling and came up with this after a little while (omitting the socket assigner, etc.):

char[] charbuffer = new char[135];

sin.read(charbuffer, 0, 135);
sout.println("Bye.");

System.out.println(socket.getInetAddress().toString() + " disconnected.");

System.out.println("Got following data: (total chars: " + charbuffer.length + ")");

System.out.print((int)charbuffer[0]);
System.out.print((int)charbuffer[1]);

System.out.println("Compressing array..");

String compressedArray = "";

for(int iii = 2; iii < (charbuffer.length - 2); iii++)
{
	compressedArray = compressedArray + charbuffer[iii];
}

System.out.println("Compress succeeded.\nSplitting compressed array into new array..");

String[] clutteredArray = compressedArray.split(" ");

System.out.println("Split succeeded.\nArray length: " + clutteredArray.length);

System.out.println("Attempting removal of spaces from cluttered array.");

String[] playerInfo = new String[2];

int writeDex = 0;

for(int iii = 0; iii < clutteredArray.length; iii++)
{
	if(!(clutteredArray[iii].equals("")) && writeDex < 2)
	{
		System.out.println("Found data.");

		playerInfo[writeDex] = clutteredArray[iii];
		writeDex++;
	}
}

System.out.println("Data extracted from cluttered array. New array length: " + playerInfo.length + "\nContents: ");

for(int iii = 0; iii < playerInfo.length; iii++)
{
	System.out.print("[" + iii + "]" + playerInfo[iii]);
}

And then I suddenly realized I could just use substring() and replace() then did an epic facepalm.

I did this and the above became this:

char[] charbuffer = new char[134];

sin.read(charbuffer, 0, 134);
sout.println("Bye.");

System.out.println("");

System.out.println(socket.getInetAddress().toString() + " disconnected.");

System.out.println("Got total chars: " + charbuffer.length + "\nCompressing array.");

String compressedArray = "";

for(int iii = 0; iii < charbuffer.length; iii++)
{
	compressedArray = compressedArray + charbuffer[iii];
}

System.out.println("Array compressed.\nExtracting data.");

String[] playerInfo = new String[2];

playerInfo[0] = compressedArray.substring(2,63).replace(" ", "");
playerInfo[1] = compressedArray.substring(66,130).replace(" ", "");

System.out.println("Got data: " + playerInfo[0] + ", " + playerInfo[1]);

…and getting the time

October 24th, 2009

In 24-hour format. In CMD.

SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~0,1%.%time:~3,2%]
IF "%time:~0,2%" == " 1" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 2" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 3" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 4" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 5" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 6" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 7" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 8" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]
IF "%time:~0,2%" == " 9" SET thetimeanddate=%date:~4,2%-%date:~7,2%-%date:~10,4%[0%time:~1,1%.%time:~3,2%]

Each if is there to throw in the missing 0 if the hour is from 1-9. Weeee.

Decided to make this since I decided to make a dump of my Minecraft server’s backups. And then that led to fixing up the times in the filenames.

Makin’ Music

October 17th, 2009

Batch files, checking validity of user input

September 14th, 2009

Well, today I decided to add to my Minecraft server’s backup script.

Before it would just make a copy of the server_level.dat and rename it with the time and date. I extended it to be a bit more interactive, adding a selection for the server’s current mode. (ie, Sunken or Preflood. I run an underwater build server.) And of course, I wanted to add a validity of user input check. I figured I could just do a if '%userinput%' != '0' || '1' || '2' goto invalidinput but I was wrong. So I found a hack around this, and I’m sharing it for anyone who may need it.

@echo off
:getnum
set /p mytestvar="Input 3, 4, or 23 please: "
echo.

rem the workaround
if '%mytestvar' == '3' goto isvalid
if '%mytestvar' == '4' goto isvalid
if '%mytestvar' == '23' (
goto isvalid
) else (
goto isnotvalid
)

:isvalid
echo it's valid!
pause
rem need this so it doesn't go over into isnotvalid
exit

:isnotvalid
echo it's not valid!
goto getnum

The valid numbers, or strings even, can be listed in any order. It’ll still work.
A bit tedious, listing each valid input option with its own if statement, but it’s better than having it just exit if the input is invalid.

So there. My 7-lined backup script bumped up to 45 lines, just to add the mode of the server automatically.
God, I love automation.

The Lettere E

September 11th, 2009

I gote borede, sittinge ine Frenche, one daye. Thise thoughte floatede intoe mye minde.. The lettere E cane be placede one nearlye anye worde note endinge ine E, ande the worde cane stille be pronouncede prettye muche the same. Whate doe youe thinke?

Stereoscopical nonsense (with a hint of panoramia)

August 14th, 2009

Is awesome. But requires wide monitors. So some resizing is usually needed. Either that, or the images are just tiny little things. Anyway, combine this with rope art, and you get this.

What is stereoscopic imagery you ask? It’s when you take two pictures, one in the general area of where the left eye would be, and then the other in place of the right. If you look at a properly aligned pair of images cross eyed, you’ll see them in 3D. If you have trouble crossing your eyes, try putting your index finger out in front of you, at arm length. Then move it slowly towards your face, keeping your eyes on it, until you touch your nose. As for focusing.. well, just try using your finger, placed on your nose, then shifting the focus back, from your finger onto your monitor. Good eye control is a must. :P

Stereoscopic imagery is fun. And can kinda work on any image. I took the cutout of Benie’s sub, and put two of them together, and kinda rotated one a bit so it looked as if it were being viewed from a slightly different point. It seems to be 3d. Seems. Pseudo-stereoscopica anyone?

And speaking of pseudo-stereoscopica.. Seems all stereoscopic images I’ve made up until recently were pseudo-stereoscopica. :P I just realized today that I was doing it wrong. The image taken in place of the right eye goes on the left side, and the other vice-versa. I was putting image in place of right eye on right side. Call me an idiot.

I was gonna make a stereoscopic image of my living room, but unfortunatley I am Captain Shakeywhileholdingphone.. and it’s hard to translate the phone on one single axis without translating it on another, or changing the pitch/yaw/roll. :|
And my webcam would’ve worked, for a picture of my keyboard, but it’s a cheap ass thing, and the pictures I managed to take of my keyboard were pretty much just black and white. You could make out the sillouette of my keyboard and front center speaker. Not to mention the moving issues mentioned above. So instead I made another GMod one.

And there’s panoramic imagery too. Which is taking multiple images at different rotations from the same point to capture everything that can be seen from that specific point. And then stitching it all together. At least that’s the way in which I use it. The wide POV panoramia is nice too. :P This produces something along the lines of this. Of course that’s a rather crappy example. Since I just threw it together in a few minutes. And I’m beginning to think this program was made for the wide POV kind of panoramia. :P Edit: I came across a decent panoramic picture of Dragon Forest.. Wurm nostalgia, anyone? :(

Now imagine this. Panoramic images.. With stereoscopic-ness. How awesome would that be? :)

Quite awesome. Being able to see the entirety of a single point, in 3d. Mix in enough time, and you could make multiple stereoscoporamic images for.. let’s say a house you’re planning to sell. No need to go to the house IRL, just look at it online.

Anyway, I think this concludes this blogpost. Enjoy the stereoscopica.

The dissasembleation of a laptop

July 24th, 2009

Yep. I took apart a laptop yesterday. When my grandparents arrived back in town back in May, I was gifted with a laptop. The only catch, was that the video card was a bit.. broke. But everything else worked fine. I actually managed to get the video card to work twice, with a bit of slamming, and glares. Anyway, today, I finally decided to look inside, to see if I could locate the video card. And sure enough, after about half an hour of trying to get into it from the bottom, I noticed a notch on the corner of the keyboard.. pried it up, and pulled a bit.. then the screen came off. With a bit of unscrewing, I removed what I guessed was the video card, which is is, according to a nice article found with google. Now the fun part is gonna be trying to find a video card from a laptop that was manufactured in 2004. Something tells me I’m gonna have a bit of trouble..

Anyway, like an excited noob (I’m a noob when it comes to hardware) I took a few pictures displaying the results of my toils.

the motherboard, minus vidya card

Here you can see the motherboard, minus the video card. Interesting note, most of the weight of a laptop comes from the screen. The damn thing is heavy.

the vidya card

And here’s the reason the screen shows nothing, or shows what looks like a spongey substance, moving across the screen. With changing colors, too!

stuff from the bottom

And here’s stuff I unscrewed from the bottom. Also, on top of the CD drive sits the hard drive.

screen n' stuff

And the screen, keyboard, and the panel that covers the front of the laptop. Yeah, call me idiotic for putting things on the LCD, but they don’t weigh all that much, and there’s only so much room to put things in this house. I mean, I have the bottom of the laptop sitting on a box of canned tomatoes over on the table now..

screws

And here be the screws. The screws in the line were what secured parts to the motherboard. And the little pile of screws is what kept the bottom cover of the laptop on.

Oh, and if you ever dissasemble a laptop that hasn’t had its innards accesable since it was assembled, wear a mask and bring canned air.

Higher resolution images over at my dump.

Was das holle?!

May 31st, 2009

New Wordpress version is omgawesome.

Quick run-through of what I’m upto:

C++

php

restructuring Benie’s Builds

html

counting the days left until I escape from school.

Kthxbye!

School

May 20th, 2009

Click me.