Skip to content

Instantly share code, notes, and snippets.

View rene-d's full-sized avatar
🤘
Let There Be Rock

rene-d rene-d

🤘
Let There Be Rock
  • Thales
  • France
View GitHub Profile
@rene-d
rene-d / hexdump.c
Last active September 16, 2022 04:26
ultra fast dump function in C (output like hexdump -C)
// ultra fast dump function (output like hexdump -C)
void hexdump(const void *data, size_t size)
{
static const char digits[] = "0123456789abcdef";
char line[80]; // we use 79 chars at most
size_t i;
int j;
for (i = 0; i < size; i += 16)
{
@rene-d
rene-d / server.py
Created March 21, 2022 16:04 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
FROM alpine:edge AS toilet-builder
RUN apk update && apk add gcc musl-dev make curl unzip findutils fdupes
WORKDIR /build
# figlet
RUN curl -skL -o figlet-master.zip https://github.com/cmatsuoka/figlet/archive/refs/heads/master.zip && \
unzip -q -o figlet-master.zip && \
@rene-d
rene-d / Cargo.toml
Last active January 16, 2022 06:45
Rust cross-compilation example (on Apple Silicon with Docker)
[package]
name = "hello"
version = "0.1.0"
edition = "2021"
[dependencies]
[[bin]]
name = "hello"
path = "hello.rs"
@rene-d
rene-d / bashdb.sh
Last active November 9, 2023 07:29
Little debugger for bash scripts
#!/bin/echo must be source:
# bash debugger
# Rene Devichi. https://unlicense.org
# Usage: `source bashdb.db` at the beginning of your script
# Inline version:
# curl -sL -o /tmp/bashdb.sh https://gist.github.com/rene-d/fd2d2c37dfc1371255818d73f7b5f1db/raw/bashdb.sh
# trap "rm -f /tmp/bashdb.sh" EXIT
# . /tmp/bashdb.sh
@rene-d
rene-d / eject
Created May 15, 2021 09:42
The missing eject command in macOS
alias eject="diskutil list | sed -nr '/external, physical/s,^/dev/disk([0-9]+) .*,\1,p' | xargs -I+ diskutil eject /dev/rdisk+"
@rene-d
rene-d / shell_colors
Last active March 24, 2024 12:27
Show ANSI color sequences in a terminal
#!/usr/bin/env bash
# https://en.wikipedia.org/wiki/ANSI_escape_code
print_colors()
{
# Print column headers.
printf "%-4s " '' ${bgs[@]}
echo
#!/usr/bin/env python3
def chiffres(i):
return i // 100, (i // 10) % 10, i % 10
def bad(a, b, place, desordre, absent):
aa = a
a = chiffres(a)
@rene-d
rene-d / Dockerfile
Last active February 11, 2021 21:01
Build a more recent version of fuse-overlayfs for CentOS7/RHEL7
FROM centos:7 AS builder
RUN yum -y install gcc clang cmake automake python3-pip make git gcc-c++ vim glibc-static
RUN pip3 install meson ninja
WORKDIR /src
RUN git clone -b fuse-3.6.1 https://github.com/libfuse/libfuse && \
cd libfuse && \
#!/usr/bin/env python3
# rene-d 2020/07/23
from sys import argv
import operator
from PIL import Image, ImageDraw, ImageFont
import numpy as np
# import csv
import argparse