Skip to content

Instantly share code, notes, and snippets.

View MatrixManAtYrService's full-sized avatar

Matt Rixman MatrixManAtYrService

View GitHub Profile
@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;
double x = 5.001;
int n = (int)x;
cout << n; // output: 5
    int foo[] = {1,2};   // an array of int
    char bar[] = "ab";   // an array of char
    void* baz = foo;   // a pointer to the first element of foo
    cout << *(baz++);    // you might think that this would print the second element of foo
    void* qux = bar; // a pointer to the first element of bar
    cout << *(qux++);    // you might think that this would print the second element of bar