April 9, 2008

Download files from terminal

I had come across a mp3 file online that would only load half way, or so I though. Apparently it wold load the whole thing but Safari thought that it was bigger than that, so it would never give me the option to download it. Frustrated after having it load a few different times I looked for a better solution, the Terminal! I figured that there must be some way to download file from terminal. I knew of wget, however that is not installed by default in 10.4, and I did not feel like downloading and installing the fink packages. Instead I found the cURL command...


curl -o "address"


The -o is for file output, see the curl manpage for more info.

April 5, 2008

PHP RC4 Encryption

One of the harder encryption problems comes when you need to encrypt something but need to also be able to decrypt it as well. I ran into such a problem recently in PHP. The regular simple methods such as sha1 or MD5 with a simple salt would not work because they are only one way, and to make matters worse the crypto modules I needed for a solution where not installed on the server.

Luckily I stumbled upon RC4Cript a simple php class that supports a simple RC4 encryption. Although RC4 is not exactly the safest encription Wikipedia, it was fine for simply securing the data I had, and I did not feel up to the task of coming up with a better solution. It took a while to get it to work because I was confused into thinking that I needed bin2hex() after encrypting it, however that is simply to give a more readable form, leave it as is when using the encrypted text in the decrypt function. Other than that, the source has an example that is pretty self explanatory.

April 4, 2008

Sonic CD in XP




After such a ridiculous week I felt like digging out my copy of Sonic CD. I had found this at a game store at home many years ago. It was one of the best purchases I have ever made, not just because the game is awesome, but because the soundtrack is in CD form so you can just pop the cd in a player and listen. Something I was ecstatic about finding out back when I was quite a bit younger and CD players where all the rage. Ah, that was a while ago back before IPods ever existed.

This was also one of my favorite sonic games because of two levels, wacky workbench, which had electrified floors which would shoot sonic to the ceiling for better or worse, and stardust speedway which was just long twist and runs with a awesome background and music. However after getting to the last level I was reminded of the one really horrible part in the game, the huge pit you must cross at the last level, which I always fall and die over and over again at.

If you even get a chance you grab this game take it, a great addition to a classic game collection, definitely better then the rather lame 3D attempts at a sonic games that have come out in recent years. 2D Side Scrolling FTW!

The game was coded for Windows 95/98 so you will need this patch to play it in XP however no idea about Vista.

April 3, 2008

Fortran 95 BattleShip


Because I want to try taking every programing the CS Department offers this semester was Fortran. Definitely not quite like the other languages I know, but after getting used to it, I can do almost everything I can with C short of graphics and some string manipulation. After some short homework assignments, we where given our first big assignment, two player ascii battleship. Simple enough to complete in the 4 weeks we where given. I decided however to up the ante and add a simple ai system for one player games. Nothing fancy, just a random seek, with a focus on areas when something was hit, sill very easy to beat every-time. Yet it was somewhat impressive and if nothing else made it easier to test the program because I did not have to play against myself everytime.

I have uploaded it here with the Mac and Windows compiled versions plus source.

Fortran was definitely not designed with games in mind, but as with most programing languages with some careful planing and a bit of force you can easily get around such constraints.