22 April 2008

My classes and how they don't exist

EDIT: I realized I forgot another 9 days, so I added them to the list and recalculated. It now comes to a nice even 100 days

I have 4 classes, that all meet 4 times per week, for 10 weeks. So in theory, I should have 160 days of lecture.

  • Two of my classes don't meet on Friday even though they're supposed to. Minus 20 days

  • One of my classes has 14 guest lectures. Minus 14 days (trust me, we don't learn anything in them. At all)

  • Another of my classes, apparently feeling left out of the guest lecture thing, did 4 in one week. Minus 4 days

  • One of my classes has 4 days of student lectures, where we read the textbook and teach each other. Seriously. Minus 4 days, and a piece of my soul

  • One of my classes has 9 days of student presentations on the projects and research we've done over the quarter. Minus 9 days

  • One of my classes has dedicated 5 days in a row for "lab time", and then another 4 for presentations of the work done during said lab time. Minus 9 days


So instead of 160 days, we have 100 days where professors trained to teach us are actually teaching us, or about 62% (this ignores the fact that one of my professors isn't actually a teacher). Therefore, I should probably only need to pay 62% of my tuition for this quarter. I should go talk to financial aid about this.

20 April 2008

Schoolwork

My schoolwork needs to stop existing, it's making me neglect my poor RSS feeds:



Look at that. Who knows what critical things I could be missing. 1000+ stories on Digg, and I bet 5 or 10 are actually interesting, and I'm not reading them.

16 April 2008

Credit Card Validation with Luhn

I found an interesting article on using the Luhn algorithm to validate credit cards. I'd heard of the algorithm before but didn't know how it worked; it's actually much simpler than I imagined. The idea of the article (validating credit card numbers client-side with Javascript) is a good one, but I thought the actual javascript implementation was fairly poor, so I rewrote it. So if anyone wants to validate credit card numbers for typos and that sort of thing, go crazy:

function luhn(cardNumber) {
sum=0;
for(i=cardNumber.length-1;i>=0;i--) {
sum+=parseInt(cardNumber[i],10);
doubled=parseInt(cardNumber[--i],10)<<1;
sum+=doubled>9 ? doubled-9 : doubled;
}
return sum!=0 && sum%10==0;
}

The function assumes you pass in just a string of digits, no hyphens or any of that. In case the one line is confusing, most compilers will optimize an instruction like x*2 to do x<<1 instead, but I'm assuming javascript probably doesn't do that so I did it manually; it just doubles the number. You could get really crazy with the optimization, like changing parseInt(cardNumber[i],10) to cardNumber[i]-'0', but that's probably excessive.

14 April 2008

You are better at dying!

I have yet to mention Doctor Who in this thing. If you haven't seen Doctor Who, you should probably go die. Although then you will have died without seeing Doctor Who, which is problematic. It's the longest running science fiction show ever, which means it has a disgusting 740 episodes. Sadly, most Americans haven't heard of it, because it's a British show, but you can think of it as the British version of Star Trek, only way better. Fortunately, you don't need to watch all 740 episodes to catch up, because they stopped the show for a while and just started making episodes again in 2005, so they started out assuming people hadn't seen the previous episodes. So if you start with the "new" season 1 in 2005, you're only 3 seasons behind (we're just starting the 4th season now). So spring into Amazon action. It's probably my favorite show ever, it even gives MacGyver a run for its money.

This is my favorite clip of all the new episodes. It's when the Daleks and Cybermen (the two biggest bad guys in the series) first meet up, so you get to see both races, how they're really similar, but constantly insult each other; also, how the Daleks are way better, how badass the Daleks are in general, and how they're still scared of The Oncoming Storm. This also has probably my favorite line of all time in it (bolded in the transcript, or look at the post title):



(show transcript)

(seriously though, the clip is so much better, go watch that)


Random side note: Blogger, wtf? I'm used to you sucking at general uptime (I had the usual "Unable to communicate with Blogger" every other auto-save), but you also fail at video uploads. I ended up canceling the "processing" screen after 4 hours and just uploading it to Youtube.

13 April 2008

Now we can read my RSS feeds as a group

Blogger in draft (beta Blogger) has a new thing they're testing called Blog List. And I live on the edge, so I added it. It's over there ----->. Approximately. What's handy is instead of manually entering them all, you can import from Google Reader, which is another service I highly recommend, it's the first RSS reader I've ever liked. Anyway, with a laziness-enabling option like that, you know I used it. So I just imported all 29 feeds I have in Google Reader, they show up in the list in order of who's updated most recently.

Perry Band > (!Perry) Band

This isn't related to anything at all, I just happened to stumble across this on my hard drive. It's an audio clip of some halftime commentators at one of the football games my high school band played at, talking about how we're awesome. Because we are. Well, were. I'm not in it anymore, so we suck now :).

EDIT: There used to be embedded audio here, but it was crashing Firefox :'(. Feel free to go here though

07 April 2008

PHP doesn't kill people, shitty programmers kill people

I'm reading a thing about security, and I found the canonical PHP example of why register globals is the worst thing ever:

if (authenticated_user())
{
$authorized = true;
}
if ($authorized)
{
include '/highly/sensitive/data.php';
}
?>

I've seen that so many times I have it memorized. Now, I don't program with register globals on, and there's really no reason to have it on, but seriously, show of hands. Who would ever write the above code? It's so obviously specious and yet nobody seems to notice. Assuming authenticated_user returns a boolean, everyone would write this:

$authorized = authenticated_user();

And magically, the problem is gone. Why would you ever have two branches that come back together with different variables released into the global namespace, that's just awful. Almost as bad as storing the user's username in a cookie and trusting it blindly, but obviously nobody would ever do that. I'm very worried about this field.

06 April 2008

Targeted ads

This is short, but I keep finding stories about companies and their increasing invasions of our privacy in the name of profit. A lot of the stories tend to be about targeted advertising. Why doesn't everyone want targeted advertising? It seems like a win for everyone involved. Advertisers only pay to advertise to people that actually care about their product, the people that show the ads get paid more, and the people that see ads might actually be interested in the products they're seeing for once. Why don't we want that? Instead, we've got advertisers and ISPs spying on us while we complain about our right to privacy and they laugh and ignore us. Why should they have to spy on us? You'd think we'd be volunteering this information, if it means we get ads for stuff we actually vaguely care about.

03 April 2008

House pwns Jeopardy

One of my professors, Dr. Richard House, was on Jeopardy tonight. And he won, because he's better than the other contestants. Plus all your professors. Combined.



EDIT: There used to be an embedded video here, but it was crashing Firefox :'(


So he'll be on again tomorrow. Go watch

EDIT: He won again, so go watch Monday. Thursday he won by $2, Friday he won by $3, which is an impressive increase percentage-wise.

EDIT: He owned the whole time on Monday until he lost in final Jeopardy. He's still better than all of you though.

If God is real he probably doesn't read my blog anyway

I've never read the Bible, or really paid much attention to any religions, I've found them patently stupid for as long as I can remember now, but this is basically my impression of how Christianity works:

God: "Jesus. JESUS! Get over here, I need you to do something"
Jesus: "Damn it Dad, what now?"
God: "HEY! I don't like that talk. Come over here, I'm not going to yell over the whole plane"
Jesus: "Fine. What?"
God: "Look, you know those humans I made? I messed up....er, I mean. I designed them to suck. Yeah, that's it. I designed them to sin. But sinning is against the rules I'm making them follow. But you see, I still want them to get into heaven. And I'm all powerful, I am. But I still can't let them in because they're sinners. Well, I could if I wanted to. But I can't. You following this?"
Jesus: "Uh . . . no. Why would you design them to sin if . . ."
God: "DID I TELL YOU YOU COULD TALK? It doesn't matter, just trust me, I know what I'm talking about, it's a whole "free will" thing. So I need a favor. I need you to go down to Earth"
Jesus: "Aww, no!"
God: "Shut it! You're going down to Earth, and you're going to let my crazy creations nail you to a cross, so then I can say we're even for all the sinning they do"
Jesus: ". . . That could not make less sense if you tried"
God: "Who's the omniscient one here? It makes sense, go do it. You'll just end up right back here anyway. Well, until the whole rising from the dead thing. But we'll cross that bridge when we come to it, for now just go convince them I'm God. I'm going to stay here. Don't worry, I've got this all timed to match up with their existing holidays, so when we convert them all to the true religion they won't have to change much. And make sure it's a cross, I've got stock in the people that make crosses, the industry is going to explode after this"

So yeah. I'm not a huge fan of religion either, if you couldn't tell by my rampant blasphemy. It's actually on the top of the hate list, even above Macs, which is an impressive accomplishment really, but Mac users don't make a habit of killing people that use other operating systems. Although I think they probably will one day, but even when they do, religion has a pretty big head start on them. I used to believe in the whole "let everyone believe what they will and respect each others beliefs" thing, but I got over that a while ago, now I just think they're all deluded.

I was searching for a couple of my favorite atheist quotes using the parts of them I could remember, and amazingly found pretty much all of them on the same page, which is handy. The last one is my all-time favorite and the inspiration for that thing above. It comes down to the rather succinct bumper-sticker friendly "God made me an atheist. Who are you to question his wisdom?"


  • "I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours."
    --Stephen Roberts

  • "When I was a kid I used to pray every night for a new bicycle. Then I realised that the Lord doesn't work that way so I stole one and asked Him to forgive me."
    --Emo Philips

  • "Is God willing to prevent evil, but not able? Then he is not omnipotent. Is he able, but not willing? Then he is malevolent. Is he both able and willing? Then whence cometh evil? Is he neither able nor willing? Then why call him God?"
    --Epicurus

  • "We must respect the other fellow's religion, but only in the sense and to the extent that we respect his theory that his wife is beautiful and his children smart."
    --H. L. Mencken

  • "Jesus' last words on the cross, "My God, my God, why hast thou forsaken me?" hardly seem like the words of a man who planned it that way. It doesn't take Sherlock Holmes to figure there is something wrong here."
    --Donald Morgan

  • Eskimo: "If I did not know about God and sin, would I go to hell?"
    Priest: "No, not if you did not know."
    Eskimo: "Then why did you tell me?"
    --Annie Dillard, 'Pilgrim at Tinker Creek'

  • "We must question the story logic of having an all-knowing all-powerful God, who creates faulty Humans, and then blames them for his own mistakes."
    --Gene Roddenberry


I also find this picture rather amusing:

Do you know what flavor your kid's lollipops are?

As far as I can tell, this story is in fact not an April Fools joke. Georgia has banned the sale of marijuana-flavored candy to minors. Not candy with marijuana in it, which is what I thought it was originally talking about. Candy that tastes like marijuana, with absolutely no actual drug content.

This entry is going to ignore the many, many arguments about the safety of marijuana compared to legal things like alcohol or nicotine, or how it's considered less addictive than caffeine. That doesn't even matter at the moment, we'll pretend marijuana is more deadly than decapitation. I'm also going to ignore the war on drugs altogether, which I think is the stupidest waste of money since . . . well, actually there are lots of stupid wastes of money in this country, I think there are whole websites dedicated to enumerating them. But I'm going to pretend that it is indeed the government's job to tell us what drugs we can and can't do like we're all 5 years old.

There's still two things so very wrong with this. First, why would you want marijuana-flavored candy? What's the point of it if you don't get high, it's like something that's cough syrup flavored but doesn't actually fix coughing (apologies to people that enjoy the taste of cough syrup, that analogy probably made no sense to you). Second, how is marijuana-flavored candy possibly leading to marijuana use? Apparently the theory is if kids eat the candy and don't die, they rationalize that marijuana must be equally safe. Personally, I'm a fan of letting all the kids that find no problem with this line of reasoning go for it, it's probably better for the planet as a whole anyway. I'm going to go get a water pistol and shoot myself in the head, and when nothing bad happens conclude that shooting myself in the head with a real gun must also be safe. They're calling it, and this is the part where I thought for sure I'd been had by an April Fools day prank, a "gateway candy". And the bill, and again I stopped to verify this isn't a joke and ended up looking up the actual bill to be absolutely sure, was introduced by a guy named Doug Stoner. I am not making this stuff up.

This is the biggest problem I have with Democrats and why I would be tempted to be a Republican if they weren't all so completely out of their minds that they've forgotten what being a Republican even means. Democrats love laws, we just cannot get enough of them. I don't believe the government should have laws telling us we can't smoke marijuana, but I can't see how anyone would believe the government should have laws telling us we can't eat candy.

01 April 2008

April Fools Day

I considered a post about how Apple had finally won me over with their sexy interfaces and easy-to-access menu location, but I couldn't really make myself write a whole entry about it, even this sentence makes me feel a little ill. People have sent me lots of amusing April Fools Day things though. There's a ridiculously large list on Wikipedia if you want to look at more of them, these are just some I've seen.

What confuses me is the alarming number of rick rolls. It confuses me how 4chan has the power to cause these things, but it happens all the time.