Skip to content

Instantly share code, notes, and snippets.

Avatar

Stuart Longland sjlongland

View GitHub Profile
@sjlongland
sjlongland / 0001-imx-bootlets-Add-fno-stack-protector.patch
Created Jun 25, 2014
[PATCH] imx-bootlets: Add -fno-stack-protector
View 0001-imx-bootlets-Add-fno-stack-protector.patch
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 / future.py
Last active Aug 29, 2015
Arithmetic and method calls to Future objects
View future.py
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
Using pymodbus in TornadoWeb IO loop
View asynchronous-client-tornado.py
#!/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
View itanimulli_extract_bits.py
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)
View itanimulli_extract_bits_avg.py
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)
View pyhaystack-api-ideas.md

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 Dec 22, 2016
pyhaystack 0.91.0 on Debian, works with nHaystack
View gist:b9f6e49b5e803f8b7962e4fc2d62f597
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 Apr 26, 2017
pyhaystack build failure on Python 2.7
View gist:1f0c1a5115f19cc5d0a88f979aab7580
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 / radio.c
Created Nov 9, 2017
OpenThread radio.c with CC2592 calibration
View radio.c
/*
* Copyright (c) 2016, The OpenThread Authors.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
@sjlongland
sjlongland / portable_endian.h
Last active Nov 13, 2017 — forked from panzi/portable_endian.h
This provides the endian conversion functions form endian.h on Windows, Linux, *BSD, and Mac OS X. You still need to use -std=gnu99 instead of -std=c99 for gcc. The functions might actually be macros. Functions: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, be64toh, le64toh. License: I hereby put "port…
View portable_endian.h
// "License": Public Domain
// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
// In case there are jurisdictions that don't support putting things in the public domain you can also consider it to
// be "dual licensed" under the BSD, MIT and Apache licenses, if you want to. This code is trivial anyway. Consider it
// an example on how to get the endian conversion functions on different platforms.
#ifndef PORTABLE_ENDIAN_H__
#define PORTABLE_ENDIAN_H__
#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)