Skip to content

Instantly share code, notes, and snippets.

View gregglind's full-sized avatar

Gregg Lind gregglind

View GitHub Profile
@gregglind
gregglind / shell.py
Created November 10, 2010 19:20
Subprocess callout for python
import shlex
from subprocess import Popen, PIPE
def is_stringy(x):
'''
Is x a multiple type (like list, dict, tuple), or a 'single' type,
such as string.
>>> is_stringy(xrange(3))
False
@gregglind
gregglind / sa_pgsql_copy_expert.py
Created November 11, 2010 16:19
use native pg 'copy' to or from...
def pgsql_copy(session,tablename,string_buffer,direction="from"):
"""
Args:
session: a SA session that with a started transaction.
tablename: the table to write into
string_buffer: handle to a filelike, with seek set to 0
direction: from|to, which way it should go.
sele
Returns:
True on success, raises on errror
@gregglind
gregglind / dirs_same_enough.py
Created November 15, 2010 19:58
blunt, 90% solution to 'are two dirs the same' using filecmp
def dirs_same_enough(dir1,dir2,report=False):
''' use os.walk and filecmp.cmpfiles to
determine if two dirs are 'same enough'.
Args:
dir1, dir2: two directory paths
report: if True, print the filecmp.dircmp(dir1,dir2).report_full_closure()
before returning
Returns:
@gregglind
gregglind / classless.py
Created November 19, 2010 04:18
Showing some raw python, if there were no classes...
## python without classes?
def newlist(items):
def in_(item):
return item in items
def index(a):
return items.index(a)
def pretty():
<html>
<head>
<title>Data Conlficts Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script src="http://cdn.jquerytools.org/1.2.5/jquery.tools.min.js"></script>
<script>
$(
function(){
[gregg@gregg-vh master python-project]$ git log -n100 --graph --abbrev-commit --pretty=oneline --decorate
* 2c47f95 (HEAD, svn/tags/python-project-0.1.7, master) trying to get things back on main trunk
* 1c5b935 junk2
* f97ea26 junk file for testing svn update
* a4b9e34 release tag for python-project-0.1.7
* 5b81d53 (svn/tags/python-project-0.1.4) 0.1.7
* aae9a08 basic test script added, but doctests fails.
* c10b623 import the full io package into utils
* 895c208 Makefile drivin build process
* 549f95d Adding default dict, tempio, bump to 0.1.6
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>disabled form demo</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#when').attr('readonly','readonly');
class Instruction(object):
def __init__(**kwargs):
for k,v in kwargs.items():
self.k = v
def __repr__(self):
return "%s %r" % (self.__class__, self.__dict__)
def __call__(self,memory):
@gregglind
gregglind / rst.style.css
Created April 15, 2011 21:56
A simple css stylesheet
body {
width: 500px;
margin-right: auto;
color: #444;
font-family: Helvetica, Arial, Sans Serif;
font-size; 1em;
line-height: 1.4em;
}
h1, h2, h3, h4, h5, h6 {
each group can have a committee
staging and master
employable foundations? "here's how you leave the nest"
for inside pystar minneapolis
curriculum: