Skip to content

Instantly share code, notes, and snippets.

@karlp
karlp / MANIFEST.in
Created August 16, 2013 08:37
Including git version in setup.py files. (Requires at least _one_ tag in the repo) Normally used to make things like, "python setup.py sdist" give you a predictable name for files. Normally used with tags on the repo like 0.1 or 2.3.0 You should add RELEASE-VERSION to MANIFEST.in so that end users of the tarball can use this too.
include RELEASE-VERSION
include version.py
# Anything else you normally use
@karlp
karlp / Vagrantfile
Created June 26, 2013 18:31
vagrant up sets up two virtual machines with salt-minion installed pointing to the static ip of my private machine.
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Create two virtual machines, each with salt-minion installed
# They are bridged, so they need to reach a salt master somewhere.
# you can use these for trying out salt for deploying slightly different
# data collector settings for different machines from the same salt states
Vagrant.configure("2") do |config|
box_url = "http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-i386-disk1.box"
@karlp
karlp / gist:4452408
Last active December 10, 2015 15:09
proposed text for pagekitec
PageKite is a system for running publicly visible servers (generally
web servers) on machines without a direct connection to the Internet,
such as mobile devices or computers behind restrictive firewalls.
PageKite works around NAT, firewalls and IP-address limitations by
using a combination of tunnels and reverse proxies.
.
This package provides an implementation of the PageKite Protocol in C,
optimized for high-performance or embedded applications.
.
Basic UCI support for HTTP and SSH servers is also included in this package.
@karlp
karlp / sample output
Created November 30, 2012 18:10
mosquitto-cpu-testing
$ lua send-cpu.lua
Posted 35 messages in 0.955896 seconds, long term: total=35, rate: 36.614710 msgs/sec
Posted 35 messages in 0.953455 seconds, long term: total=70, rate: 31.679929 msgs/sec
Posted 35 messages in 0.882752 seconds, long term: total=105, rate: 30.950216 msgs/sec
Posted 35 messages in 0.883659 seconds, long term: total=140, rate: 30.591545 msgs/sec
Posted 35 messages in 0.940316 seconds, long term: total=175, rate: 30.084469 msgs/sec
Posted 35 messages in 0.887835 seconds, long term: total=210, rate: 29.978839 msgs/sec
Posted 35 messages in 0.949010 seconds, long term: total=245, rate: 29.681898 msgs/sec
Posted 35 messages in 0.884780 seconds, long term: total=280, rate: 29.663531 msgs/sec
Posted 35 messages in 0.951152 seconds, long term: total=315, rate: 29.465380 msgs/sec
@karlp
karlp / lua-fed17-x64.diff
Created November 26, 2012 17:23
Patch lua to match default fed17-x64 paths
diff --git a/src/luaconf.h b/src/luaconf.h
index e2cb261..0e218b5 100644
--- a/src/luaconf.h
+++ b/src/luaconf.h
@@ -94,9 +94,9 @@
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll"
#else
-#define LUA_ROOT "/usr/local/"
+#define LUA_ROOT "/usr/"
@karlp
karlp / backup.sh
Created November 13, 2012 20:03
Karl's kinda simplistic backupsss
#!/bin/bash
# Karl's very simplistic backup script...
REALLY=$1
REAL_FLAGS=-avh
DEMO_FLAGS=-avnh
# "arx2011" is the volume name of my second harddisk
MOUNTED=$(mount | grep arx2011)
if [[ -z $MOUNTED ]]
@karlp
karlp / SimpleSecureHTTPServer.py
Created October 31, 2012 16:04
HTTPS python server
'''
SimpleSecureHTTPServer.py - simple HTTP server supporting SSL.
- replace fpem with the location of your .pem server file.
- the default port is 443.
usage: python SimpleSecureHTTPServer.py [server.pem] [port]
prereq: make a cert!
openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
@karlp
karlp / gist:2953799
Created June 19, 2012 12:10 — forked from jnareb/gist:2953631
libmodbus - reading from many slave_ids via RTU
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <modbus.h>
#define SM4_ID 3
#define P120_ID 2
@karlp
karlp / modbus_master.c
Created September 7, 2011 19:27
libmodbus sample master, always gets errno == 9 for all operations after it's connected (but still works just fine)
#include <stdio.h>
#include <errno.h>
#include <modbus.h>
int main(int argc, char **argv) {
modbus_t *mb;
uint16_t tab_reg[32];
int rc;
@karlp
karlp / _etc_init.d_mosquitto
Created August 25, 2011 14:02
using daemon to make a respawning mosquitto server
#! /bin/bash
# Based on /etc/init.d/sshd as it came on CentOS 5.6:
#
# Copyright (c) 1995-2000 SuSE GmbH Nuernberg, Germany.
#
# Author: Jiri Smid <feedback@suse.de>
# /etc/init.d/mosquitto
#