Skip to content

Instantly share code, notes, and snippets.

View alex's full-sized avatar

Alex Gaynor alex

View GitHub Profile
import itertools
import tempfile
import subprocess
for i in itertools.count():
with tempfile.NamedTemporaryFile(suffix=".rb", delete=False) as f:
f.write("""
def f(*args)
end
f(%s)
from sqlalchemy import (MetaData, Table, Column, Boolean, Integer, String,
DateTime)
class Models(object):
def __init__(self, config):
super(Models, self).__init__()
self.metadata = MetaData()
self.builds = Table('builds', self.metadata,
Column('id', Integer, primary_key=True),
Disease-resistant dwarf wheat
Pasteurization
Acqueduct
Printing press
Trans-Atlantic telegraph cable
Interneta
@alex
alex / Original lyrics
Created October 1, 2012 04:23
I'm proud to be a unix programmer
If tomorrow all the things were gone,
I’d worked for all my life.
And I had to start again,
with just my children and my wife.
I’d thank my lucky stars,
to be livin here today.
‘ Cause the flag still stands for freedom,
and they can’t take that away.
import glob
import os
from fabric.api import task, local
class Test(object):
def __init__(self, func, deps=[], needs_pypy=True):
self.func = func
self.deps = deps
import glob
import os
from fabric.api import task, local
class Test(object):
def __init__(self, func, deps=[], needs_pypy=True):
self.func = func
self.deps = deps
$ wget http://python-distribute.org/distribute_setup.py
$ sudo python distribute_setup.py
$ wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$ sudo python get-pip.py
$ sudo pip install virtualenv virtualenvwrapper
$ mkvirtualenv my_project
$ pip install all the things

As we discussed earlier this evening here are some of my criticisms of go:

  1. Lack of parametric polymorphism, the failure to include C++'s templates, Java's generics, etc. makes it fundamentally impossible to do metaprogramming necessary for reusable code. And the go creators fundamentally know this is a necessary feature: the included hash table type is specialized to the types it is used with, a faculty not available to actual users of the language.

  2. Lack of exceptions. Go has two substitutes, panics, which are intended only for program ending conditions. And returning error codes. I'll ignore the former, since it isn't intended for general exception use. The latter fundamentally fails because they require the programer to never screw up. The beauty of exceptions is I can add appropriate error handling as I develop software and understand its failure modes, and I'll be alerted very clearly if I miss a case. Consider this python:

with open(path_to_file) as f: line = f.read(100)

Writing some markdown

<script type="text/javascript"> alert("lol");

Writing some markdown

<script type="text/javascript"> alert("lol");