Skip to content

Instantly share code, notes, and snippets.

@thalesmg
thalesmg / gh-actions-order.css
Created January 27, 2024 21:01
github actions sort checks order
/* ==UserStyle==
@name github.com - Jan 2024
@namespace github.com/openstyles/stylus
@version 1.0.0
@description A new userstyle
@author Me
==/UserStyle== */
@-moz-document domain("github.com") {
/* in firefox you may need to set layout.css.has-selector.enabled to true in order for this to work */
@thalesmg
thalesmg / erlang-java-interop-demo.sh
Created June 28, 2023 12:44 — forked from eriksoe/erlang-java-interop-demo.sh
An Erlang-Java Interop Demo - executable summary
#!/bin/bash -x
#######################################################################
#
# Demo of Erlang IDL, as applied to property testing of Java code.
# We'll need Triq.
git clone git://github.com/krestenkrab/triq.git
(cd triq && ./rebar compile)
ERL_ROOT=`erl -noshell -eval 'io:format("~s\n", [code:root_dir()]), init:stop().'`
@thalesmg
thalesmg / person.proto
Last active May 24, 2023 14:10
Example of how to use Schema Registry + Rule Engine in EMQX 5.0 (protobuf, encoding)
// Generate `person_pb2.py` by running `protoc --python_out=. person.proto` before
// running `protobuf_mqtt.py`
syntax = "proto2";
package tutorial;
message Person {
required string name = 1;
required int32 id = 2;
@thalesmg
thalesmg / avro_mqtt_sub.py
Created May 23, 2023 20:09
Example of how to use Schema Registry + Rule Engine in EMQX 5.0 (avro, encoding)
# Original source: https://github.com/terry-xiaoyu/schema-registry-examples/blob/master/avro/avro_mqtt.py
import paho.mqtt.client as mqtt
import io
import json
import avro.schema
import avro.datafile
import avro.io
import avro.ipc
import time
@thalesmg
thalesmg / person.proto
Created May 22, 2023 14:23
Example of how to use Schema Registry + Rule Engine in EMQX 5.0 (protobuf)
// Generate `person_pb2.py` by running `protoc --python_out=. person.proto` before
// running `protobuf_mqtt.py`
syntax = "proto2";
package tutorial;
message Person {
required string name = 1;
required int32 id = 2;
@thalesmg
thalesmg / avro_mqtt.py
Last active May 22, 2023 14:21
Example of how to use Schema Registry + Rule Engine in EMQX 5.0 (avro)
# Original source: https://github.com/terry-xiaoyu/schema-registry-examples/blob/master/avro/avro_mqtt.py
import paho.mqtt.client as mqtt
import io
import json
import avro.schema
import avro.datafile
import avro.io
import avro.ipc
import time
@thalesmg
thalesmg / latest_stack.sh
Created October 20, 2022 21:01
Find latest avaiable Haskell Stack snapshot (LTS)
stack ls snapshots -l remote | rg -o 'lts-[0-9]+\.[0-9]+' | sort -rn | head -n1
stack ls snapshots -l remote | grep -Eo 'lts-[0-9]+\.[0-9]+' | sort -rn | head -n1
@thalesmg
thalesmg / random-bitmask-corrupt.hs
Created October 9, 2022 15:39
Generate random bit masks for corrupting packets with probability
{-# LANGUAGE ScopedTypeVariables #-}
-- https://stackoverflow.com/questions/2075912/generate-a-random-binary-number-with-a-variable-proportion-of-1-bits
import Control.Monad (replicateM)
import Data.Bits
import Data.Foldable (foldl')
import Data.Word (Word8)
import Numeric.Natural (Natural)
import System.Random (Random, randomIO)
@thalesmg
thalesmg / trace.thm
Created September 22, 2022 01:17
Simple two-phase commit in Alloy 6
<?xml version="1.0"?>
<alloy>
<view>
<defaultnode/>
<defaultedge/>
<node>
@thalesmg
thalesmg / core.clj
Created May 3, 2022 19:35
example pulsar client using basic auth in clojure
(ns pulsar-test.core
(:import (org.apache.pulsar.client.api PulsarClient)))
(defn make-consumer
[]
(let [props (doto (java.util.Properties.)
(.putAll {"userId" "super"
"password" "superpass"}))
client (-> (PulsarClient/builder)
(.serviceUrl "pulsar://localhost:6650")