Skip to content

Instantly share code, notes, and snippets.

View posborne's full-sized avatar

Paul Osborne posborne

View GitHub Profile
@posborne
posborne / ptymaster.c
Created October 30, 2013 01:38
Example showing a simple usage of PTY without use of fork()
#define _XOPEN_SOURCE 600
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
/*
* Simple Echo Server that repeats back characters, with a spin
*/
@posborne
posborne / moneytimer.html
Created January 11, 2013 14:43
Timer to track how much time and money is being wasted in meetings
<html>
<head>
<title>Timer</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js"></script>
<script type="text/javascript">
var stdt = null;
var running = false;
var TICKS_PER_SEC = 1000;
padn = function(d, l) {
ds = "" + d;
from pacman.fields import UBInt16, VariableRawPayload, LengthField, Magic, \
UBInt8Sequence, DispatchField, DispatchTarget, UBInt8, UBInt32, BitField, BitNum, \
BitBool
from pacman.message import BaseMessage
import unittest
class UDPFrame(BaseMessage):
source_port = UBInt16()
destination_port = UBInt16()
@posborne
posborne / countpaths.py
Created February 13, 2012 01:44
Count paths through a directed acyclic graph (and display graph)
#!/usr/bin/env python
"""Build a graph, count the paths and visualize (using graphviz)
Under ubuntu 11.10, the following steps should allow you to run
this script (assuming working from virtualenv)::
$ pip install python-graph-core python-graph-dot
$ sudo apt-get install graphviz libgv-python
"""
@posborne
posborne / countpaths.py
Created February 13, 2012 01:32
Counts path in graph and display
#!/usr/bin/env python
"""Build a graph, count the paths and visualize (using graphviz)
Under ubuntu 11.10, the following steps should allow you to run
this script (assuming working from virtualenv)::
$ pip install python-graph-core python-graph-dot
$ sudo apt-get install graphviz libgv-python
"""
@posborne
posborne / getattr_test.py
Created December 31, 2011 00:52
Strange failure with getattr
from compiler import visitor as compvisitor
import compiler
import sys
class VisitorChecker(compvisitor.ASTVisitor):
"""
AST Visitor that pulls together individual AST checkers
The VisitorChecker takes in other Visitor classes and delegates
Traceback (most recent call last):
File "/usr/lib/python2.6/dist-packages/twisted/internet/selectreactor.py", line 146, in _doReadOrWrite
why = getattr(selectable, method)()
File "/usr/lib/python2.6/dist-packages/twisted/internet/tcp.py", line 667, in doConnect
self._connectDone()
File "/usr/lib/python2.6/dist-packages/twisted/internet/tcp.py", line 674, in _connectDone
self.protocol.makeConnection(self)
File "/usr/lib/python2.6/dist-packages/twisted/internet/protocol.py", line 349, in makeConnection
self.connectionMade()
File "/usr/lib/python2.6/dist-packages/twisted/web/client.py", line 60, in connectionMade