Saturday, July 26, 2008

Democrats are Cool

After a lifetime of compulsive TV watching, I've learned some interesting things about politics.

Democrats are cool. Their policies are socially acceptable. They represent the downtrodden, work-class people.

Republicans are socially backward. The only reason they're not as smart as Democrats is because either:
  1. They're Southern, and don't know how to read, or
  2. They can read, but the only things they read are Christian.
Whether an individual Republican is to be mocked or pitied depends on their belligerence. Ann Coulter, for example, is extremely outspoken, and should be mocked as harshly as possible. Poor, religious people are to be pitied until they start talking about Christianity, at which point they become belligerent.

I'm not making an argument for either side here. I'm simply stating the message of the Viacom Propaganda Machine.

Saturday, June 28, 2008

Long Time Coming

OK, so I've been lazy. This is my first post in 5 months. I was going to school, but I don't really have an excuse for the last 2 months of summer vacation.

Anyway, here's some funny stuff I found in the last 5 months:

Funny Adwords - Some actual Adwords that people have seen. Pretty funny.

Demetri Martin - Findings



And here are some more Demetri Martin videos. He's funny.


Mandelbrot Set video



Ha. Clever.

I don't know if I actually have an audience, but if so - look for more posts soon!

Thursday, January 10, 2008

My Top 5 Firefox Add-ons

One of the great things about Firefox is all the cool add-ons available. If there's anything you don't like about Firefox, there is an add-on to change it. And I have the same add-ons for my Linux machine as I do for my Windows machine, so it's pretty good that way too. It's always a pain to have to switch between different tools that do the same things.

So, without further ado, here are my favorite Firefox add-ons:

  1. PDF Download
    This one allows more flexibility about what FF does with PDFs. Instead of just opening it in-browser, it allow you to download it, open it in a new window, or view it as HTML.
  2. IE View Lite
    Firefox is great, but not all sites were programmed with the idea that anyone will access them without IE. On Windows systems, this allows you to quickly view the current page in IE.
  3. Resizeable Textarea
    This gives you the Safari-like functionality of being able to resize large text fields.
  4. Server Spy
    Lets you know in a little section at the bottom of the FF window what kind of server a site is using. It's interesting information. Always fun to see the broken sites running IIS and say, "Oh, well there's your problem!"
  5. Web Developer
    By far my favorite FF add-on. This gives you a little toolbar with more web development tools than you would ever need. It gives css and javascript tools, shows you divs, classes and ids, style information for a given element, and lots more.
So enjoy these, and make the move to FF if you haven't already!

Thursday, December 13, 2007

Ethical Roads

Ethics don't exist without opposition. Luckily, the world is full of opposition. People can either hold to their ethics or give in.

If they hold to their ethics, they should be prepared to fight, be unpopular, and feel like a loser. Bosses don't like to be told, "No." Friends don't enjoy being corrected. Of course, this won't always happen to the ethical, but they should be prepared for it, as it's likely.

If people give in and take the easy road when an ethical roadblock appears, their ethics will change. Ethics that aren't held are not ethics at all. Stated differently, when people give in to something against their personal code of ethics, that code of ethics is decreased.

Choose the hard or easy road, and be prepared for the consequences.

Tuesday, December 11, 2007

Go Forth

Forth is an interesting little programming language. First of all, it's stack based, so to do 4 + 5, you would actually need to type 4 5 +. Next, it's a compile-as-you-go language. Defining new "words" for your program is literally extending the compiler. And finally, its grammar is nothing more than a string of defined words.

Forth is used for embedded systems (in fact, according to forth.com, it's used today), and has been used in the past for arcade games.

Tuesday, November 13, 2007

PHP CGI Weirdity

I don't know why anyone would ever want to programmatically call the CGI version of PHP, but there's a slight weirdness you'll have to deal with. If you call it with just the normal CGI environment variables, PHP will complain that it was compiled with "--enable-force-cgi-redirect," and that it needs some extra stuff.

Here's that stuff:
1. REDIRECT_STATUS. I just set this to 200, and it seemed to work. Pretty sure that refers to the HTTP status, but I really haven't researched it at all.
2. PATH_TRANSLATED. This is just the location on disk of the php script to run.

Setting these two seemed to work, but (just for kicks) I also set REDIRECT_URL = SCRIPT_URL = REDIRECT_SCRIPT_URL = the URL (minus the server name, ie "/dir/script.php".)

Monday, November 12, 2007

Fun With PERL

I'm pretty proud of myself right now, because I just used PERL to do something cool. In my 360 class (CS 360 - Internet Programming) we're building a web server, and I keep finding new mistakes of mine to fix. It's going well, but there seems to be some kind of limit in Linux to the number of semaphores I'm allowed to create. So when my program dies a few times (without removing the semaphores it created), it won't create semaphores on restart. Up till now, I've been restarting the computer when this happened.

Did some investigating, and I found out that there's a nice little utility, ipcs, that prints out all the IPC (interprocess communication) stuff - message queues, shared memory, and (of course) semaphores. There's another nice little utility, ipcrm, that removes IPC stuff.

I could go through and remove all my semaphores every time, OR I could use my newfound PERL knowledge to make the computer do it for me. Being a geek, I found the second option way cooler.

Anyway, here's my code. Enjoy! (Note that I don't guarantee it on anything. Also, note that it deletes ALL semaphores under your user. So don't run this if anything else you're running is using semaphores. Finally, use this at your own risk!)


#!/usr/bin/perl

open(IPCS, "ipcs|") || die("Couldn't run ipcs.\n");

$startedSems = 0;
while (<IPCS>){
if ($startedSems){
if ($_ =~ /------ Message Queues --------/){
$startedSems = 0;
}
else{
($currkey, $currid, $usr) = split /\s+/;
if ($currid != "" && $usr eq "yourUserNameHere"){
$cmd = "ipcrm -s " . $currid . "|";
open (IPCRM, $cmd);
while (<IPCRM>){
print;
}
close(IPCRM);
print "Removed sem id=$currid\n";
}
}
}
else{
if ($_ =~ /------ Semaphore Arrays --------/){
$startedSems = 1;
}
}
}
close(IPCS);


Oh yeah, two more things. Change yourUserNameHere to your user name. And last of all, either chmod a+x the file to make it executable, or perl it.