More optical illusions
I haven’t seen an optical illusion like these before. You stare at some sort of colored version of a black & white photo, and then quickly swap to the black & white photo. The photo will appear as if it was the normal colored version until you move your eyes. Crazy!
See also: my previous post about optical illusions.
Adult Swim news
AdultSwim.com now looks more awesome than before.
Perfect Hair Forever may or may not be back in production. By that I mean it’s definitely in production. Maybe. Not. You can watch all 6 episodes at Adult Swim Fix.
A full-length Fullmetal Alchemist full movie is fully coming to full American theaters. Check out this full trailer:
Finally, here’s the Adult Swim schedule for the rest of the year.
New quarter
I’m very glad that summer quarter is over. The Organizational Behavior class was okay, I guess, but Financial Accounting was just torturous. The professor was fine, the class was fine, but I’ve learned something very important: I hate accounting. I understand it, I understand the usefulness and importance of it, but I hate hate hate doing it.
I was soooo bored during Financial Accounting classes that I actually started doodling on my PowerPoint print-outs, junior high style. If I had to choose where to spend the last two hours of my life, it would be in Financial Accounting because those hours are somehow much, much longer than 2 hours of, say, watching paint dry, or watching a Pauly Shore movie.
Before a recent exam, I got so bored studying that I started taking pictures of my boring surroundings. I hope you enjoy.
Penny Arcade: The Game
It was only a matter of time until the premiere gaming/nerd comic became a game franchise itself. I look forward to Penny Arcade: The Game, and the eventual Penny Arcade: The Arcade Game, and of course the spinoff sprite comic, Penny Arcade: The Arcade Game: The Comic.
Speaking of Penny Arcade, they just finished up probably the longest serial that I can remember: Armadeaddon. It’s basically a series packed full of joke for long-time loyal readers. It features a lot of favorite peripherial characters: Annarchy, Jim, Frank, that one Mac guy with the goggles, and everyone’s favorite sentient juicer.
Another handy Opera button
I’m finding Technorati more and more handy as time goes by. I came up with an Opera button that will look up any blogs referencing the current URL. Click the link below to add it to your custom buttons.
Share and enjoy.
New office
So, yeah, I moved into a new office building like a month ago. I took a whole bunch of pictures and forgot to post them.
It’s not a bad place. It has its upsides (parking, cheap snacks, conference rooms) and its downsides (2 men’s room stalls, farther from customers, close quarters), but I think it’s going much better than I expected. The men’s room is still an issue, but everyone seems to be very courteous and clean so far. So far. There was a ridiculous issue with the 1 non-handicapped stall within the first week. Let’s just say that there was no plunger before, and there is a plunger now.
Here’s the pictures:
New cat
I was taking pictures of books to sell on eBay, and I realized I had a whole bunch of pictures on there that I meant to post earlier, but didn’t. So I’m going to start posting some of them and hopefully not completely boring you to death.
Firstly, our new cat. After months of wild, unsuccessful gesticulating at craigslist ads promising free kittens, my wife just brings one home out of the blue (not via craigslist, btw). The kitten had already been given some stupid, trendy name, so I argued that it be given a different one (even though I never call animals by name anyway). After much discussion, we settled on Friday, since that was the day the cat came into our possesion.
Anyway, she is a crazy kitten who likes to hide and pounce on my feet. She also claimed an expensive Pottery Barn basket as her own as shown in the pictures.
AJAX without XMLHttpRequest object
While the hype of AJAX may be a bit overblown, it’s still a useful tool and very fun to program with. One of the issues I’ve had with my two previous examples (AJAX username availability checking and A simple AJAX example) is that most AJAX out there today depends on the XmlHttpRequest JavaScript object. It’s certainly available in IE, FireFox, Opera, etc, but in IE, it has to be called as an ActiveX object, whereas in Opera, FireFox, etc, ActiveX won’t fly. This means you have to have a darn good browser detection algorithm, or else you risk a percentage of users losing functionality.
Alternatively, we could do some AJAX without the XmlHttpRequest object. But how? Some guy at PHPit (Google Cache) has figured out a way.
Like Rasmus’s tutorial, this is a pretty straight-forward approach, and you should be running some AJAX in no time. If you want, you can skip right ahead to three demos that I’ve prepared.
As before, there will be three parts: the PHP page that the user visits, the JavaScript file containing the engine, and a PHP page (or pages) that will be called by the engine. First, the user’s PHP page (demo.php):
<h3>Demo from PHPit</h3>
<p>This demo simply grabs text from another PHP file. Nothing much to see here, just
demonstrating the basic concept.</p>
<div id="contentdiv"></div>
<input type="button" onclick="ajax_do ('page1.php');" value="Get content" />
Notice the empty div tags. As before, we will be using the DOM and the innerHTML element to update the content. The ajax_do function is the engine, and the one parameter it gets is the PHP page to call (along with any parameters in querystring form).
Next, the engine (engine.js):
// Get base url
the_url = document.location.href;
xend = the_url.lastIndexOf("/") + 1;
var base_url = the_url.substring(0, xend);
function ajax_do (the_url)
{
// this first part is pretty darn hacky, but if we need to make multiple calls with the
// same 'the_url', then most browsers will only work one time
// so we need to make each call unique as possible.
// two random querystring names and values should do the trick
// if there were no querystrings, we need to start with a '?'
if (the_url.indexOf("?") != -1) {
the_url += "&";
} else {
the_url += "?";
}
the_url += Math.random(0,1000) + "=" + Math.random(0,1000)
+ "&" + Math.random(0,1000) + "=" + Math.random(0,1000);
// note that it is possible to get the same 4 random numbers each time,
// but a very slim possibility. That doesn't make the above part any less hacky
// Does URL begin with http?
if (the_url.substring(0, 4) != 'http') {
the_url = base_url + the_url;
}
// Create new JS element
var jsel = document.createElement('SCRIPT');
jsel.type = 'text/javascript';
jsel.src = the_url;
// Append JS element (therefore executing the 'AJAX' call)
document.body.appendChild (jsel);
}
This simply creates a new SCRIPT element on the current document and loads the filename specified as that script. Once this happens, the loaded script will execute.
Finally, the file being called by the engine (page1.php):
<?php
// nothing dynamic about this, but it's just for demo purposes
$html = "<p><b>This content came from our AJAX Engine</b></p>";
?>
div = document.getElementById('contentdiv');
div.innerHTML = '<?php echo $html; ?>';
The code within the php tags can do anything you like–it can look up a username passed through the querystring, whatever. The output from the PHP should be put into the $html string. The bottom two lines of this page should always be the javascript shown, changing only the name of the ID to be updated (contentdiv, in this case).
Once you have engine.js in place, you can make any number of PHP files for it to interact with. I’ve thought of two examples (for more good examples of appropriate AJAX uses, check out Alex Bosworth’s 10 Places You Must Use AJAX): username availability checking (which I did before), and Digg-style voting.
Here’s the code for username availability checking:
<?php
$theusername = $_GET['username'];
//error checking on the username
// no spaces allowed
if(strpos($theusername," ") === true) {
$html = "Usernames may not contain a space.";
// must be at least 1 character
} else if(strlen($theusername) == 0) {
$html = "<p>Please enter a username and try again.</p>";
// now check to see if it's already in the db
} else {
// connect to whatever database...(I'm using MySQL)
// check to see if that username has been used in my comments
$sqlquery = mysql_query("SELECT count(username) AS cnt
FROM blog_comment
WHERE username = " . PrepSQL($theusername)
);
$rs = mysql_fetch_assoc($sqlquery);
if($rs['cnt'] == 0) {
$html = "<p>Congratulations, the name <b>" . $theusername
. "</b> is available.</p>";
} else {
$html = "<p>Sorry, the name <b>" . $theusername
. "</b> is not available.</p>";
}
}
?>
div = document.getElementById('nameavailable');
div.innerHTML = '<?php echo $html; ?>';
And the HTML you should put in demo.php to use it:
<h3>Username availability demo</h3>
<p>This demo will check to see if a given username is valid and if it's present or not
in a database containing existing usernames. This uses my "comments" database, so try
"Sithlet" or "Jonny" for existing names.</p>
<p>Enter the name to check for: <input type="text"
name="formName" id="formName" /></p>
<div id="nameavailable"></div>
<input type="button"
onclick="ajax_do('namecheck.php?username=' + document.getElementById('formName').value);"
value="Check Username Availability" />
Here’s the code for Digg style voting:
<?php
// how did the user vote?
if($_GET['awesome'] == "1") {
$awesome = 1;
$notawesome = 0;
} elseif($_GET['notawesome'] == "1") {
$awesome = 0;
$notawesome = 1;
} else {
echo("This file is only meant to be used as part of an AJAX application.");
exit();
}
// connect to whatever database (I'm using MySQL)
// ...snip...
// record the users vote
mysql_query("INSERT INTO voting_table (awesome, notawesome)
VALUES (" . $awesome . ", " . $notawesome . ")");
// count the votes so far
// I'm simply storing each vote in a table with two fields, and then just summing
// those fields to count votes
$sqlquery = mysql_query("SELECT sum(awesome) AS awesome_votes,
sum(notawesome) AS notawesome_votes
FROM voting_table");
$rs = mysql_fetch_assoc($sqlquery);
$html = "<p>Awesome votes: " . $rs['awesome_votes'] . "</p>"
. "<p>Not awesome votes: " . $rs['notawesome_votes'] . "</p>";
?>
// 'votingresults' is the ID on the div tag that I want to update
div = document.getElementById('votingresults');
div.innerHTML = '<?php echo $html; ?>';
And the HTML/PHP to put in demo.php:
<h3>Voting demo</h3>
<p>Finally, this is something I've not done before in AJAX, but it's still pretty easy.
This is very much like the AJAX on <a href="http://www.digg.com">Digg</a>. Below is the
vote count as of whenever this page was loaded. Click "awesome" or "not awesome" to cast
your own vote. The votes will then be updated from the database, so if someone else voted
while you were wasting time reading this text, their vote will appear too.</p>
<input type="button" onclick="ajax_do('vote.php?awesome=1');" value="Awesome" />
<input type="button" onclick="ajax_do('vote.php?notawesome=1');" value="Not Awesome" />
<div id="votingresults">
<?php
// connect to whatever database (I use MySQL)
// ... snip ...
// count the votes so far
// this is an initial tally, as the div we are in will be updated if the user voted
$sqlquery = mysql_query("SELECT sum(awesome) AS awesome_votes,
sum(notawesome) AS notawesome_votes
FROM voting_table");
$rs = mysql_fetch_assoc($sqlquery);
$html = "<p>Awesome votes: " . $rs['awesome_votes'] . "</p>"
. "<p>Not awesome votes: " . $rs['notawesome_votes'] . "</p>";
echo($html);
?>
</div>
I’ve attached the full source code for you to download, and you can check out
all three demos on the same page.
Video Game Music: The Best and the Worst
Here are the worst songs in video games from Error Macro. I’m gonna get those fools; they want to play with my emeralds? They playin’ with the wrong guy. I didn’t see any mention of the absolute worst song in the history of gaming: Girl in the Tower, from the King’s Quest 6 soundtrack. They expected people to call top 40 stations and request this? I dare you to listen to the whole thing.
Anyway, I thought I would take this opportunity to point out some of my favorite video game music.
- Maniac Mansion for the NES. This is one of the best games of all time. It is the complete package. Storyline, gameplay, graphics (at the time), and of course, music. Check out Dave’s Theme and Bernard’s Theme.
- Mega Man 2 & 3 for the NES. As far as I’m concerned, Mega Man 2 is the pinnacle of gaming, and the music stands the test of time. Give a listen to Quickman’s stage from 2 and Gemini Man’s stage from 3. Also I emplore you to please check out the excellent OC Remixes for both games. Most of them are fantastic (check out Gemini Salsa).
- Final Fantasy 7 for the PSX/PC. One of my favorite RPGs. A frenetic storyline with corresponding music that sets the mood. Aeris’s Death is one of the most emotional moments in video game history, and the music is part of the reason. Also, the J-E-N-O-V-A boss music is always a sign that you are in for a real fight.
- Chrono Trigger for the SNES. Another classic Square RPG with equally classic soundtrack. Check out the OC Remix, The Incredible Singing Robot, complete with vocals! It’ll make you laugh, it’ll make you cry, and maybe, just maybe, you’ll learn a little something…about life.
- Secret of Mana for the SNES. Pretty laid back tunes that make leveling up more enjoyable. I could probably listen to Traveling Music all day. Also, check out the Fear of the Flava OC Remix for even more traveling music.
- StarFox for the SNES/n64. I’m always reminded of John Williams when I play through this game. Do a barrel roll! Press Z or R twice and listen to this Corneria Theme remix.
- Parappa the Rapper for the PSX. Yeah, it’s corny, but it’s so much fun. Yes, I know all the words to Kick! Punch!, and no I will not sing them for you.
Frosted mini-games
Not sure if this is a good tie-in or not…
Collect all 5 Xbox® Mini Games found inside specially marked Kellogg’s* cereals.
O RLY? Perhaps an extra special treat in my Hal-O’s?
- Spaceship Blaster – Eliminate the enemy spaceships before they reach you
- Motorcycle Madness – Avoid or eliminate oncoming traffic to move up a level and win
- Disco Mania – Copy the dance instructor’s moves to move through the levels
- Robo Blast – Capture the robots before they escape
- Mystic Castle – Navigate through the castle, collecting gems and defeating enemies
Uh huh. So really, nothing to do with the Xbox, put in cereal that probably isn’t much of the tarket market of the Xbox. Though maybe a lot of males aged 18-40 still eat Fruit Loops for breakfast, who am I to say? Heck, I’d eat Kid Cuisine at work if it was socially acceptable. I mean, come on, it’s fun AND food rolled into ONE.
Digg this article!