Friday, February 15, 2008

'uʍop əpısdn sı ʇsod sıɥ⊥

Some code:


#include <cstdlib>
#include <iostream>
#include <fstream>

#define BUFFERLENGTH 500

using namespace std;

// character map for upside down characters
char* charactermap[] = { "¡", ",,", "#", "$", "%", "&", ",", //33-39
")", "(", "*", "+", "´", "-", "'", "/", // 40-47
"0", "1", "&#9761;", "&#400;", "&#4281;", "S", "9", "L", "8", "6", // 48-57
":", ";", ">", "=", "<", "¿", "@", // 58-64
"&#8704;", "&#666;", "&#390;", "p", "&#8707;", "&#8498;", "&#1508;", // A-G
"H", "I", "&#383;", "&#65276;", "&#1498;", "W", "N", "O", "d", "&#8184;", // H-Q
"&#641;", "S", "&#8869;", "&#8745;", "&#923;", "M", "X", "&#411;", "Z", // R-Z
"]", "\\", "[", "^", "¯", ".", // 91-96
"&#592;", "q", "&#596;", "p", "&#601;", "&#607;", "&#387;", "&#613;", // a-h
"&#305;", "&#1360;", "&#670;", "&#1503;", "&#623;", "u", "o", "d", "b", "&#633;", // i-r
"s", "&#647;", "n", "&#652;", "&#653;", "x", "&#654;", "z", // s-z
"}", "|", "{", "~" // 123-126
};

// returns length of word
int getLength(const char* word)
{
int len = 0;
while (word[len] != 0 && len < BUFFERLENGTH)
len++;

if (len == BUFFERLENGTH)
len = 0;

return len-1;
}

// writes upside down character sequence into stream
void writeConvertedChar(ofstream& stream, char c)
{
if (c < 33 || c > 126)
stream << c;
else
stream << charactermap[c-33];
}

int main (int argc, char** argv)
{
// open input file
ifstream fin;

if (argc >= 2)
fin.open(argv[1]);
else
fin.open("data.txt");

if ( !fin )
return 1;

// open output file
ofstream fout("upsidedown.html");
if ( !fout )
return 2;

// go through input file, iterate through each line backwards,
// and call writeConvertedChar to put the upside down version of each
// character in
char buffer[BUFFERLENGTH];
while ( fin.getline(buffer, BUFFERLENGTH) )
{
cout << buffer << endl;

for (int i = getLength(buffer); i >= 0; i--)
writeConvertedChar( fout, buffer[i] );

fout << endl;
}

fin.close();
fout.close();

return 0;
}


This extremely exciting program allows me to be a prankster on message boards and post entire messages uʍop əpısdn.

Monday, February 4, 2008

Videogame Database

Link here

This was a final project for CS411: Databases.

The backend was done in mySQL via PHP, the front a mixture of CSS and Javascript (using JSON). I handled nearly all of the Javascript/JSON frontend coding, as well as some of the HTML/CSS and a few of the backend PHP queries. Another group member populated the database via perl and the power of the internet, and the result was the final product. (hosted on his webspace)

I also chose the color scheme, which might be a good reason for a company not to hire me.

Friday, February 1, 2008

The "city browser"

Link here
This was a one week web 2.0 project done for the CS242 course at the University of Illinois. The assignment was to be creative, come up with a project involving dynamic web content with no page refreshes, and to go nuts. CS242's ultimate goal was coding practice (for example, commenting code, making sure it was understandable and not a jumbled mess, and the like), so a more boring project may have been a safer bet... but a boring project would've been boring.

The result was the "city browser". I learned to use JSON in conjunction with Javascript for this assignment, and using data from yahoo and geonames.org I created a small web page that ... well, it's a little hard to explain.


Here's how it works. The user (you) types in the name of a city or specific location into the search box, then hits search. Then the following things happen:

1a) a request is sent to yahoo with whatever was entered into the box as a query
2a) Yahoo!'s JSON services return a JavaScript object with the first 10 search results
3a) those results are displayed in the left panel

1b) simultaneously, a similar request is sent to geonames.org, which collects geographic and weather data and has a JSON service of its own as well.
2b) geonames.org returns a JavaScript object with 4 locations + data.
3b) That data goes into the rightmost panel.

4) By clicking on any of the locations in the right panel, another request is sent to geonames.org. The returned data from this request is displayed in the middle panel, and includes the current weather data at that location.