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.

31 March 2008

I posted this with Ctrl+P

OK, try this. I think all browsers have a file menu; if your browser doesn't have a file menu, find one that does. Open the file menu. Done? Good job. Now, did you in any way touch the mouse? If you used the mouse to open the menu, you're doing something very wrong.

I was recently forced in class to read a thing about how wonderful the Mac menu system is. Seriously, I had to explain why Mac OS is clearly the superior operating system. For credit. I don't have the lecture material, but suffice to say Mac menus are awesome because the current window's menu is always at the top of the screen, so you can just fling your mouse to the top of the screen and easily click the menu. Now, obviously this ignores the whole still-need-to-position-horizontally problem, which I would think pretty much kills the time gain, but apparently studies say it really is faster. However, this also ignores the you're-using-completely-the-wrong-interface problem. The approximate order of increasing input device speed is:

  1. Prayer

  2. Mouse

  3. Keyboard

  4. Mind reading


The mouse has lots of useful applications, but my definition of "lots" is degrees of magnitude smaller than most people's. People used to watch me use computers in middle school and giggle that I never used the mouse, and while "never" is an overstatement it's fairly accurate compared to the rest of them. The mouse is stunningly overused, because people are too lazy to learn the keyboard ways to do stuff. You don't even have to bind your own shortcuts, just the default ways to do things will massively speed up your productivity.

If you need to run a program, Super+R opens the run dialog in Windows, Meta+F2 in GNOME. I can't remember the last time I manually opened a run dialog, and I almost never use a shortcut or a start menu item to launch a program, it takes forever. Super+D/Ctrl+Meta+D shows the desktop, although hopefully if you're doing this you're not going to need desktop shortcuts anymore so this won't come in handy very often. Here's one nobody seems to know: Super+Pause opens the System properties dialog. Never right click My Computer again. Want to open the start menu? There's a dedicated key on the keyboard for it. Stop clicking the start menu and hit the key with the pretty windows symbol on it. Then hit the first letter of the menu you want to jump to, P for programs, S for search (although Super+F will get you there faster anyway), etc. Just learning basic navigation keys for documents makes life so much easier. You don't need to be a vim ninja, just knowing that Ctrl+End will get you to the end of the document in most programs is helpful. Highlighting by holding Shift and an arrow? Hold down Control too and each arrow press will jump one word instead of one character.

Now, if you're feeling super crazy, you can set up your own hotkeys to do stuff. I don't know the canonical way to do this in Windows, but most programs come with their own way to deal with hotkeys. Under Linux I use XBindKeys, which lets you map keys to commands really easily. Here's one of my entries:

mpc toggle
Alt+Mod4 + space

When I hit Meta+Super+Space, it runs "mpc toggle", which pauses or unpauses my music. I have a bunch for MPD, a bunch of others for MPlayer (for videos), and a handful for miscellaneous other programs. For maximum fun, you can get peripherals. I have a Saitek Command Pad and a Griffin Powermate, and I use Gizmod to control both of them, which lets you write Python scripts to deal with input devices. In short: bonus hotkeys. Global hotkeying is much easier in Linux because everything is doable from the command-line, but I imagine a lot of this can be accomplished in Windows as well.

Side note: Coincidentally (I started writing this like a week ago when I had the evil lecture of mac-loving), there's an article on Coding Horror about how using the keyboard tends to take longer than using the mouse when learning a program. This is probably true, although with hints like letters underlined in menus I would think the keyboard would be able to keep up just about from the beginning. Nonetheless, once you know how to use the keyboard, it's always going to be faster, so if it's a program you use regularly it's definitely worth the effort. Google understands this, and all of their web applications have hotkeys built in, which is something incredibly lacking in web UIs for some reason. I hit Ctrl+S to save my draft of this entry, and Ctrl+P to publish it. In Google Reader (which i highly recommend), J and P jump to the next/previous entry in the list, and V opens the current selection in a new tab. There are other hotkeys, I don't remember them because I don't use them often, but just remembering two or three saves time.

26 March 2008

All the cool kids hate Apple

There's an article on ITworld about how even Apple will be hated one day. When that day comes, I want to have this blog post on hand so I can point at it and say "See! I TOLD you they sucked. I hated Apple before it was cool to hate Apple"

22 March 2008

Start?

This is going to be short, but this particular thing drives me crazy. At some point some anti-Microsoft person noticed that to shut down your machine, you click the Start button. They apparently thought this was quite comical, and suddenly everyone on the internet is making fun of Microsoft for being so silly as to put the shutdown option in the Start menu. Now, it's possible the whole Internet is just stupid, or maybe people really do get it and then just keep making fun of Microsoft anyway because it makes them feel good, but just in case it's the former I'm going to clear it up right here. The "Start" on the Start button means start doing something. So, for example, if you want to start to shut down your computer, you would click Start -> Shut Down. You don't click the Start button to start up your computer either, but nobody seems to care about that one. No, it's not a perfect analogy, but when they added the start bar in Windows 95 it was a really big deal UI-wise (No more alt-tab switching!, wink), and it took a decade for somebody to finally complain that apparently they're too slow to figure out how to shutdown their machines.

Microsoft is a dirty thief, let's iCry about it

I found yet another video of Apple bitching that Microsoft steals all its stuff:



Normally when I talk about operating systems on here I focus on my love of Linux, so it may not be clear that my love for Linux is equal to my hate for Mac OS. I hate the look and feel, I hate the interface, I hate the software, I iHate their iNaming scheme, and I hate its users pretty much on sight. Mac users focus on three truths they latch onto like a religion (speaking of things I hate):


  1. Mac is the best

  2. Windows steals everything from Mac

  3. Windows sucks


At some point they're going to realize that there's an issue in there somewhere. Windows steals everything so flawlessly from their precious Mac OS that they call it "photocopying", but Windows still sucks huge. Stop bitching that Windows steals all your shit as though they're going to stop or something; you can't maintain that you're amazing and yet still complain that people are imitating you and you want them to stop

21 March 2008

It's just like a real table!

I've seen dozens of videos now on Microsoft Surface. First, I think Surface could be very cool, I love multitouch interfaces. Second, I think right now Surface looks useless. As far as I can tell, a personal Surface table can do exactly four things:

  1. Show really big maps. This is pretty neat; personally, I would get tired of manually dragging a map around instead of just entering an address and going there, but I can see the use for it

  2. Transfer files (well, really just pictures and music in the clips I've seen) between devices. This is useless for me, but cool for other people, so this one is good

  3. Take the nice, organized photos stored on a device and explode them into a mass of disorganized thumbnails that you can spin and resize for no reason

  4. Make little bubbles shoot out from a glass when you set one on the table


Now, the one that really annoys me is apparently Surface's big feature: allowing you to, and I quote from more than one video, "organize your photos". For some reason, Surface's definition of "organize your photos" is to take all the photos on your device, ignore any organization they may have like folders named "Vacation" and "Work", and spread thumbnails of them all over the table haphazardly. Sure enough, I check the Wikipedia article and there it is:



Apparently this is somehow a good thing. If I wanted my photos to be like this, I would take print photographs and spread them all over my much cheaper analog table. Why would you want this?

Terrible:


Sexy:


I made up those picture folders on the spot because I don't take pictures, but still. I really don't understand why you would want to use the method of organizing photos that computers replaced forever ago, that's exactly the wrong way to be going about this. We should be designing new interfaces that are even easier to use than the ones we have now, not ones that very accurately simulate stuff we've already gotten rid of. Somebody should write a Surface app that lets you play music by dragging an LP over to a record player and then dragging the needle onto the record. Not that people ever actually do anything with the photos but spin them around and resize them over and over again; it's actually very much like people who enable the desktop cube in compiz for the first time:

20 March 2008

Jon Stewart: 1, Crossfire: 0

My roommate is watching this clip for the first time, and it's come to my attention that not everyone in the world has seen Jon Stewart destroy Crossfire. And you should see it before you die, because he is both unbelievably funny and extremely intelligent, unlike the sadly unimpressive Crossfire hosts:



And the transcript:
(show transcript)


Prefix notation considered harmful?

I found an article on making readable S-expressions. The premise is that, as Paul Graham is quoted as saying in the article:

I've used Lisp my whole programming life and I still don't find prefix math expressions natural

I understand that prefix notation isn't what everyone learned in school, so it seems weird at first, but I find prefix and postfix notation both more logical than infix; come to think of it, I'm actually not sure why we even use infix in the classroom instead of prefix. It's an ambiguous grammar, so (ironically, considering all the whining about parenthesis in S-expressions) you need parentheses to clear up what the meaning is, or some sort of accepted precidence rules.

Postfix makes sense if you think of things like a stack, which granted most people probably don't. It's easy to understand in that sense though. If you see an operator like +, you're going to add the last two numbers you had, so 2 3 + means add 2 and 3, and you end up with 5 on the stack. Want to do (2 + 3) * 5? To hell with parentheses: 2 3 + 5 *. This is easiest for computers, but I agree it doesn't make much sense to think about math this way.

Prefix makes total sense to me, however. In prefix notation the first thing you get is what you're going to be doing. You shouldn't have to wait for the middle of an expression like 2 + 3 to find out you're doing addition; when you have + 2 3 you know from the beginning you're adding two numbers, all you need to do is get the actual numbers now. Prefix notation tends to be much more logical to read: + 2 3 is obviously "add 2 and 3". Infix notation requires a passive voice like "2 added to 3", which seems silly. Programmers take it for granted that you would call add(2,3) to use the add function to add two numbers, but balk when they see (+ 2 3) as being obviously wrong -- all Lisp has done is normalize everything instead of having an annoying mix of prefix and infix functionality.

When I first learned Lisp (technically, Scheme) I thought it was the greatest thing ever, and I loved writing things in it. I think a lot of programmers have the same experience, and yet there seems to be a growing movement to destroy the S-expression, which seems to defeat the whole point.

19 March 2008

Holy hell, all is not lost

If you haven't heard Obama's speech from yesterday, go listen to it. Now. It's fine, my blog will still be here when you get back. Or watch it here:



How great was that? Seriously, it gave me chills, I can't remember the last time I heard a speech I could even stand to listen to, let alone liked. Rumor has it Obama wrote that speech single-handedly. If he did, we might not end up destroying the world after all like I figured was pretty much inevitable at this point. Even if he didn't write it alone, still, it was great. Now, I understand that our southern voters might worry about electing someone who "knows stuff". (Yes, I went there. Be happy I left the racism out of it for the moment). But please. Please. Don't keep electing crazy morons, we can't afford another four years of insanity. Presidential candidates seriously worry about "looking too smart", because "people don't want to elect someone smarter than them". WHY NOT? Here is pretty much my formula:

(elect (apply max candidates))

Why would you not want the smartest person possible? Are you jealous? You should be, they're President and you're not. Sorry I went all second-person on you, but I'm imagining getting my hands on all the people that, to put it bluntly, vote wrong. Don't vote for somebody because they make you feel smart by comparison, vote for somebody that can actually fix everything.