In an interesting critique of Google Hotel Finder, these lines stood out:
As Google grows, its willingness to float bad products is starting to seem a little bit similar to Microsoft, ten years ago. You know what’s also similar? Its dependence on a single cash cow that keeps them from caring whether any single side venture lives or dies.
Which leads us to:
The direct contrast of course is America’s best design-driven company, Apple. Steve Jobs would rather die than release any new product that wasn’t a step-wise improvement over everything that existed before. That’s the mentality of someone that cares about whether people use a product. It’s the mentality of a designer. Google’s mentality is that of an engineer, content to labor over one cool feature at the expense of creating any overarching value.
As the example of Microsoft vs. Apple showed us, the engineer’s mentality can win early in a product cycle, when new features can create great advantages over competitors. But over time, as the tech gets commoditized, it’s companies like Apple, which are focused on integrating all the features, that create world-changing products.
In case of trouble connecting to Bespin from an external machine, try setting the IP address to 0.0.0.0
Either change the file pavement.py:
# set to true to allow connections from other machines
Or pass it as a command line argument:
paver server.address=0.0.0.0 server.port=8080 start
In case you haven’t noticed, you can even specify the port to start on i.e. run Bespin on a custom port.
I use DynDns to map my ISP provided dynamic IP to a static hostname. For some reason, the DynDns provided update clients don’t always work for me and often leave my hostname pointing to a dead or (worse) someone else’s IP. I decided to take matter into my own hands and write a script that would email me my IP whenever my DHCP lease expired and my ISP issued me a fresh one. This would ensure I know how to reach back home, even if my hostname was pointing to an old IP.
While going through the DynDns API, I realized it was trivial to update the hostname as well, essentially replicating the functionality of the aforementioned client(s). So I decided to add that as well.
I know this functionality can be replicated via curl + sendmail, but Python is my tool of choice, so just live with it. Without further ado, here’s the script, with an explanation afterwards.
# encoding: utf-8
Script to email IP whenever it changes. Also updates DynDns hostname.
Created by Kunal Dua on 2010-05-10
Get email updates when your IP changes/ Python DynDns update client
This program is free software; you may redistribute it and/or
modify it under the same terms as Python itself.
def send_mail(subject, content):
from email.mime.text import MIMEText
SERVER = "smtpserver"
PORT = 587 #Use 25 if this doesn't work
USER = "username"
PASS = "password"
FROM = "IPBot "
TO = "email@example.com"
SUBJECT = subject
TEXT = content
message = MIMEText(TEXT)
message['Subject'] = SUBJECT
message['From'] = FROM
message['To'] = TO
server = smtplib.SMTP(SERVER, PORT)
server.login (USER, PASS)
server.sendmail(FROM, TO, message.as_string())
USERNAME = 'username'
PASSWORD = 'password'
HOSTNAME = 'example.dyndns.org'
theurl = 'https://%s:%firstname.lastname@example.org/nic/update?hostname=%s&myip=%s&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG' % (USERNAME, PASSWORD, HOSTNAME, theip)
conn = urllib.urlopen(theurl)
if __name__ == '__main__':
import urllib2, re
conn = urllib2.urlopen('http://checkip.dyndns.com/')
data = conn.read()
m = re.search('([0-9]*)(.)([0-9]*)(.)([0-9]*)(.)([0-9]*)', data)
currip = m.group(0)
lastfile = "lastip.txt"
allfile = "history.txt"
theipfile = open(lastfile,"r")
lastip = theipfile.read()
if lastip == currip:
#print "no change needed"
histfile = open(allfile, "a")
thenow = datetime.datetime.now().ctime()
histfile.write("%s %sn" % (thenow, currip))
theipfile = open(lastfile,"w")
- Lines 17-22 and 39-41 replace with your email and DynDns settings respectively.
- Line 22 – My email provider supports redirecting mails to a folder by simply adding the name of the folder before @ sign. For example email@example.com will deliver mail in folder ipupdates of firstname.lastname@example.org. If your email provider supports this, it’s a useful trick to prevent these mails from cluttering up your inbox. If not, simply enter your regular email address.
- Lines 60-61 initialize 2 files that I use. One is to store the current IP (or the last known IP) and the other is a history of all IP changes. The former is used to compare if the IP has changed since the script was last run and thus if an email needs to be sent + DynDns updated. The latter is not really needed for the script to function properly, and is used to maintain a log of all IP changes – because you can!
- Line 78 – By default, the subject of the mail is the IP and the body/ text is blank. Feel free to obfuscate your IP if you feel paranoid about sending it in clear text or write sweet nothings to yourself in the body.
- Note: Before you run this script for the first time, create an empty file called lastip.txt in the same directory as the script or the script will fail. I know I could write a trivial check for this, but I leave that as an exercise for the reader.
Recommended frequency of running this job via cron/ launchd is 10 minutes.
Update: (May 27) I am pretty sure the DynDns API is broken in some way because I can’t get it to update even with this script. The email part is working pretty good for me though!