Skip to content

Instantly share code, notes, and snippets.

@dbarnett
dbarnett / .vimrc
Created Mar 28, 2020
Sample minimal .vimrc for reproducing vim-codefmt bug xyz
View .vimrc
call plug#begin('~/.vim/plugged')
Plug 'google/vim-maktaba'
Plug 'google/vim-codefmt'
Plug 'google/vim-glaive'
call plug#end()
call glaive#Install()
View missing_method.py
"""
Response to
http://venodesigns.net/2010/11/02/emulating-rubys-method_missing-in-python/
If you're going to enumerate each "missing method" and its args, why not just
define a stub?
"""
class Twython(object):
def __init__(self, params):
@dbarnett
dbarnett / pip_anyjson.trace
Created Feb 26, 2012
snippet from python -m trace --trace pdb install dist/anyjson-0.3.1.tar.gz
View pip_anyjson.trace
This file has been truncated, but you can view the full file.
--- modulename: req, funcname: prepare_files
req.py(898): unnamed = list(self.unnamed_requirements)
req.py(899): reqs = list(self.requirements.values())
--- modulename: req, funcname: values
req.py(754): values_list = []
req.py(755): for key in self._keys:
req.py(757): return values_list
req.py(900): while reqs or unnamed:
req.py(901): if unnamed:
@dbarnett
dbarnett / cars.py
Created Feb 11, 2012
Object-oriented demonstration for SO question http://stackoverflow.com/q/9237725/307705
View cars.py
import random
class Vehicle(object):
def __init__ (self, _id):
self.company = None
self.id = _id
def printDoors(self):
print 'Car ' + str(self.id) + ' has ' + str(self.doors) + ' doors.'
@dbarnett
dbarnett / jsonalchemy.py
Created Feb 3, 2012
JSONAlchemy: Proper JSON marshalling and mutation tracking in SQLAlchemy
View jsonalchemy.py
import simplejson
import sqlalchemy
from sqlalchemy import String
from sqlalchemy.ext.mutable import Mutable
class JSONEncodedObj(sqlalchemy.types.TypeDecorator):
"""Represents an immutable structure as a json-encoded string."""
impl = String
View _get_setuptools_data_files.py
#!/usr/bin/env python
import glob
import os
import setuptools
import sys
import types
def show_all_files(*args, **kw):
# package files