Skip to content

Instantly share code, notes, and snippets.

Christopher O'Brien obriencj

Block or report user

Report or block obriencj

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@obriencj
obriencj / cli_stub.py
Created Dec 31, 2013
Stub that I find useful for writing CLI utilities
View cli_stub.py
#!/usr/bin/env python2
"""
Given two tags, do absolutely nothing.
This script is just a stub illustrating the bits I re-use for every
CLI utility I write.
@obriencj
obriencj / spexy repl example
Created Jan 22, 2014
Spexy had a repl, for testing purposes. The >>>> lines are my input, the --> lines are spexy letting me see the Python code it created from my input, and then following that is the result of the evaluation if any.
View spexy repl example
[siege@maybe src]$ python spexy.py
>>>> (defun make_pair ()
(letrec ((value None)
(getter (lambda () value))
(setter (lambda (v) (setf value v))))
(make-list getter setter)))
--> globals().__setitem__('make_pair', (lambda : ((lambda value, getter, setter: ((value.__setitem__(0, None), getter.__setitem__(0, (lambda : value[0])), setter.__setitem__(0, (lambda v: value.__setitem__(0, v))),)[-1], [getter[0], setter[0],],)[-1])([None], [None], [None]))))
>>>> (letrec ((gs (make_pair)))
(define getter (getf gs 0))
(define setter (getf gs 1)))
@obriencj
obriencj / more spexy repl
Last active Jan 4, 2016
This is how I roll on a Friday night, getting crazy up in here.
View more spexy repl
maybe:python-spexy siege$ PYTHONPATH=./ python
Python 2.7.6 (default, Nov 18 2013, 15:12:51)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from spexy import repl
>>> from datetime import datetime
>>> repl(globals())
>>>> (let ((who "siege") (date 1999))
(letrec ((fmt "Hello %s, party like it is %i!")
(msg (% fmt (make-tuple who date))))
@obriencj
obriencj / output of spexy_try
Last active Jan 4, 2016
An attempt to create a Python expression that acts like the try/except/finally blocks.
View output of spexy_try
maybe:python-spexy siege$ PYTHONPATH=./ python tmp/spexy_try.py
The original spexy source is
-----
(defun division (x y)
(let ((result None))
(try
(setf result (/ x y))
((ZeroDivisionError)
(println "division by zero!" x "/" y)
@obriencj
obriencj / lambda.py
Last active Jan 4, 2016
My take on the church of lambda
View lambda.py
"""
My take on the Church of Lambda. I've tweaked and added a few thing to
make life more enjoyable
author: Christopher O'Brien <siege@preoccupied.net>
inspiration from http://doos.m3r.nl/~ivo/lambda.txt
"""
@obriencj
obriencj / despair.scm
Last active Aug 29, 2015
Scheme Comedy
View despair.scm
((lambda (f)
((lambda (r) (f (lambda () ((r r)))))
(lambda (r) (f (lambda () ((r r)))))))
(lambda (despair)
(lambda () (despair))))
@obriencj
obriencj / eval_no_closures.py
Created Feb 26, 2014
Examples of compile/eval not giving me a chance to provide lexical bindings for it to snag closures from
View eval_no_closures.py
def attempt_1():
data = list()
# no prob, bob. data is captured as a closure cell of action
action = lambda x: data.append(x)
action(5)
return data
@obriencj
obriencj / xmlrpc_unittest_harness.py
Last active Dec 24, 2015
An example harness for testing an XMLRPC client/server relationship
View xmlrpc_unittest_harness.py
from threading import Thread
from unittest import TestCase
from xmlrpclib import ServerProxy
from SimpleXMLRPCServer import SimpleXMLRPCServer
class Dummy(object):
def __init__(self):
self.data = list(xrange(0,10))
@obriencj
obriencj / tailcall.py
Created Mar 14, 2014
playing chicken with the python stack using exceptions
View tailcall.py
#! /usr/bin/env python3
from functools import partial
from inspect import currentframe
import sys
STACK_LIMIT = 64
View keybase.md

Keybase proof

I hereby claim:

  • I am obriencj on github.
  • I am obriencj (https://keybase.io/obriencj) on keybase.
  • I have a public key whose fingerprint is B813 6B61 D568 811E 626F 0DBA B5AB A230 5282 9C5C

To claim this, I am signing this object:

You can’t perform that action at this time.