Skip to content

Instantly share code, notes, and snippets.

View sjlongland's full-sized avatar

Stuart Longland sjlongland

View GitHub Profile
@sjlongland
sjlongland / 0001-imx-bootlets-Add-fno-stack-protector.patch
Created June 25, 2014 06:56
[PATCH] imx-bootlets: Add -fno-stack-protector
From 395ac8e68801f22234269e301a716b3e67b4b5a2 Mon Sep 17 00:00:00 2001
From: Stuart Longland <me@vk4msl.yi.org>
Date: Wed, 25 Jun 2014 13:28:04 +1000
Subject: [PATCH] imx-bootlets: Add -fno-stack-protector
Gentoo's toolchain uses the stack protector by default and needs to be
told *not* to in order to successfully build the boot stream.
---
imx-bootlets-src-10.12.01/boot_prep/Makefile | 2 +-
imx-bootlets-src-10.12.01/linux_prep/Makefile | 2 +-
@sjlongland
sjlongland / amqp.py
Last active November 14, 2018 14:13
Tornado Coroutine interface to AMQP (pika)
#!/usr/bin/python
import datetime
import logging
import threading
import weakref
import tornado
import tornado.gen
import pika
@sjlongland
sjlongland / future.py
Last active August 29, 2015 14:13
Arithmetic and method calls to Future objects
import tornado
import tornado.gen
import tornado.concurrent
'''
A proof-of-concept library that allows a Future to be treated like the object
it will eventually yield to. Attributes and method calls are translated, with
Future and FutureObject references yielded before calling.
Most standard Python routines are supported.
@sjlongland
sjlongland / asynchronous-client-tornado.py
Created May 21, 2015 03:26
Using pymodbus in TornadoWeb IO loop
#!/usr/bin/env python
'''
Pymodbus Asynchronous Client Examples -- using Tornado
--------------------------------------------------------------------------
The following is an example of how to use the asynchronous modbus
client implementation from pymodbus.
'''
#---------------------------------------------------------------------------#
# import needed libraries
import gd
import argparse
from sys import stdout
parser = argparse.ArgumentParser(
description='Extract bits from the border colour of each tile',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--image', help='Image file to parse')
parser.add_argument('--invert', help='Invert the bits',
action='store_const', default=False, const=True)
import gd
import argparse
from sys import stdout
parser = argparse.ArgumentParser(
description='Extract bits from the average colour of each tile',
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--image', help='Image file to parse')
parser.add_argument('--invert', help='Invert the bits',
action='store_const', default=False, const=True)
@sjlongland
sjlongland / pyhaystack-api-ideas.md
Created January 23, 2016 11:02
pyhaystack API ideas

Project Haystack API ideas

The Project Haystack interface is largely based on plain GET/POST requests made over either HTTP or HTTPS. Authentication differs between versions, but common methods include custom headers (e.g. SkySpark, WideSky) and conventional HTTP authentication (nHaystack).

Having authenticated, a couple of API endpoints allow us to discover what sort of server we are talking to. It's a shame that the authentication method isn't discoverable in the same manner, but that's life.

@sjlongland
sjlongland / gist:b9f6e49b5e803f8b7962e4fc2d62f597
Created December 22, 2016 00:54
pyhaystack 0.91.0 on Debian, works with nHaystack
In [1]: from pyhaystack.client.niagara import NiagaraHaystackSession
In [2]: import logging; logging.basicConfig(level=logging.DEBUG)
In [3]: ax = NiagaraHaystackSession(uri='http://…', username='…', password='…', http_args=dict(debug=True))
In [4]: op = ax.about()
DEBUG:pyhaystack.client.NiagaraHaystackSession.http_client:Merging None with None, exclude None -> {}
DEBUG:pyhaystack.client.NiagaraHaystackSession.http_client:Merging {} with None, exclude True -> {}
DEBUG:pyhaystack.client.NiagaraHaystackSession.http_client:Merging {} with None, exclude True -> {}
@sjlongland
sjlongland / gist:1f0c1a5115f19cc5d0a88f979aab7580
Created April 26, 2017 19:49
pyhaystack build failure on Python 2.7
simple 26-Apr-2017 15:55:10 Build WideSky - Pyhaystack - bugfix-WC-846-fix-http-status-handling - Unit tests #1 (WS-PYH5-UT-1) started building on agent Local Agent 2
simple 26-Apr-2017 15:55:10
simple 26-Apr-2017 15:55:10 Build working directory is /srv/bamboo/working/1933313/WS-PYH5-UT
simple 26-Apr-2017 15:55:10 Executing build WideSky - Pyhaystack - bugfix-WC-846-fix-http-status-handling - Unit tests #1 (WS-PYH5-UT-1)
simple 26-Apr-2017 15:55:10 Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'
simple 26-Apr-2017 15:55:10 Updating source code to revision: 41789c9de1a0818a87a045415742937d6891535d
simple 26-Apr-2017 15:55:12 Fetching 'refs/heads/bugfix/WC-846-fix-http-status-handling' from 'https://bitbucket.org/vrtsystems/pyhaystack.git'.
simple 26-Apr-2017 15:55:13 Checking out revision 41789c9de1a0818a87a045415742937d6891535d.
simple 26-Apr-2017 15:55:13 Creating local git repository in '/srv/bamboo/working/1933313/WS-PYH5-UT/src/.git'.
simple 26-Ap
@sjlongland
sjlongland / arm_cortex_m3_mutex.c
Last active January 17, 2018 13:26 — forked from hdznrrd/arm_cortex_m3_mutex.c
basic implementation of a no-block / no-wait mutex for ARM Cortex M3 and compatible models
/*!
* Cortex M3 mutex implementation.
* Ported to gcc by Stuart Longland <stuartl@vrt.com.au>
*
* Credit: https://gist.github.com/hdznrrd/4032002
*/
#ifndef _CM3MUTEX_H
#define _CM3MUTEX_H