Skip to content

Instantly share code, notes, and snippets.

View stormouse's full-sized avatar
🧸

Shawnc stormouse

🧸
  • North America
View GitHub Profile
@stormouse
stormouse / gist:b4b4aa16ee18d95fcc574e5357af3eaa
Created June 16, 2023 19:58
FollyIobufAsStdStreambuf.h
#pragma once
#include <exception>
#include <streambuf>
#include <iostream>
#include <memory>
#include <string>
#include <unordered_map>
#include <folly/io/IOBuf.h>
#include <folly/io/Cursor.h>
@stormouse
stormouse / notes_profile
Created September 28, 2022 13:20
note taking script
function tn {
local EDITOR=${TAKE_NOTE_EDITOR:-"vim"}
local DIRECTORY=${TAKE_NOTE_DIRECTORY:-"${HOME}/.notes"}
local ACTIVE_NOTE=${TAKE_NOTE_ACTIVE_NOTE:-"note-$(date +%Y-%m-%d)"}
if [ "${#}" == "0" ]; then
${EDITOR} ${DIRECTORY}/${ACTIVE_NOTE}
else
printf "[%s] %s\n" "$(date +%H:%M:%S)" "${*}" | tee -a ${DIRECTORY}/${ACTIVE_NOTE}
fi
FLAGS = -std=c++20 -stdlib=libc++ -fcoroutines-ts -lpthread
INC = -I/usr/lib/llvm-13/include/c++/v1
coroutine: coroutine.o
clang++ $(FLAGS) $(INC) coroutine.o -o coroutine
coroutine.o: coroutine.cpp
clang++ $(FLAGS) $(INC) -c coroutine.cpp -o coroutine.o
clean:
@stormouse
stormouse / do-calculus-backdoor-finder.py
Last active December 30, 2021 08:37
do-calculus-backdoor-finder
"""
Copyright 2021 stormouse
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
@stormouse
stormouse / parse_perf_script.py
Last active November 25, 2021 03:34
Parse output of perf script
# usage: python this.py <(perf script -i perf.data -F comm,tid,time,ip,sym,cpu,event)
import fileinput
proc_sample_total = 0
cpu_inc = {}
cpu_ext = {}
comm = '<your-process-name>'[:15].lower()
interested = True
@stormouse
stormouse / http-pcap.cs
Created November 9, 2021 16:35
Unreliable http request extraction from pcap
void Main()
{
var readerFactory = new PacketReaderFactory();
var packetReader = readerFactory.Create(@"<>.pcap");
IDisplayer displayer = DisplayerFactory.Text(System.Console.Out);
Dictionary<(int, int), HttpRequestCutter> comms = new Dictionary<(int, int), UserQuery.HttpRequestCutter>();
foreach (var packet in packetReader.ReadPackets())
{
@stormouse
stormouse / sketch_201206a.pde
Created January 2, 2021 19:01
A semi-auto random block profile pic generator perhaps
// algo
int minBlockWidth = 2;
int minBlockHeight = 2;
int maxBlockWidth = 5;
int maxBlockHeight = 5;
class Block
{
color c;
@stormouse
stormouse / pbd-distance-constraint-example.js
Last active January 1, 2021 23:13
pbd-distance-constraint-example.js
// you can try it out on https://editor.p5js.org/
class Constraint {
constructor(constraintType, updateFunc, stiffness) {
this.ctype = constraintType;
this.f = updateFunc;
this.stiffness = stiffness;
}
project(verts) {
@stormouse
stormouse / jf_nbi.cs
Created September 25, 2020 10:44
json flattener and naivebayes inference
void Main()
{
var exampleJson = @"
{
""random"": 37,
""random float"": 51.886,
""bool"": true,
""date"": ""1982-05-19"",
""regEx"": ""hellooooooooo to you"",
""enum"": ""json"",
@stormouse
stormouse / draft.cxx
Created February 2, 2020 23:33
game network event design discussion
void main()
{
start_network();
start_game();
}
void network(callback on_receive_a, callback on_receive_b)
{
while(1)
{