"http" entries

Twisted Python: The engine of your Internet

Learn to build event-driven client and server applications

I want to build a web server, a mail server, a BitTorrent client, a DNS server, or an IRC bot—clients and servers for a custom protocol in Python. And I want them to be cross-platform, RFC-compliant, testable, and deployable in a standardized fashion. What library should I use?

Use Twisted

Twisted is a “batteries included” networking engine for writing, testing, and deploying event-driven clients and servers in Python. It comes with off-the-shelf support for popular networking protocols like HTTP, IMAP, IRC, SMTP, POP3, IMAP, DNS, FTP, and more.

To see just how easy it is to write networking services using Twisted, let’s run and discuss a simple Twisted TCP echo server:

from twisted.internet import protocol, reactor

class Echo(protocol.Protocol):
    def dataReceived(self, data):
        self.transport.write(data)

class EchoFactory(protocol.Factory):
    def buildProtocol(self, addr):
        return Echo()

reactor.listenTCP(8000, EchoFactory())
reactor.run()

With Twisted installed, if we save this code to echoserver.py and run it with python echoserver.py, clients can now connect to the service on port 8000, send it data, and get back their echoed results. Read more…

Four short links: 15 April 2013

Four short links: 15 April 2013

Know Your HTTP, Digital Exploitation, Insecure Webcams, and CS Courses

  1. Know Your HTTP Posters (GitHub) — A0-posters about the HTTP protocol.
  2. Crowdserfingwhen a large corp uses crowd-sourced volunteering for its own financial gain, without giving back. It offends my sense of reciprocity as well, but nobody is coerced into using Google Maps or contributing data to it. How do we decide what is “right”?
  3. Exposed Webcam Viewer — hotels in Russia, lobbies in California, and blinking lights in the darkness from all around the world. (via Hacker News)
  4. Beauty and Joy of Computingan introductory computer science curriculum developed at the University of California, Berkeley, intended for non-CS majors at the high school junior through undergraduate freshman level. Uses Snap, a web-based implementation of Scratch.

ASP.NET web API rocks

Why the ASP.NET Web API Framework is an essential tool for RESTful applications.

Glenn Block (@gblock) is an O’Reilly author and senior program manager on the Windows Azure Team at Microsoft.

We sat down recently to talk about the newly released ASP.NET Web API Framework, which he helped develop, and why it will become essential to building RESTful applications.

Key points from the full video (below) interview include:

  • ASP.NET Web API enables a rich set of clients to consume info [Discussed at the 1:47 mark]
  • Find out if one comes out on top – MVC vs. Web API [Discussed at the 2:41 mark]
  • Different clients negotiate content differently – Web API handles this with ease [Discussed at the 5:50 mark]
  • Self hosting is a big deal but beyond that Web API introduces flexibility – you no longer need to use IIS [Discussed at the 9:04 mark]
  • An HTTP Programming Model for Microsoft [Discussed at the 11:04 mark]
  • The newest of the new – Hypermedia, OData, and Web API Contrib [Discussed at the 18:08 mark]

You can view the entire interview in the following video.

Read more…

Four short links: 13 June 2012

Four short links: 13 June 2012

Buffett Lessons, Crypto Startup, HTTP 451, and Fixing Academic Publishing

  1. Warren Buffett Lessons — nice anthology of quotes, reordered into almost a narrative on different topics. (via Rowan Simpson)
  2. Silent Circle — Phil Zimmermann’s new startup, encrypting phone calls for iPhone and Android for $20/month. “I’m not going to apologize for the cost,” Zimmermann told CNET, adding that the final price has not been set. “This is not Facebook. Our customers are customers. They’re not products. They’re not part of the inventory.” (via CNET)
  3. New HTTP Code for “Legally Restricted” — it’s status code 451.
  4. PeerJ — changing the business model for academic publishing: instead of charging you each time you publish, we ask for a single one off payment, giving you the lifetime right to publish articles with us, and to make those articles freely available. Lifetime plans start at just $99. O’Reilly a happy investor.
Four short links: 4 April 2012

Four short links: 4 April 2012

Touch-Typing Instruction, HTTP Header Attacks, Sorting Ratings, and Risks of Inspecting Applicants' Facebook Pages

  1. Typing Club — lessons to improve your touch-typing, building you up letter by letter to speed and mastery. Like how I learned, only without the typewriters and the bibs and the roomful of girls. It wasn’t easy being the only boy in typing class, but somehow I managed. (via EdTech ideas)
  2. SQL Injection via HTTP Headers — excellent introduction to how some surprising HTTP headers can be attack vectors.
  3. How Not to Sort by Average Rating (Evan Miller) — so easy to get it wrong, so eye-wateringly complex a formula to do it right. (via Hacker News)
  4. I Hereby Resign (Reg Braithwaite) — not an actual resignation letter, but it highlights exactly why asking to see applicants’ Facebook pages is a bad idea. “If you are surfing my Facebook, you could reasonably be expected to discover that I am a Lesbian. Since discrimination against me on this basis is illegal in Ontario, I am just preparing myself for the possibility that you might refuse to hire me and instead hire someone who is a heterosexual but less qualified in any way. Likewise, if you do hire me, I might need to have your employment contracts disclosed to ensure you aren’t paying me less than any male and/or heterosexual colleagues with equivalent responsibilities and experience.” Ditto “spouse is pregnant so I’m about to take maternity leave just after you hire me”, etc. Those things you spend days thumping into HR that they aren’t supposed to ask about? All on the applicants’ Facebook pages.
Four short links: 28 February 2012

Four short links: 28 February 2012

REST Interfaces, Browser History, Crappy Textbooks, and Wireless Babies

  1. Designing RESTful Interfaces (Slideshare) — extremely good presentation on how to build HTTP APIs.
  2. Manipulating History for Fun and Profit — if you want to make websites that are AJAX-responsive but without breaking the back button or preventing links, read this.
  3. Why Textbooks Are So Broken (Salon) — Let’s say a publisher hires a developer for a certain low-bid fee to produce seven supplemental math books for grades 3-8. The product specs call for each student book and teacher guide to have page counts of roughly 100 pages and 80 pages, respectively. The publisher wants these seven books ready for press in five weeks—over 1,400 pages. To put this in perspective, in the not too recent past at least six months would be allotted for a project of this size. But publishers customarily shrink their deadlines to get a jump on the competition, especially in today’s math market. Unreasonable turnaround times are part of the new normal, something that almost guarantees a lack of quality right out of the gate.
  4. exmobaby — wireless biosensor baby pyjamas send ECG, skin temperature, and movement data via Zigbee. (via Jo Komisarczuk)
Four short links: 24 February 2012

Four short links: 24 February 2012

Analytics in Excel, HTTP Debugger, Analytics for Personalized Healthcare, and EFF To The Rescue

  1. Excel Cloud Data Analytics (Microsoft Research) — clever–a cloud analytics backend with Excel as the frontend. Almost every business and finance person I’ve known has been way more comfortable with Excel than any other tool. (via Dr Data)
  2. HTTP Client — Mac OS X app for inspecting and automating a lot of HTTP. cf the lovely Charles proxy for debugging. (via Nelson Minar)
  3. The Creative Destruction of Medicine — using big data, gadgets, and sweet tech in general to personalize and improve healthcare. (via New York Times)
  4. EFF Wins Protection of Time Zone Database (EFF) — I posted about the silliness before (maintainers of the only comprehensive database of time zones was being threatened by astrologers). The EFF stepped in, beat back the buffoons, and now we’re back to being responsible when we screw up timezones for phone calls.
Four short links: 13 December 2011

Four short links: 13 December 2011

Newton's Notebooks, Creative Commons, Node HTTP, and Data Business

  1. Newton’s Notebooks Digitised — wonderful for historians, professional and amateur. I love (a) his handwriting; (b) the pages full of long division that remind us what an amazing time-saver the calculator and then computer was; (c) use of “yn” for “then (the y is actually a thorn, pronounced “th”, and it’s from this that we get “ye”, actually pronounced pronounced “the”). All that and chromatic separation of light, inverse square law, and alchemical mysteries.
  2. Creative Commons Kicks Off 4.0 Round — public discussion process around issues that will lead to a new version of the CC licenses.
  3. Shred — an HTTP client library for node.js. (via Javascript Weekly)
  4. Holding Back the Age of Data (Redmonk) — Absent a market with well understood licensing and distribution mechanisms, each data negotiation – whether the subject is attribution, exclusivity, license, price or all of the above – is a one off. Very good essay into the evolution of a mature software industry into an immature data industry.
Four short links: 22 August 2011

Four short links: 22 August 2011

Cooked Brands, HTML Bootstrap, Browser Security Headers, and Swarming Robots

  1. Cities in Fact and Fiction: An Interview with William Gibson (Scientific American) — Paris, as much as I love Paris, feels to me as though it’s long since been “cooked.” Its brand consists of what it is, and that can be embellished but not changed. A lack of availability of inexpensive shop-rentals is one very easily read warning sign of overcooking. I wish Manhattan condo towers could be required to have street frontage consisting of capsule micro-shops. The affordable retail slots would guarantee the rich folks upstairs interesting things to buy, interesting services, interesting food and drink, and constant market-driven turnover of same, while keeping the streetscape vital and allowing the city to do so many of the things cities do best. London, after the Olympic redo, will have fewer affordable retail slots, I imagine. (via Keith Bolland)
  2. Bootstrap — HTML toolkit from Twitter, includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more. Open sourced (Apache v2 license).
  3. Extra Headers for Browser Security — I hadn’t realized there were all these new headers to avoid XSS and other attacks. Can you recommend a good introduction to these new headers? (via Nelson Minar)
  4. Swarmanoid — award-winning robotics demo of heterogeneous, dynamically connected, small autonomous robots that provide services to each other to accomplish a larger goal. (via Mike Yalden)
Four short links: 9 August 2011

Four short links: 9 August 2011

Android Peripherals, Security Asymmetry, Teaching on G+, and HTTP Load Testing

  1. DSLR Controller — Android app that lets you remote-control your DSLR. Much being made of the fact that iOS devices aren’t as easy to interface with. For more, see the Wired article. (via BoingBoing)
  2. Asymmetric Security Warfare — I found this nugget buried in this photo shoot talking about the differences between Black Hat and DEFCON conferences: [Mudge, Peiter] Zatko found that it takes about 125 lines of code to create the typical piece of malware and it takes about 10 million lines of code to create sophisticated technologies to protect against it.
  3. Teaching Cooking in Google+ Hangouts (KQED) — I love the many uses of hangouts. To my mind, they remain the unique value-add for G+.
  4. HTTP Benchmarking Rules — Mark Nottingham lays down some guidelines for meaningful and effective benchmarking of HTTP services. Full of subtleties and wile: [P]retty much every server loses some capacity once you throw more work at it than it can handle. A better way to get an idea of capacity is to test your server at progressively higher loads, until it reaches capacity and then backs off; you should be able to graph it as a curve that peaks and then backs off. How much it backs off will indicate how well your server deals with overload.