Entries from November 2007 ↓

Python’s Style Guide

Here’s the summary of PEP8, a badly formatted guide to Python style which also imparts random programming advice.

Capitalization

_private, keyword_, __mangled_private, module, _extension, ClassName, _PrivateClassName, ExceptionError, function_name, global_variables, instance_methods, _private_instance_methods, instance_variables, _private_instance_variables,

* Follow the existing module convention over these rules

* _private Leading underscore to make a weak internal or private indication.

* keyword_ Trailing underscore to avoid conflict with keyword.

* __mangled_private Double leading underscore invokes name mangling privacy

* module Package names are all lower case, short, and may use underscores.

* _extension C and C++ extension modules have a leading underscore.

* ClassName Class names use CapWords.

* _PrivateClassName Class names can have an underscore to indicate internal use.

* ExceptionError Exceptions are CapWords classes and end with Error if they are errors.

* function_name Function names are lowercase with underscore seperators.

* global_variables Globals look like functions with lowercase and underscores.

* instance_methods Instance methods also look like function names.

* _private_instance_methods Private instance methods may use an underscore.

* instance_variables Everything looks like a function name

* _private_instance_variables Everything private looks like a private function name
Style Advice

* Indent 4 spaces per line.

* Limit lines to 79 characters.

* Separate top level methods and classes with two blank lines.

* Separate methods within a class with one line.

* Imports are one per line.

* Avoid spaces immediately inside parenthesis, brackets or braces.

* Avoid spaces immediately before a comma, semicolon, or colon.

* Comments should be complete sentences in English.

* Write good docstrings.

* Version bookkeeping goes after the module’s docstring.

* self is the first argument to all instance methods.

* cls is the first argument to all class methods.

Sorry, not an Idea For Free, but I got sick of trying to read through Pep-8 again to check a style question.

Redundant Arrays of Internet Service Providers (RAISP) for 100% Uptime

raisp.png

Problem: Good or Cheap Internet Hosting Companies

Solution:
Good and Cheap Internet Hosting Companies

The cost of casual web hosting has dropped through the floor and one can expect it to remain there. If you need to host a dozen domains, downloading about 500 gigabytes of bandwidth each month, storing some hundreds of gigabytes of graphics, handling email accounts, and programming with a full Unix shell including tools like Subversion, Python, and MySQL, then that will set you back about $8 per month. DreamHost’s feature list (sign up here) would be unheard of five or ten years ago. With minor variations, so does everyone else. The catch? These servers are not 100% reliable; more like 98% reliable. I noticed DreamHost had about two or three days of outages or severely degraded performance last year.

Hold it, you think, we handle nearly 100% reliability with unreliable hard drives, unreliable communications channels, and even unreliable employees. Why can’t we handle nearly 100% reliability with unreliable web hosting? What can we do?

Redundant Arrays of Independent Service Providers

Tactic 0Sharing the Static Load

Web hosting companies slow down or run out of bandwidth quota far more often than actually crashing. Also, graphic files and other static data account for the bulk of the data served. One common tactic is to serve the the static files from several different domains. One can use an Apache plug-in to rewrite outgoing html, a periodic (cron) program to occasionally rewrite your images directory location, a client-side JavaScript routine to display from whichever server provided the picture fastest, mirroring downloads onto a new server, or several other methods. The effect is that loading a web page may load data from more than one domain.

Only the smaller main page needs to be served from the primary ISP when it is slow. All other data comes from faster, inexpensive ISPs. Similarly, a graphics intensive site, such as Girl Genius, could use this method to serve many terabytes of data for about a hundred dollars per month.

Tactic 1Dumb DNS Failover or Load Splitting

Another tactic that commonly works to failover to another site. Using various tricks with DNS or BGP, traffic to a downed site can route to a backup or traffic from different geographies can route to different servers. The site is mirrored, but the the URL remains the same.

Tactic 2Failover with Transactions Intact. Distributed ACID Transactions.

The hard part of failing over is making sure the important state is preserved when a site goes down. There are ways to do this, with varying degrees of bandwidth efficiency and latency. Each service would need to notify other servers in some scheme in order keep databases intact. Lots of trade-offs present themselves. It is doable, but requires a fair amount of custom work.

Summary

Getting the high availability out of these redundant ISPs is just work. More complex tactics require more engineering. The business model, as always, is to mask all of the complexity of these tactics so that the customer’s problem just “goes away”.

One could provide a service that set up all the failover options, signed up for the ISPs, wrote the scripts to maintain transaction state for a flat fee. Alternately, one could simply sell themselves as a “high availabilty, high transaction volume” service provider while actually running the service off a number of inexpensive ISPs.

There is money sitting there people. Go pick it up!

Advertising This Blog – Fun with Banner Ads

Ideas for Free Sex For Free

Just for fun, I ran an experiment last month advertising this blog using Project Wondeful. I spent about $8 to place small graphics alongside popular web comics such as Buck Godet. There was one honest banner (Ideas for Free), and on less honest banner (Sex for Free). No surprise; sex sells.

  • Budget: $10.00
  • Actually Spent: $8.45
  • Ad Impressions: 1,520,000 (Yikes!)
  • Clicks to the Blog: 617, for a 0.04% click through rate.
  • Readership Before Ads: About 2 or 3 per day
  • Readership During “Free Ideas” Ad: About 15 per day
  • Readership During “Free Sex” Ad: About 30 per day
  • Readership After Advertising: About 2 or 3 per day
  • Odd Controls: I only updated the blog once during the advertising period.

Well, this was fun! I got my $8.45 worth of entertainment.

Do Domain Name Registries Steal Your Great Names?

new_document_1-text2160-955.png

Hypothesis: Some domain registries cherry pick through names queried and register them.

Conclusion: Probably not.

Given that:

  • domain registration services have unreadable terms of use,
  • the site owner do just about anything with any data you provide,
  • you (or any user) have put your creative energy into figuring out cool names,
  • human nature is to wait before comitting to a name,
  • it’s valuable to have the name you want or found creative

So, it seems like one way to make money to camp on any interesting names that people look up on your site.

The hypothesis is that sometime in the day after you look at a cool name, it gets registered.

To test this, I tried looking up a number of adjective-noun combinations on a number of lookup sites. For each service, I tried two different unregistered domain names, e.g., SnappyGrunge.com or SlickThunder.com. I waited a couple days, tried again with the same service, then waited a week and checked with nslookup.

I tried these domains: SnappyGrunge.com, SlickThunder.com, SnappyThunder.com, SlickSlime.com, SlickThunder.com, GrabPottery.com, GrabFudge.com, GrabThinker.com, SnappyFudge.com, SlickGrunge.com, GrabGrunge.com, TakeThunder.com, SnappySlime.com, TakeFudge.com, SlickPottery.com, GrabThunder.com, HappySlime.com, GrabThinker.com, HappyGrunge.com, SlickFudge.com, HappyThunder.com, TakeThinker.com, SnappyGrab.com, TakeGrunge.com, YellowSounds.com, YellowHarvest.com, BrickTeens.com, FloppySounds.com, BrickSounds.com, FloppyHarvest.com, EdgeCup.com

Two at each of these registry services: DNSStuff.com, ZoneEdit.com, DNSWatch.com, Bankes.Com, Register.com, GoDaddy.com, NetworkSolutions.com, Active-domain.com, Secure.OnlineAccess.net, 101Domain.com, DomainDirect.com

There were no results in which these domains were registered. There were a few irreproducible results: GoDaddy.com initially reported that the two domains (GrabGrunge.com and GrabThunder.com) were taken, but did not report this a week later. Google.com/a reported the same with SlickPottery.com. A few of the fly by night sites (bankes.com, Secure.OnlineAccess.net) were not responding for one phase of the tests. None of the domains was registered after a week.

It was an experiment. It told us this wasn’t a problem.