Archive | Software RSS for this section

Play the card game “War” in my avatar

Since my previous avatar DDOSed my router, today I wrote a less popular avatar game. The only game I could think of that has no need for actual user input was the card game war. So I implemented it in my avatar. You can play too, by simply refreshing this image:

Features:

  • Proper handeling of running out of cards during a “war”
  • War cards are show (with appropriate cards face up or down)
  • Independent games for each ip address playing
  • Deck state stored in database between refreshes
  • Special WIN/LOSE screens

How I DDOSed myself with an avatar

Building on my previous avatar hack, I set out to design an avatar that was also an interactive game. The game I eventually settled on was one where you compete with the other users to see who can load the avatar the most times. The image you are served shows your ranking as compared to the other users. It looked like this:

And true to its word, every time you refreshed it, your number went up, and you could climb to the top. I thought it would be fun, and a person or two might even refresh it a few times to get to the top. So, before I went to bed, I set it as my avatar on a forum I frequent. When I woke up the next morning Read More…

Php only serving one page at a time [fix!]

After years of confusion I finally found the solution to why php was only serving one page at a time.

When you execute session_start() the session array for that user gets locked to prevent concurrent write errors. Until the script finishes or you run session_write_close() any other script that tries to access that session will stall.

So, the fix is to run session_write_close() after you are done writing session data but before anything time consuming (large shell_exec()s, sql querys, downloads).

Your Debut Album (Automated)

The internet has spawned a hilarious method for determining Your Debut Album and the results are surprisingly hilarious. It works like this:

1 – Go to http://en.wikipedia.org/wiki/Special:Random
The first random Wikipedia article you get is the name of your band.

2 – Go to Random quotations: http://www.quotationspage.com/random.php3
The last four words of the very last quote of the page is the title of your first album.

If you want to do this again, you’ll hit refresh to generate new quotes, because clicking the quotes link again will just give you the same quotes over and over again.

3 – Go to flickr’s “explore the last seven days” http://www.flickr.com/explore/interesting/7days/
Third picture, no matter what it is, will be your album cover.

Put it all together, that’s your debut album.

I found this very funny, so I wrote a quick and dirty script to automate the process, and I must say, seeing an actual image of the album only makes it funnier. Have your debut album automatically generated here. Be patient though, it takes a second to get all the data and put it together. The images are fully bookmarkable/shareable and you can simply hit refresh to get a new one!

Let me know what you think in the comments.

PHP: Avatar Hack

I am a member of a web forum which allows you to use an Avatar image of your choice. You simply give them the url of the image. The ability of php to generate images lead me to try to come up with ways to take advantage of this system.

My first attempt at a dynamically generated avatar was thwarted by the sites form verification. It rejected my avatar because it pointed to a .php file instead of an image file. To get around this, I created a directory called:

/avatar.jpg

that contained an index.php file. Therefore when a user requests:

http://www.classicalcode.com/avatar.jpg

the server resolves that to:

http://www.classicalcode.com/avatar.jpg/index.php

and that script generates an image which it then returns with .jpg headers.

Now that the image is dynamically generated, the question is: what can the script do? Currently it logs ip addresses, browsers and operating systems, does a google image search, finds a random image for a search term, and displays that image along with the users ip and the total times that the avatar has been requested. The source code can be found here: avatar_source.txt

Drawing mandalas with PHP for my Papa

A sample mandala I have generated

The earliest memories I have of computers is a contraption my dad rigged up that would draw mandalas on a screen. Later in my life he wrote software that would plot large mandalas on his huge plotters.

In my last project, I learned about image generation using PHP and realized that it might be possible to use PHP functions to draw mandalas. After a couple hours of relearning trig, I was able to create a script that outputs a .png image of a mandala based on the size and number of points that you give it.

Give it a try:



Source code: here.

Get alerts when the emails you send are opened

Inspired by spypig.com, a site that helps you track when your emails are opened, I decided to see if I could write a script with the same functionality. It tuned out to be a rather interesting project.

Here it is: http://www.classicalcode.com/t.php

It works by generating an image which you embed in your email. Then when your recipeint reads their email, their email client downloads that image. Downloading that image triggers a script on my server which then sends you an email.

In order to make the image look less suspicious I implemented a feature where the image is a string of text of the senders choosing. Example:

An Example of a tracker image from my email tracking project

Give it a try!

PGP Desktop was causing OS X to run slowly

After months of my laptop running slower and slower, to the point where I stopped using it completely, I broke down and took it into the apple store. They checked everything they could think of but eventually told me they thought that I just had installed too many “apps” that were running the background. I have been running GPG for some time now, but still had PGP Desktop installed, because I simply could not figure out how to uninstall it. Somehow I managed to overlook the giant UNINSTALL button. Anyway, turns out that PGP Desktop was strangling my computer. But don’t worry. It’s all better now.

You might be a nerd if: You write a perl script to count sheep for you…

… in binary.

I couldn’t seep last night, so I decided to count sheep. Counting reminded me of the time my brother mentioned that one could count in binary on ones fingers. That sounded pleasantly meditative, so I set my brain to work on figuring out how one might do that. Before long I had counted quite high, and was fascinated by the way the system worked. Naturally my brain wandered to: “how might a computer do this simple task?” By now I had completely lost interest in sleep, so I sneaked out of bed, turned on the laptop and cranked out a little application to count in binary for me. I was then a free to go back to sleep, having automated the tedious task of counting sheep.

The code follows:

Read More…

How to actively connect to a local Verlihub

Ever since I moved my DC hub to my apartment, I have been unable to connect to the hub in active mode from a client on the local intranet.

The solution:

Set the Verlihub database’s alternate_ip variable for your user to your external ip.

The command I issues was:
!regset captbaritone alternate_ip 67.188.34.158


This allowed me to connect to the hub (from the local network) in active mode, without getting kicked for my reported ip (local ip) not matching my “real” ip (external ip).

The only remaining problem, is that I will have to manually change this each time my external ip address changes. I suppose it would be possible to write a deamon to check the address every now and again, and update the mysql database if it changes. But thats a lot of work.

Page 2 of 3123