Skip to content

Instantly share code, notes, and snippets.

From 3c148f31fba1b797322b84298eb802e479f2e809 Mon Sep 17 00:00:00 2001
From: Benoit Favre <[email protected]>
Date: Tue, 9 Sep 2014 11:08:56 +0200
Subject: [PATCH] FIX None macro from X11 colliding with Event::None and others
---
src/she/alleg4/she_alleg4.cpp | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/she/alleg4/she_alleg4.cpp b/src/she/alleg4/she_alleg4.cpp
@benob
benob / stbttf.h
Last active October 7, 2024 09:47
Example for using stb_truetype with SDL2 renderer. Only supports ASCII characters.
#ifndef __STBTTF_H__
#define __STBTTF_H__
#include <SDL2/SDL.h>
#include "stb_rect_pack.h"
#include "stb_truetype.h"
/* STBTTF: A quick and dirty SDL2 text renderer based on stb_truetype and stdb_rect_pack.
* Benoit Favre 2019
@benob
benob / exif_rotate.py
Created May 27, 2019 07:32
Rotate pictures according to EXIF orientation tag, in python using PIL. Supports all 8 orientations with a simple transposition operation.
# Proper exif rotation with PIL. Handles all the cases in https://github.com/recurser/exif-orientation-examples
from PIL import Image
image = Image.open(filename)
exif = image._getexif()
ORIENTATION = 274
if exif is not None and ORIENTATION in exif:
orientation = exif[ORIENTATION]
method = {2: Image.FLIP_LEFT_RIGHT, 4: Image.FLIP_TOP_BOTTOM, 8: Image.ROTATE_90, 3: Image.ROTATE_180, 6: Image.ROTATE_270, 5: Image.TRANSPOSE, 7: Image.TRANSVERSE}
if orientation in method:
@benob
benob / exif_rotate.py
Created May 27, 2019 07:32
Rotate pictures according to EXIF orientation tag, in python using PIL. Supports all 8 orientations with a simple transposition operation.
# Proper exif rotation with PIL. Handles all the cases in https://github.com/recurser/exif-orientation-examples
from PIL import Image
image = Image.open(filename)
exif = image._getexif()
ORIENTATION = 274
if exif is not None and ORIENTATION in exif:
orientation = exif[ORIENTATION]
method = {2: Image.FLIP_LEFT_RIGHT, 4: Image.FLIP_TOP_BOTTOM, 8: Image.ROTATE_90, 3: Image.ROTATE_180, 6: Image.ROTATE_270, 5: Image.TRANSPOSE, 7: Image.TRANSVERSE}
if orientation in method:
@benob
benob / exif_rotate.py
Created May 27, 2019 07:32
Rotate pictures according to EXIF orientation tag, in python using PIL. Supports all 8 orientations with a simple transposition operation.
# Proper exif rotation with PIL. Handles all the cases in https://github.com/recurser/exif-orientation-examples
from PIL import Image
image = Image.open(filename)
exif = image._getexif()
ORIENTATION = 274
if exif is not None and ORIENTATION in exif:
orientation = exif[ORIENTATION]
method = {2: Image.FLIP_LEFT_RIGHT, 4: Image.FLIP_TOP_BOTTOM, 8: Image.ROTATE_90, 3: Image.ROTATE_180, 6: Image.ROTATE_270, 5: Image.TRANSPOSE, 7: Image.TRANSVERSE}
if orientation in method:
@benob
benob / exif_rotate.py
Created May 27, 2019 07:32
Rotate pictures according to EXIF orientation tag, in python using PIL. Supports all 8 orientations with a simple transposition operation.
# Proper exif rotation with PIL. Handles all the cases in https://github.com/recurser/exif-orientation-examples
from PIL import Image
image = Image.open(filename)
exif = image._getexif()
ORIENTATION = 274
if exif is not None and ORIENTATION in exif:
orientation = exif[ORIENTATION]
method = {2: Image.FLIP_LEFT_RIGHT, 4: Image.FLIP_TOP_BOTTOM, 8: Image.ROTATE_90, 3: Image.ROTATE_180, 6: Image.ROTATE_270, 5: Image.TRANSPOSE, 7: Image.TRANSVERSE}
if orientation in method:
@benob
benob / brogue-ce.nix
Created May 24, 2020 19:33
nix package for brogue community edition
#{ stdenv, fetchurl, SDL2, SDL2_image makeDesktopItem }:
with import <nixpkgs> {};
stdenv.mkDerivation rec {
pname = "brogue-ce";
version = "1.8.3";
src = fetchFromGitHub {
owner = "tmewett";
repo = "BrogueCE";
@benob
benob / docker_extract.py
Created September 14, 2020 19:44
Extract a docker image retrieved with docker_pull.py (https://github.com/NotGlop/docker-drag)
# Extract a docker image retrieved with docker_pull.py (https://github.com/NotGlop/docker-drag)
import tarfile
import sys, json
# The tar contains a manifest.json which lists layers; each layer is a tar archive
with tarfile.TarFile(sys.argv[1]) as tf:
with tf.extractfile("manifest.json") as manifest_fp:
manifest = json.loads(manifest_fp.read())
for layername in manifest[0]['Layers']:
with tf.extractfile(layername) as layer_fp:
@benob
benob / server.nim
Created February 7, 2021 17:54
Nim server that checks client identity
import net
var
sslContext = newContext(certFile = "fullchain.pem", keyFile = "privkey.pem", verifyMode = CVerifyPeer)
socket = newSocket(domain = AF_INET6)
socket.setSockOpt(OptReuseAddr, true)
socket.setSockOpt(OptReusePort, false)
socket.bindAddr(Port(1965), "::")
socket.listen()
sslContext.wrapSocket(socket)
@benob
benob / ssl-client.nim
Created February 9, 2021 21:43
self-signed certificate verifying client in nim
import openssl
import ssl_config
from ssl_certs import scanSSLCertificates
import nativesockets
import uri
import os
import strutils
type Socket = ref object
fd: SocketHandle