Skip to content

Instantly share code, notes, and snippets.

View posborne's full-sized avatar

Paul Osborne posborne

View GitHub Profile
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
@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
@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 / 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
"""
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 / 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;
@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 / closure.c
Created February 17, 2015 04:24
Closures in C using libffi closures API
#include <stdio.h>
#include <ffi.h>
#include <stdlib.h>
/* Acts like puts with the file given at time of enclosure. */
void puts_binding(ffi_cif *cif, void *ret, void* args[], void *stream) {
*(ffi_arg *) ret = fputs(*(char **) args[0], (FILE *) stream);
}
typedef int (*puts_t)(char *);
#include <linux/ioctl.h>
#include <stdio.h>
int main(int argc, char **argv) {
printf("_IO('q', 10) => 0x%08lX\n", (unsigned long int)_IO('q', 10));
printf("_IO('a', 255) => 0x%08lX\n", (unsigned long int)_IO('a', 255));
printf("_IOW('z', 10, char[1]) => 0x%04lX\n", _IOW('z', 10, char[1]));
printf("_IOW('z', 10, char[512] => 0x%04lX\n", _IOW('z', 10, char[512]));
printf("_IOW('z', 10, char[1 << 32] => 0x%04lX\n", _IOW('z', 10, char[1 << 32])); // _IOC_SZ_BITS = 14
@posborne
posborne / k20.json
Created May 19, 2015 06:36
zinc k20 json (testing)
{
"arch": "arm",
"cpu": "cortex-m4",
"data-layout": "e-m:e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-v128:64:128-a:0:32-n32-S64",
"disable-redzone": true,
"executables": true,
"llvm-target": "thumbv7m-none-eabi",
"morestack": false,
"os": "none",
"relocation-model": "static",