that.dork.jordan
Changing the way we teach math

Conrad Wolfram thinks math education needs a major refresh. He asserts that the way we teach math to children today in no way matches the ways it needs to be practically applied once you’ve moved into the job sphere. To change that, he suggests that we start teaching math by way of programming.

I am happily biased on this topic and I agree wholeheartedly. My interest in math wasn’t sparked until I discovered the programming features of my TI-83 calculator. I haven’t reflected on my math education in many years, but I am now angry at the disservice my educators did for me. Once they learned that I knew how to write these tiny programs, they wouldn’t allow me to use the calculator during class or during tests. Every other student sat there with the same TI-83, the same access to utility, and I was forced to use a 10-key calculator and show all of my work on paper. The sad truth is, because I wrote the program, I knew more about the actual mathematic problem at hand than anyone else in the room.

I’m happy to say that I wasn’t discouraged. I still followed my fascination with being able to make real world problems more simple not only for me, but for everyone. I followed that path right into my current position, where making software is my full time job, and I love it.

We should be teaching children how to solve real world problems as much as possible.

Share
Django CSRF headaches?

I spent hours upon hours today trying to figure out why the Django 1.2 CSRF system was not working for me. There are obviously a lot of struggles with existing Django installs in converting to 1.2 because of the CSRF protection, but none of my searches turned up a useful resolution for my particular problem. What I saw was the typical “CSRF verification failed” message but I’d installed the middleware and inserted the token and passed in RequestContext so it should have worked. Then I switched off my tornado server and tried it via Django’s built-in server and voila! It worked.

Django 1.2 works with the latest versions of Tornado (I’m now running 1.1) but if you have a very old version I suspect you may run into the same problem I did. Save yourself the headache and make sure tornado is up to date and you don’t have any old versions installed.

Share
Hypes, gripes, and likes: The T-Mobile Vibrant (Samsung Galaxy-S)

T-Mobile Vibrant#VIBRANTRAGE

It’s the hashtag I tweeted just a couple days after buying a new Samsung Galaxy-S for T-Mobile (also known as the Vibrant.) I was frustrated with the clunky interface, faced with incredible amounts of lag when flipping between screens, and the audio processor was causing tons of snaps, cracks, and popples. Not exactly what I want from a phone that cost me $660 (I always buy phones at full face value.)

Well, I’m ready to erase that moniker, at least partially. I returned the phone to Radio Shack where I initially bought it and picked up a new one from T-Mobile for $110 less after tax. The new phone is snappier and the audio problems are gone. I still have some gripes, though I won’t bore you with another lengthy review. Instead let me give you my hypes, gripes, and tips:

Hypes
- The Galaxy-S really does have the best screen on a smartphone. Yes, it is better than the iPhone 4. The AMOLED screen is very close to the glass, so it feels like you are touching the image. The glass is smooth, and the image is incredibly vivid. There’s no other screen that can produce this level of brightness and contrast while remaining sharp and maintaining perfectly black blacks.
- It IS very fast. Other phones have a 1ghz processor, but they lack the graphics power the Galaxy-S has. Scroll in your browser, or open up The Sims and you’ll see what I mean. On par with the iPhone 4 as far as 3d strength goes.
- It’s tiny and light. I am impressed they fit hardware this powerful into something so tiny. Some people claim it feels cheap. If you want weight to convince you that something is well made, I suggest a cement brick. Meanwhile, I’ll be freaking out every 10 minutes wondering where I lost my phone because I can’t feel it in my pocket.

Gripes
- HOLY HELL WTF DID SAMSUNG DO TO THE UI!? Coming from Nexus 2.2-land where everything is beautiful and makes sense, this thing is a clusterfuck. Why does it look like a children’s toy? Why are they trying so hard to make it look like an iPhone. Android has a LOT of strong suits, don’t ruin it by trying to mimic a competitor. Instead, I suggest manufacturers spend their development time adding new widgets or applications. (Note Android 1.x users, life is much better on the other side of 2.)
- I’m seriously perplexed as to why there is no notification light. I’m constantly turning on the screen to see if I missed anything.
- No flash on the camera. Blah, blah, blah “night mode” blah, blah, blah. Night mode is crap unless you are on a ghost hunt and want to photograph some orbs. My friends are attractive. I want to remember them fully lit.
- I REALLY miss the trackball from my Nexus One. One thing Android does NOT do well is inserting the cursor where you want it; you really need something to help with fine-tuning. If you see me poking my phone, I am not tickling it, I’m just trying to copy some text.

Tips
- Mac users will want to know this: In order to mount the mass storage, you need to turn on USB Debugging under Settings > Applications > Development. After that you’ll get two mounted file systems- one for the built-in 16gb SD card and another for the removable SD.
- Install LauncherPro to undo some of the horrid things Samsung did to Android’s beautiful 2.x GUI. You’ll get back the regular home screen, app drawer, and a few extra features.
- Keep your USB door closed when it isn’t plugged in. The little widget on the inside is fragile and I’ve seen many people break them on other phones. Samsung did a wonderful thing in giving you a hard plastic door. Those rubber stoppers that other manufacturers include are crap.

Let me know your impressions, or ask me a question if you are interested in the Vibrant, or Android. I’ve been through the G1, Cliq, and Nexus prior to this, I can probably help ya ;-)

Share
Why I agree, then disagree with Steve Jobs and Apple

Once upon a time I loved Apple, then I couldn’t stand them, then they embraced unix and I loved them again, and now I’m starting to really dislike them again.

The trouble isn’t that they don’t make products that people find useful, the fact that Apple’s market cap recently surpassed that of Microsoft would suggest quite the opposite. Actually the reason is they are becoming increasingly more like the Office and Windows giant.

I agree fully with Jobs’s notion that HTML 5 and open standards are the future of computing, especially on mobile devices. I’m immersed in the world of development and design and trust me when I say there are few things that anyone in my line of work would enjoy more than never having to consider cross platform compatibility again. Open platforms are beneficial to all involved: end users have a wider range of choice in devices; creators spend more time making great products and less time working around incompatibility problems; and platform developers, knowing the next big thing is a click away, work to make their implementation the most desirable to all parties involved. This isn’t some new idea, it’s the same model that has made the United States one of history’s greatest and most successful countries.

My disagreement lies in the closed platform that Apple has built with their iPhone OS. Apple’s customers (perhaps unwittingly through lock-in contracts) pay between $500 and $700 for their mobile device, and yet they are consistently thwarted in attempts to use the hardware the way they choose. From the App Store lockdown that keeps people from having access to applications like Google Voice and Gay New York 101, to preventing users from installing other OSes on the phone, Apple has blocked users at every turn from doing things that they want to do with a device that the user technically owns.

While I respect Apple’s decision to create an experience that is easy to use, well designed, and (mostly) devoid of poorly designed or malicious applications; I can’t say that I agree with the way they’ve implemented it or in how they pompously tell their customers what is best. I’m a firm believer that a good product can stand on it’s own, and doesn’t need a closed marketplace to survive. Hey Apple, what are you afraid of?

Footnote: The majority of this was written using a drop in replacement keyboard (Swype) on an open source build of the Android operating system that I installed on my Google Nexus One. Forgive me for any spelling/grammar errors, but I think this came out pretty good for something written on a train… I’ll get around to editing it when I’m not in the middle of work.

Share
Getting off Google

Being a former Googler, one question I get asked a lot by my friends is “How can I get a page about me removed from Google?”

Almost always, my response is “don’t get published”.

Seriously. Google will make available any content that they know how to get to. “They” being the Googlebot, a tool that Google uses to find pages on the internet and make those pages available as a result when you search. So if you don’t want to be on Google, then simply don’t affect the world in a way that you would be notable at all.

Now that’s a sad lifestyle, when you really think about it. You should be happy to be in Google’s index! But if something about you is published, and that information makes its way online, and you really don’t want it to be there, you do have hope. You just have to get that information removed or have the author block Google from indexing that page. If you are nice enough about it, most webmasters will at least remove your name from the page(s) in question.  Then give it a few weeks for Google to re-index the page and you’ll be fine.

Share
No default application to open Desktop!?

No default application for Desktop?!I came across this issue on my laptop the other day where OS X thought my Desktop was actually a package. If you’re unfamiliar with packages (or bundles), they are really just directories containing more files and directories, but by default they open with an application or they are themselves an application. In fact, if you right click on almost any Mac application, there is an option to “Show Package Contents.” That’s all great and wonderful, but the Desktop is not supposed to be a package. So how the heck do I fix this? Well, my normal *nix intuition was that it was a permission, but I couldn’t turn anything up. After a bit of digging, I found a ManPage with all the details on these extra file/directory attributes.

Here’s how I fixed it:

  1. Open Terminal (Located in your /Applications/Utilities directory)
  2. setFile -a b Desktop/ (by default a new terminal will be in your users directory)

Well, I’m happy because I have access to my Desktop again. I’ll stop nerding out now and let you back to your life!

Share
Django Forms: Add to validation, don’t override. And how to require fields conditionally.

This picture of me is not at all relevant but often times the pictures I post are not...I’ve spent the past six months working on a lot of different projects but one of the biggest projects I’ve been working on is a back-end system for the company I work for. If you ever want a sure-fire way to begin eating, breathing, and sleeping in Python, try joining a start-up and building something like this from the ground up. Lucky for us, Django is around to make this sort of thing far less difficult.

One of the greatest features of Django is the built in form handling functionality. Define some fields, throw a variable at the template, and add a form tag and submit button and you are pretty much done. It even does all the validation for you. Well, sort of…

As all generic things go, the validation that Django does is, well, generic. It’s easy to override the methods that do the validation, but then you lose the original validation provided by Django. So what do you do when you want to add to the existing validation instead of replace it? It isn’t exactly documented but it is possible…

In this example we have a form with a field that is only required in certain circumstances. Everything else about the validation needed to be the same.

Define the form:

class CreditCardPaymentForm(forms.Form):
    mark_paid_in_full = forms.BooleanField(required=False)
    payment_note = forms.CharField(required=False)

In this form you will have a checkbox to mark the payment “paid in full.” What we want is to require a note when that checkbox is selected. I’ve omitted the rest of the form as it’s irrelevant for the example.

This is where the trickery comes in. We are going to override the clean() method, check if mark_paid_in_full is selected, and change payment_note to required if it is, then run the existing validation.

def clean(self):
if self.cleaned_data['mark_paid_in_full']:
    payment_note_field = self.fields['payment_note']
    payment_note_field.required = True

    try:
        super(forms.CharField, payment_note_field).clean(
                self.data['payment_note'])
        except forms.ValidationError, error:
            self._errors['payment_note'] = error.messages

    return self.cleaned_data

As you can see a few things happen here. First it’s important to know that self.fields will contain all the field objects. Then we try to call the CharField’s clean method. I won’t delve into the specifics of how super works as there are already many articles covering that topic but if you aren’t familiar with super, it’s worth reading about. Then if the clean method raises a ValidationError, catch it and put it in the _errors property. You could just as easily leave the ValidationError raised and Django would print the error message… albeit at the top of the form. In some cases this might be desirable, but here we want to actually tie those errors to the appropriate field. Finally, you should always return self.cleaned_data or you will get some truly bizarre results :)

if this is something you are trying to do I hope this saved some time.

Share