Skip to content

Instantly share code, notes, and snippets.

View MatrixManAtYrService's full-sized avatar

Matt Rixman MatrixManAtYrService

View GitHub Profile
@MatrixManAtYrService
MatrixManAtYrService / locustfile.py
Created February 6, 2019 18:47
example of keeping tasks on a single class
from locust import HttpLocust, TaskSet, task
import json
class UserBehavior(TaskSet):
def on_start(self):
# this retrieves a coookie from the server and stores in in a RequestsCookieJar: self.locust.client.cookes
# that is, it stores the cookie on an instance of this class, not the class itself (as your code does)
# your server may have different requirements for how the login request should look, but this worked for me
self.client.post("/login",
@MatrixManAtYrService
MatrixManAtYrService / luigi
Created January 18, 2019 18:54
Linux pipe reconstruction
#! /usr/bin/env bash
# This script interrogates the system and constructs a JSON representation of the pipeline that it is part of.
# It is a proof-of-concept. A more useful utility would accept a parameter that targets not the pipeline of the
# utility itself, but insted that of its parent, or grandparent, or great grandparent, or whatever. Such a tool could
# be used to sense the correct output-format based on who is listening downstream.
# Usage Example:
# cat -b | ./luigi | cat -e | jq .
@MatrixManAtYrService
MatrixManAtYrService / tb2j.sh
Created November 21, 2018 11:58
Converting tabular output to json
# Requires sqawk, datamash, and jq
# input tab delmited columns, newline delmited rows:
# foo bar
# 1 a
# 2 b
# tbr2j (rows to json)
#[
# Cursor shape switch based on mode:
# https://unix.stackexchange.com/questions/547/make-my-zsh-prompt-show-mode-in-vi-mode
KEYTIMEOUT=5
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne '\e[1 q'
elif [[ ${KEYMAP} == main ]] ||
@MatrixManAtYrService
MatrixManAtYrService / optipessibias.py
Last active July 25, 2018 21:00
controlling for pessimism and optimism
pessimist = [2, 2, 3, 2]
optimist = [4, 4, 5, 4]
def min_max(scores):
return list(map(lambda x : (x-min(scores))/(max(scores)-min(scores)), scores))
print(min_max(pessimist)) # [0, 0, 1, 0]
print(min_max(optimist)) # [0, 0, 1, 0]
def div_avg(scores):
# when I get lazy I put my bash wizard hat away and put on my vim wizard hat
echo bash 4.4.23
sudo docker run bash:4.4.23 -c 'RANDOM=5; (md5sum) <<< $RANDOM'
sudo docker run bash:4.4.23 -c 'RANDOM=5; (md5sum) <<< $RANDOM'
echo
echo bash 4.4
sudo docker run bash:4.4 -c 'RANDOM=5; (md5sum) <<< $RANDOM'
sudo docker run bash:4.4 -c 'RANDOM=5; (md5sum) <<< $RANDOM'
echo
echo bash 4
@MatrixManAtYrService
MatrixManAtYrService / Makefile
Created September 26, 2017 22:25
qmk_firmware/keyboards/planck/keymaps/matrixman
MOUSEKEY_ENABLE = yes
BACKLIGHT_ENABLE = yes
ifndef QUANTUM_DIR
include ../../../../Makefile
endif

The Problem

When the SWSS (Simple-WebSocket-Server) client connects to a server running libwebsockets:

  • The connection gets set up, and data moves through
  • The server fails to to call the appropriate callback for the specified protocol (/sky/api/v0/controller-sky in the example shown here)

This libwebsockets implementation is working, which I know because:

  • The connection gets up, and data moves through
  • The server calls the correct callback for the specified protocol (front-panel-protocol)
@MatrixManAtYrService
MatrixManAtYrService / itinerary.txt
Last active September 9, 2017 22:15
Candyland Road Trip
Pick up Drew's Gear
Drive 5.0 hours
Hotel in Grand Junction, Friday night
Sleep 8 hours
Pick up Drew @ GJT, 10:00 AM
- https://goo.gl/maps/ojm7HfQ9ivM2
Drive 1.75 hours
Moab Brewery (lunch?)
- https://goo.gl/maps/G3qvXJq8wMw
@MatrixManAtYrService
MatrixManAtYrService / decodeSpat.h
Last active September 7, 2017 14:08
Decoding an old (2014?) SPaT
#include <exception>
#include <array>
#include <stdint.h>
#define BUFFER_SIZE 10240
struct ControllerState
{
uint16_t PedCallActive = 0;