Skip to content

Instantly share code, notes, and snippets.

View crazyguitar's full-sized avatar
🎯
Focusing

CHANG-NING TSAI crazyguitar

🎯
Focusing
View GitHub Profile
@crazyguitar
crazyguitar / Makefile
Created January 16, 2023 08:29 — forked from sehe/Makefile
Boost shared memory lockfree circular buffer queue
all:consumer producer
CPPFLAGS+=-std=c++03 -Wall -pedantic
CPPFLAGS+=-g -O0
CPPFLAGS+=-isystem ~/custom/boost/
LDFLAGS+=-L ~/custom/boost/stage/lib/ -Wl,-rpath,/home/sehe/custom/boost/stage/lib
LDFLAGS+=-lboost_system -lrt -lpthread
%:%.cpp
@crazyguitar
crazyguitar / get.c
Created January 8, 2023 03:33 — 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[])
@crazyguitar
crazyguitar / bloomfilter.py
Created December 26, 2022 09:04 — forked from mburst/bloomfilter.py
Code for creating and testing a simple bloom filter - http://maxburstein.com/blog/creating-a-simple-bloom-filter/
from bitarray import bitarray
import mmh3
class BloomFilter:
def __init__(self, size, hash_count):
self.size = size
self.hash_count = hash_count
self.bit_array = bitarray(size)
self.bit_array.setall(0)
@crazyguitar
crazyguitar / docker-compose.yml
Created December 24, 2022 19:04 — forked from brunosimioni/docker-compose.yml
Docker Compose to Prometheus, PushGateway and Grafana setup
version: '2.1'
networks:
monitor-net:
driver: bridge
volumes:
prometheus_data: {}
grafana_data: {}
@crazyguitar
crazyguitar / bash_strict_mode.md
Created September 30, 2022 04:06 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation
@crazyguitar
crazyguitar / tutorial.txt
Created September 23, 2022 05:56 — forked from JamesMenetrey/tutorial.txt
PwnTools; example of usage
Source: https://tc.gts3.org/cs6265/2017/l/lab04/README-tut.txt
====================================
Lec04: Writing Exploits with PwnTool
====================================
http://docs.pwntools.com/
http://docs.pwntools.com/en/stable/intro.html
@crazyguitar
crazyguitar / subprocess_pipe.md
Created September 18, 2022 06:25 — forked from waylan/subprocess_pipe.md
Writing to a python subprocess pipe

Here's a few things I tried to write output to a python subprocess pipe.

from subprocess import Popen, PIPE

p = Popen('less', stdin=PIPE)
for x in xrange(100):
    p.communicate('Line number %d.\n' % x)
@crazyguitar
crazyguitar / loop.py
Created April 30, 2022 01:14 — forked from TeweiLuo/loop.py
python epoll
import subprocess
import select
from sys import exit
p = subprocess.Popen(['python3', './subproc.py'], stdout=subprocess.PIPE)
e = select.epoll()
e.register(p.stdout.fileno())
while True:
events = e.poll(1)
@crazyguitar
crazyguitar / rwlock.py
Created April 10, 2022 18:16 — forked from tylerneylon/rwlock.py
A simple read-write lock implementation in Python.
# -*- coding: utf-8 -*-
""" rwlock.py
A class to implement read-write locks on top of the standard threading
library.
This is implemented with two mutexes (threading.Lock instances) as per this
wikipedia pseudocode:
https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Using_two_mutexes