I've been actively learning and using Django since August 2008, and I've loved almost every bit of it. There are plenty of places to read all about the virtues of Django, so I'll leave that out for now.
One thing that's always bugged me about web development in general is the sending of emails. I do development on my local computer (with a badly set up Apache / MySQL / PHP / Python / whatever else stack), and I've never felt like dealing with the headache of setting up a mail server. This means, when I add something that's supposed to send an email (like an activation email after registration), I have to get very hacky to test and debug it (making sure the email text is being produced correctly, making sure it's being sent to and from the right people, etc.).
This was one of the few web development pains that I thought Django didn't solve. Whenever I'd test a bit of code that was supposed to send email, I'd get a "Connection refused" error page (meaning my computer has no mail server to send the email with). I would usually add in a bit of printf debugging to make sure the subject and body had the correct text, but beyond that, I'd usually wait to test the email portions until I uploaded to a server that could send email (usually the production server, unfortunately).
Yesterday, I bumped into a little section in the Django documentation that explains how to get around this. As usual, Python has all the solutions. First, set this code in your settings.py file:
[code lang="python"]EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025 # replace this with some free port number on your machine[/code]
Then, assuming you're on a Unix system (I'm on a Mac), run the following on the command line to start a "dumb" Python mailserver:
[code lang="bash"]python -m smtpd -n -c DebuggingServer localhost:1025[/code]
Make sure to replace 1025 with whatever you filled in for EMAIL_PORT.
Now, try running the email-sending code in your Python application. Voila! No error pages (or at least, none related to email), and the full text of the email (headers and all) appears in whatever command line prompt you ran the dumb mailserver on. This allows you to the see senders, recipients, subject, and body of the email being sent out, all without getting hacky or sending to an email account you own.
Taking this a step further, I created a small bash script called "dumbmail" in /usr/local/bin that looks like the following:
[code lang="bash"]#!/usr/bin/env bash
if [ -z $1 ]
then port=1025
else port=$1
fi
echo "Starting dumb mail server on localhost:$port"
python -m smtpd -n -c DebuggingServer localhost:$port[/code]
Now, when I'm testing a Django application and I get to a section that is going to send an email, I just run "dumbmail" (or "dumbmail some_number" if I need to use a different port, for some reason I can't imagine), and I'm ready to go.
Hope this helps people. The documentation was always there - I just never noticed that part until yesterday.
Showing posts with label apple. Show all posts
Showing posts with label apple. Show all posts
Tuesday, May 5, 2009
Tuesday, April 28, 2009
Round Rectangles (or Why Steve Jobs is a Visionary)
A story was posted on Folklore.org (a site full of old stories about the creation and initial development of Apple computers) about the addition of rounded rectangles to an old drawing program, and Steve Jobs's involvement in them. This section in particular struck me:
I think this is a fantastic example of what makes Steve Jobs one of the few true visionaries in the world. In the face of a big advancement like fast ovals (yes, it was definitely a big deal at the time), I would've been more than satisfied. I may have asked for rounded rectangles in a second iteration, but it would've been a simple feature idea. I believe most people would've reacted the same way.
What makes Steve Jobs special is his ability to quickly identify what's really important. It seems so obvious after the fact. Of course people would like computers with translucent colored cases! Of course minimalist controls would make for a more accessible and desirable MP3 player! Of course rounded rectangles are an extremely common shape, and are really important to have in a drawing program! These ideas (and more) are all obvious now. But a year before Apple did them, other companies were struggling to innovate in these fields, and they were only "obvious" to Steve Jobs.
Of course, anyone can have a great idea that turns out to be the right way of doing things. This is why I distinguish between "true" and regular (false?) visionaries. People called M. Night Shyamalan a visionary after "The Sixth Sense" and "Unbreakable". He then went on to make one more pretty good but decidedly un-visionary movie (Signs), an arguably good but decidedly un-visionary movie (The Village, which I loved, but I understand why others didn't), and two duds (my apologies to the three people who liked them). The visionary label was applied to Shyamalan before he'd reached first base, and he got thrown out at second. This happens all the time, and these people are certainly not true visionaries.
True visionaries come up with visionary ideas so consistently, that it becomes expected of them. And no one (off the top of my head) has a more consistent history of this than Steve Jobs.
Bill fired up his demo and it quickly filled the Lisa screen with randomly-sized ovals, faster than you thought was possible. But something was bothering Steve Jobs. "Well, circles and ovals are good, but how about drawing rectangles with rounded corners? Can we do that now, too?"
"No, there's no way to do that. In fact it would be really hard to do, and I don't think we really need it". I think Bill was a little miffed that Steve wasn't raving over the fast ovals and still wanted more.
Steve suddenly got more intense. "Rectangles with rounded corners are everywhere! Just look around this room!". And sure enough, there were lots of them, like the whiteboard and some of the desks and tables. Then he pointed out the window. "And look outside, there's even more, practically everywhere you look!". He even persuaded Bill to take a quick walk around the block with him, pointing out every rectangle with rounded corners that he could find.
When Steve and Bill passed a no-parking sign with rounded corners, it did the trick. "OK, I give up", Bill pleaded. "I'll see if it's as hard as I thought." He went back home to work on it.
I think this is a fantastic example of what makes Steve Jobs one of the few true visionaries in the world. In the face of a big advancement like fast ovals (yes, it was definitely a big deal at the time), I would've been more than satisfied. I may have asked for rounded rectangles in a second iteration, but it would've been a simple feature idea. I believe most people would've reacted the same way.
What makes Steve Jobs special is his ability to quickly identify what's really important. It seems so obvious after the fact. Of course people would like computers with translucent colored cases! Of course minimalist controls would make for a more accessible and desirable MP3 player! Of course rounded rectangles are an extremely common shape, and are really important to have in a drawing program! These ideas (and more) are all obvious now. But a year before Apple did them, other companies were struggling to innovate in these fields, and they were only "obvious" to Steve Jobs.
Of course, anyone can have a great idea that turns out to be the right way of doing things. This is why I distinguish between "true" and regular (false?) visionaries. People called M. Night Shyamalan a visionary after "The Sixth Sense" and "Unbreakable". He then went on to make one more pretty good but decidedly un-visionary movie (Signs), an arguably good but decidedly un-visionary movie (The Village, which I loved, but I understand why others didn't), and two duds (my apologies to the three people who liked them). The visionary label was applied to Shyamalan before he'd reached first base, and he got thrown out at second. This happens all the time, and these people are certainly not true visionaries.
True visionaries come up with visionary ideas so consistently, that it becomes expected of them. And no one (off the top of my head) has a more consistent history of this than Steve Jobs.
Labels:
apple,
computers,
imac,
ipod,
m night shyamalan,
round rectangles,
steve jobs,
the sixth sense,
unbreakable,
visionary
Wednesday, March 11, 2009
Apple takes it too far on form-over-function
Today, Apple announced the new iPod Shuffle. It drops the navigation buttons in favor of making it slightly smaller.

Your first question upon hearing this was probably the same as mine: "How do you switch songs?" Simple: the controls are on the cable of the prepackaged headphones.

Do you listen to your iPod with the headphones it came with? Most people I know don't. Admittedly, I don't know anyone who owns an iPod Shuffle (my mom used to, but that's it), so it's possible that iPod Shuffle buyers often stick with the default headphones. But be warned: if you buy an iPod Shuffle, and you want to use your own headphones, get ready to not be able to switch/skip songs.
I understand choosing form over function, up to a point. But to me, this just seems ludicrous. The difference in size between this thing and the last-gen iPod Shuffle is minuscule, and the functional sacrifice immense. But maybe I just don't get it.
Your first question upon hearing this was probably the same as mine: "How do you switch songs?" Simple: the controls are on the cable of the prepackaged headphones.
Do you listen to your iPod with the headphones it came with? Most people I know don't. Admittedly, I don't know anyone who owns an iPod Shuffle (my mom used to, but that's it), so it's possible that iPod Shuffle buyers often stick with the default headphones. But be warned: if you buy an iPod Shuffle, and you want to use your own headphones, get ready to not be able to switch/skip songs.
I understand choosing form over function, up to a point. But to me, this just seems ludicrous. The difference in size between this thing and the last-gen iPod Shuffle is minuscule, and the functional sacrifice immense. But maybe I just don't get it.
Subscribe to:
Posts (Atom)