Skip to content

Instantly share code, notes, and snippets.

View pldubouilh's full-sized avatar

Pierre Dubouilh pldubouilh

View GitHub Profile
@pldubouilh
pldubouilh / test.sh
Last active February 28, 2024 13:22
API integration tests
#! /bin/bash
set -e
# set -x
# Integration tests made easy !
# Locally it assumes DB and server is running, and on a CI it automagically starts them and waits till they're up
# All tests are cURL based, using files on tmp to pass state and variables - this allows for very easy manual debugging
# if a test fails, as the state remains on disk, and you can just copy/past the call
function test() {
@pldubouilh
pldubouilh / steps.md
Created April 9, 2023 18:48
uinifi ap ac no registration setup with guest network

uinifi ap ac with guest network

start unifi-controller:

$ docker run -d \
  -e PUID=1000 \
  -e PGID=1000 \
 -e TZ=Etc/UTC \
@pldubouilh
pldubouilh / deb2ipk.sh
Last active September 27, 2024 11:56
deb2ipk script - easy conversion from deb to opkg package (ipk)
#!/bin/bash
# inspired from https://github.com/jordansissel/fpm/issues/1323#issuecomment-450613806
if [ $# -ne 2 ]; then
echo 'USAGE: ./deb2ipk.sh arch input-deb'
echo 'WARNING: for amd64 set arch as x86_64'
exit 1
fi
set -e
@pldubouilh
pldubouilh / inject.js
Created September 8, 2022 12:35
cleaner slack
var cssText = `.p-workspace-layout {
height: 100% !important;
top: 0px !important;
position: absolute !important;
left: 0px !important;
right: 0px !important;
grid-template-rows: 0px auto !important;
}
.p-workspace__primary_view {
max-height: unset !important;
@pldubouilh
pldubouilh / papers_please_fix.cpp
Created January 2, 2022 14:23 — forked from Henje/papers_please_fix.cpp
Simple hack to disable joystick scanning and remove stutters from Papers Please.
#include <string>
#include <dlfcn.h>
#include <stdio.h>
#include <sys/mman.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
using namespace std::literals;
@pldubouilh
pldubouilh / get.c
Created February 10, 2021 15:19 — forked from garcia556/get.c
POSIX shared memory IPC example (shm_open, mmap), working on Linux and macOS
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#define STORAGE_ID "/SHM_TEST"
#define STORAGE_SIZE 32
int main(int argc, char *argv[])
@pldubouilh
pldubouilh / fuzzer.c
Created April 18, 2020 19:07
clang fuzzing
#include <stdio.h>
#include <string.h>
// clang -O0 -Wall -g -fsanitize=fuzzer fuzzer.c && ./a.out
int LLVMFuzzerTestOneInput(const char *Data, size_t Size)
{
int maxlen = (int) Size;
const char *start = Data;
@pldubouilh
pldubouilh / xdp.py
Last active August 10, 2023 17:05
xdp h2o connection tracing example
#!/usr/bin/python
#
# simple XDP eBPF program to flag connections using an eBPF map
# this example adds connections to ::1 ::1 to a an eBPF map
# depends on `bpftool` for now, as bcc is missing map pinning
#
# the map is spinned by the XDP program, and this python handler
# will call `bpftool` to pin the map to a path to allow system-wide
# access. the path will be removed when the program quits.
#
@pldubouilh
pldubouilh / a.c
Last active February 28, 2023 13:47
system wide accessible pinned eBPF maps
/**
* some musings around eBPF maps, for defining || reusing per-cpu maps
*
* maps defined here are accessible system-wide as they are defining or using a pin
*
* useful monitoring cmds:
* sudo bpftool map dump pinned /sys/fs/bpf/h2o_map
* sudo bpftool map show
*/
@pldubouilh
pldubouilh / readme.md
Last active May 6, 2019 10:42
dtrace <> ebpf <> handler

quick example to

  • define a map from the eBPF program
  • pin the map to a fs path (/sys/fs/bpf/map_instruction) from the handler program
  • read the pinned map from a C program using the bpf syscall

tested so far on linux, requires bpftool (provided by bpf in arch/community)

% clang test.c && sudo ./a.out