Real Ultimate Programming

The Home for People Who Like to Flip Out and Write Code

Notes From PyATL 2014-07-10

Announcements

  • The Weather Channel is hiring
  • So is AirSage (sp?)

Functional Programming in Python - A Sampler (Cliff)

Functional programming languages make big promises

  • Makes it easy to write robust, modular, decoupled code
  • They’re easy to test (since output is solely dependent on input)
  • They make programming fun

Do they deliver?

  • Didn’t find it worth the switching costs, personally.
  • Has a problem with the no I/O thing
  • I don’t think he gets the “no state” thing; there’s no mutable, shared state, not no state at all.

Hallmarks of Functional Code

  • Functions are first-class objects
  • Functions are typically very small
  • Closures
  • Partials/curried functions
  • Recursion
  • Immutable

Various Places that Functional Idioms Can Be Useful

  • He’s using templating as an example of how to use partials; that’s interesting. I’m going to have to look into this.
  • Interesting point about Python 3’s crazy argument ordering options and partials (how does partial application work with some of the wilder ones?)

Takeaways

  • Maybe use Python in a more functional style
  • Admits he doesn’t do this currently, so it’s aspirational
  • Use list comprehensions more
  • Isolating I/O looks like a good idea
  • Closures, decorators, and partials are a yes
  • Still doesn’t like recursion

Random observations by me

  • I didn’t realize iPython Notebook had presentation capabilities; I’m going to have to play with that.

GNU Radio and Python (Andrew Henshaw)

  • According to Andrew, it’s more him showing off instead of demonstrating programming techniques.
  • GNU Radio is for signal processing
  • It’s a C++ kernel wrapped in beautiful Python goodness
  • It’s dataflow-oriented
  • Software-defined radio is apparently a big thing, lately
  • Apparently, hardware has gotten fast enough that software Digital Signal Processing (DSP) is fast enough to replace dedicated hardware, which brings all the standard flexibility wins that software tends to provide over dedicated hardware.
  • There’s some crazy $20 dongle that can work as a receiver for just about every frequency band you could want, and feed it into software-defined radio
  • Fancy: you can draw a dataflow diagram to define your DSP pipeline.
  • That’s pretty awesome: assuming I didn’t miss anything, he just ran a touch-tone dialer program, in Python, generated from his fancy-pants dataflow diagram. It was a 7.
  • The gremlins are out in full force (technical presentations are like crack for these things); his GUI example with a volume slider suddenly stopped working despite working earlier.
  • My computer’s battery is now toast, so you’ll have to talk to him if you want the details of the presentation/demo.

Notes From PyATL 2014-01-09

Announcements

  • John is hiring
  • The Unix usergroup is looking for speakers
  • So are we
  • I missed a couple of other hiring announcements because RVM was taking its own sweet time upgrading stuff so I could actually start the blog post.

Introduction to Vagrant (Daniel Rocco)

Basically a 60,000-foot view of Vagrant.

Everything I’ve Ever Done Was Completely Wrong, And That’s Okay (Shawn Boyette)

This is about culture, not tech, and I don’t think it’s really something I could do a good job of bullet-pointing.

Notes From PyATL 2013-12-12

Announcements

Database Versioning with Alembic (Ryan )

Xpresser: GUI automation “the easy way”

  • XPresser is a tool for GUI automation
  • Wow, they have to use computer vision (SimpleCV, built on top of OpenCV) to test some things.
  • How is it translating those strings into what it sees? Enquiring minds want to know.
  • Some sort of data setup (the answer to the above question).
  • Huh. It’s effectively Ubuntu-only due to accuracy concerns. Wonder what the story is behind that.

Faces: Project Management with Python (Andy Henshaw)

  • What the… ? Faces lets you do project management by writing Python? Can I have a PM that uses this?
  • Seems fairly straightforward.
  • …and development is totally stalled. Abandoned since 2007.

Using Python to Break Simple Cryptograms (John)

  • I kinda hope he shows us a GitHub repo at the end of all this, because I’d like to actually see this in action.
  • Go play with the Practical Cryptography site (see his slides when published)

Curling (Bill)

  • Intro URL stuff

Notes From PyATL 2013-06-13

Announcements

  • distribute and setuptools have finally merged (see also: the announcement).
  • The Atlanta chapter of PyLadies will be giving the presentations on their 1-year anniversary (or the closest night to their 1-year anniversary).
  • J.R. is starting a Smyrna tech group.

One-liner fizz-buzz (Doug Hellmann)

  • I’m excited; I don’t think I’ve ever seen Doug golfing code before.
  • He starts by discussing somebody else’s golfed version; I has a sad.
  • But here’s his solution. I dig it.

PANDAS: Python Data Analysis Library (Andy Henshaw)

  • Interesting; why do a custom thing to drive PowerPoint from iPython. Isn’t that a pretty close parallel to iPython Notebook?
  • First primitive: a Series
    • It’s an array-like that contains data and labels (or indices).
    • The data must be of the same type.
    • Asking for multiple labels gives you a view into the series; providing a single label gives you the value for that label.
    • Labels don’t have to be unique; if you have multiple values for a single label, then requesting that label’s value gives you a view, much like asking for multiple labels’ values.
    • Can accommodate incomplete data; labels without values represent the value as NaN.
    • NaN is used even for a Series of strings.
    • Data is automatically aligned (that’s pretty sweet).
  • Second primitive: a Dataframe
    • It’s tabular data, a la a spreadsheet.
    • Easy to create one from a dict of equal-length lists.
    • Or you could pass a dict of dicts.
    • You can add new columns to existing Dataframes using either direct assignment or calculation.
    • You can re-index.
  • Bring on the stats!
    • It’s smart about figuring out how to apply descriptive stats like sum to columns/rows.
  • All sorts of useful import functionality for structured data, e.g., JSON, CSV, et al.
  • OK, once he started talking about crosstabs, I was in the territory where I have a hard time keeping up during a talk.
  • Plotting w/ matplotlib is just cool. I need to get better at this sort of stuff.
  • TimeSeries sounds totally awesome.

[None]: True or False? (Cliff Kachinske)

  • I wonder how you’d address this in a general way.
  • The consensus in the room seems to be that any and all are the best way to go.

Creating Python Bindings for C++ using boost::python (Aleksey Vitebskiy)

  • A dig at JNI? I like this guy already.
  • C++ wrappers for the major Python objects
  • Declarative-style API
  • Man, C++ is so alien to me, now. It took me a while to really read a few of those lines.
  • It allows extensive interop: you can extend Python classes, Python classes can extend C++ classes… pretty hardcore.
  • It does full-on MRO stuff, so it fully supports multiple inheritance (color me impressed); no metaclasses, though :-(
  • Haha! You don’t see duck-typing in conjunction with C++ all that often.
  • This slide of pros and cons vs. SWIG is gold if you need this functionality.

Using Bcvi From OS X

When it comes to text editing, it doesn’t get much better than vim—and by extension, MacVim. If this is the first time you’ve heard of vim, or the first time you’ve seriously considered using it, please stop now and go read Coming Home to Vim, by Steve Losh1. That captures the Zen of Vim better than anything else I’ve read.

If you’re still around (or back), then congratulations: you have great taste in editors. Now on to one of the most irritating things about vim: getting your vim all tricked out with just the right set of plugins, color schemes, and keybindings, then getting stuck on a remote server somewhere with a vanilla version of vim, or maybe even a different vi clone, like nvi. Enter bcvi.

bcvi is a clever little tool that basically copies the file you want to edit to your machine, invokes gvim on it, then copies it back when you are done. Presto: you get to edit in the comforts of your own, highly optimized vim environment.

All you need to do to get bcvi is install it via CPAN; it even comes with a couple of helper commands to give you handy shell aliases, etc. But if you’re running OSX , oh-my-zsh (if you’re not, go read Steve’s My Extravagant Zsh Prompt for a good explanation of just how awesome it can be), and MacVim, then there are a couple of things that you’ll probably want to do.

As an aside, you might want to update CPAN so it stops nagging you every time you try to install something. The default perl that ships with OSX is under /usr/bin, so upgrading CPAN is going to require sudo. It’s also rather old. If you’d rather, you can simply install a current perl via Homebrew. This will get you up-to-date and allow you to upgrade CPAN without needing sudo. You could also look into local::lib, which I’ve used with success on servers. The instructions I used (NOTE: some of these are probably unique to my box, but I don’t have a spare handy to test) are:

1
2
3
$ brew tap homebrew/dupes
$ brew install perl
$ brew link --overwrite perl

With that out of the way, here’s how to get started with bcvi on a Mac:

  1. Install bcvi. This is as simple as install App::BCVI from the CPAN prompt.
  2. To make bcvi use MacVim (or possibly even work, if you don’t have an X-based version of vim), you need to symlink gvim to mvim. Since I have my mvim situated in /usr/local/bin, that’s where I put the gvim symlink to it, as well.
  3. Get those lovely aliases. Execute bcvi --add-aliases. NOTE: This only adds them to .bashrc, so if you’re using ZSH, you need to copy and paste them to your .zshrc.
  4. Start the listener process. This is as simple as bcvi --listener &, but I would never remember to type this until the first time I tried to use bcvi and it errored out. Instead, I use a launchd job. You can get it from this BitBucket repo. If you’ve never used launchd jobs before, instructions are included in the README.
  5. Install bcvi on the remote servers where you’d like to use it using bcvi --install hostname. This will install bcvi in $HOME/bin, so permissions shouldn’t be a problem.
  6. Finally, I like to add an alias so I don’t have to type bcvi --wrap-ssh -- hostname every time I connect to a server and want to have access to bcvi. I added the following to my .zshrc:
1
alias ssh-bcvi='bcvi --wrap-ssh --'

At this point, you should be able to ssh-bcvi to your remote server, find the file you need to edit, and vi filename to edit it in the comfort of your own vim.

Back to flipping out…

  1. As a matter of fact, just go read everything Steve writes. I steal ideas from him all the time.

Notes From PyATL 2013-04-11

Announcements

  • Google I/O is having baby conferences; there’s one here in Atlanta in May (via JR).
  • The Jam Sessions are probably moving; contact JR with suggestions.
  • Doug reminds us about the upcoming List of Consultants.
  • Rick has coupons for his book; I wonder if I should get one just in case I need to do MongoDB stuff in the future.
  • GTRI is hiring; Brighton Technologies (sp? where Dan Rocco is working, at any rate) is hiring, too.

The Tax Man Cometh (Daniel Rocco)

  • I’m a big fan of the csv module, too.
  • But not as big of fan of it as I am of namedtuple.
  • TIL about ._make.
  • I have to admit, even my feeble attempts at an NCAA bracket this year are better than tax brackets. Taxes just suck.
  • I like the functional flavor, here. Data processing pipelines are so awesome.
  • I feel a mod operator coming on.
  • I didn’t mention it before, but the Decimal usage is probably super awesome for people who are new to Python.
  • csvkit you say? That sounds extremely cool.
  • Good Question: what about DictReader?

The Trouble with Commas (Cliff Kachinske)

  • Fun gotcha: A trailing , will often create you a tuple, usually when you really don’t want one. If you start seeing complaints about mismatches in the number of arguments, it’s a good idea to look for trailing commas.
  • What really frustrates me is when I try to get clever and do something like this only to find out that Python isn’t creating me a tuple in this particular instance (for whatever reason).

A/B Testing with Cleaver (Ryan Petrello)

  • Didn’t use Visual Website Optimizer, Google Analytics, Optimizely, etc. because they wanted a Python-based solution that targeted developers, not marketers.
  • Found plenty of solutions, but they were all opinionated (to the point of requiring specific frameworks). This might not be a show-stopper for me, because tight integration usually means less config to mess with.
  • They wound up creating Cleaver (MIT licensed?), which only requires WSGI, basically.
  • Basically, you use WSGI middleware to add tracking.
  • It has a number of pluggable backends to store the experiment data.
  • You can add a weight to the tuple, easy-peasy. Does not currently support functions, but he seems confident it can be extended fairly easily.
  • Comes bundled with a lightweight web UI for viewing the results.
  • It’s cool. I wonder how much of the statistical heavy lifting it does (statistical power, significance, correlation with other changes, etc.)
  • Ryan says: They don’t do power, but it does do significance.
  • I missed this discussion while I was reading the README (curses!), but I believe the control is just the first option.

Back to flipping out…

Notes From PyATL 2013-03-14

Things are going to be short tonight, because a lot of people (especially common presenters) are off at PyCon.

Using PyInstaller (Sim Harbert)

  • Important Note: It just packages up a Python script, it doesn’t create an installer. (It’s like py2exe?)
  • Available as a gzip’d tarball, not sure if they have a full-blown installer option or an install-from-Cheeseshop option
  • Gets all fancy: don’t spew output into a terminal if it’s a GUI app, provide an icon, etc.
  • I hadn’t thought about this, but: Python is a hell of a shell script if you’re stranded on Windows

Continuous Integration in the Cloud (me)

You’ll have to find a video :-)

Iteration in Python with itertools (Doug Hellmann wrote it, Sim gave it)

Notes From PyATL 2013-01-10

  • Georgia Tech Research Institute (GTRI) is hiring web developers

tox: State of the Art in Testing (Alfredo Deza)

  • Written by Holger Krekel, involved with py.test, helped start PyPy (no longer active), and generally helpful guy.
  • virtualenv-based automation of test activities
  • So is this turning into a Continuous Integration (CI)solution?
  • Supports different Python interpreters (this is how I first learned about it)
  • testrunner-agnostic
  • Even if you don’t need to support multiple Pythons, this still has benefits:
    • Makes sure your package can be built/installed outside your dev environment
    • Abstracts away from special start scripts, callables, etc. for your CI server
    • Oops. Alfredo used one of Rick’s libs as an example, but Rick couldn’t make it tonight.
  • Not only can you run tests, you can execute any command you want against it, so you can, for example, use it to build your Sphinx docs.
  • Apparently, there’s a very big release just around the corner.

Better Documentation Through Automation: Creating docutils & Sphinx Extensions (Doug Hellmann)

  • Biggest difference between ReStructuredText (rst)? It was designed from the ground up to be extensible.
  • Pieces:
    • Sphinx Application
    • Build Environment
    • docutils parser
    • Sphinx Builder
  • Common extension points: parser and builder.
  • Extensions manipulate the parse tree

Extending docutils

### Roles vs. Directives #### Roles

  • Inline, e.g., :bbissue:68
  • If we had a more serious doc project, I’d be writing custom roles left and right; they’re simple, yet powerful.
  • The implementation is a simple function that returns a list of nodes
  • Nice: it gives you error helpers; nice to see they thought about the failure cases
  • You use the setup function to wire your extension into the Sphinx machinery

Directives

  • More powerful than roles, at the expense of lots more pieces to keep track of
  • These are things like the .. note:: directive in vanilla Sphinx
  • I like Doug’s sample directive; nothing like using a database to build your docs to make sure your docs are legit.
  • Since it’s so much more sophisticated, the implementation is a class.
  • You’ll probably need to implement the run method, if nothing else. Like a role processor, this function returns a list of nodes.

Sphinx-specific extensions

Extending the Sphinx Builder

  • This is how Doug made his spellchecker for Sphinx docs.
  • The concepts here aren’t hard, but you’re gonna get really familiar with Sphinx internals if you start doing this.
  • A good thing to remember: set the exit code to something that is not 0 when you encounter an error. Remember, only YOU can fight crappy CLI experiences.

Back to flipping out…

Notes From PyATL 2012-12-13

Analyze This! (John Hackett)

### Simple Calculator Applications Using Bottle.py and Google App Engine

Lots of introductory material explaining how analytics works, some of the problems you need to solve to make it work, etc.

Google App Engine (GAE) is a Platform as a Service (PaaS).

Pros

  • You can get started for free.
  • You get to run on Google’s infrastructure.

Cons

You run on Google’s infrastructure:

  • You get BigTable, and (this is apparently new) some sort of MySQL in the cloud thing. No traditional RDBMS.
  • Short-lived requests; they will kill your request if you take more than 60 seconds or so. They have at least added something called a “back-end instance” that works around this, at the expense of the auto-scaling feature.
  • No writes to the filesystem.
  • No arbitrary access, e.g., FTP.
  • You’re pretty tied to GAE.

How did we do last month? ()

### or Fun with date.date, timedelta ### or dateutil to the rescue

Ever start trying to do something useful with dates in Python? It sucked, huh. Time to write some boilerplate code! But wait! Surely Someone Has Already Solved This (SSHAST). Enter dateutil.

Awesome fun things in dateutil:

They also handle recurrence rules, timezone stuff, etc.

Flake8 (Alfredo Doza)

I missed the beginning of this one. I was confused about having a break :-(

Some background about why automated linters rock (preaching to the choir; I love it).

Tarek Ziade wrote Flake8 to combine pep-8 analysis and pyflakes analysis, but it’s blocking.

khuno.vim (by Alfredo) is non-blocking.

Back to flipping out…