Skip to content

Instantly share code, notes, and snippets.

View tarkin000's full-sized avatar

Steve M. tarkin000

  • US (MI)
View GitHub Profile
@tarkin000
tarkin000 / simple_ev_loop.py
Created December 11, 2019 11:47
An example for a friend, demonstrating a simplified event loop
#!/usr/bin/python3
import time
import sys
import tty
import termios
from select import select
from evdev import InputDevice, categorize, ecodes
# wrangle an input value from your (input) widget here
@tarkin000
tarkin000 / jeaux_deaux.c
Created July 1, 2019 03:43
Tiny C Compiler compilation-on-demand with dynamic memory management
/* gcc -o jd jeaux_deuax.c -ldl -ltcc
A simple demonstration of TCC's ability to tell you how much memory a function will need,
so that one may pre-allocate the memory for it.
Here, I use a function (compile) that completely manages the compilation of a single string of text,
creating & destroying the TCCState as needed, and using malloc to allocate memory which needs to be
free'd by the user.
Other schemes can be arranged, of course- the magic is in the sequence:
tcc_compile_string(tcc,<string>);
@tarkin000
tarkin000 / libvncd_mingw32.mk
Created December 6, 2018 17:57
GNU Makefile for libvncd
#CXX=x86_64-w64-mingw32-g++-posix
CXX=i686-w64-mingw32-g++-win32
## (some) Windows MinGW/MSys installations have un- pre/suff -ixed compilers
#CXX=g++
# vcxproj preprocessor defines list WIN32;MINIZ_NO_ARCHIVE_APIS;_DEBUG;_CONSOLE;_LIB
CXXFLAGS=-mwindows -std=c++11 -g3 -Og -DUNICODE -DWIN32 -DMINIZ_NO_ARCHIVE_APIS -D_DEBUG -D_CONSOLE -I. -I asio
CFLAGS=-mwindows -g3 -Og -DUNICODE -DWIN32 -DMINIZ_NO_ARCHIVE_APIS -D_DEBUG -D_CONSOLE -I. -I asio
LDFLAGS=-Wl,--subsystem,console
## VS linker command lists the following libraries: KERNEL32.LIB USER32.LIB GDI32.LIB WINSPOOL.LIB COMDLG32.LIB ADVAPI32.LIB SHELL32.LIB OLE32.LIB OLEAUT32.LIB UUID.LIB ODBC32.LIB ODBCCP32.LIB
## MinGW won't link unless wsock32 and ws2_32 are specified
@tarkin000
tarkin000 / linux.shn
Created January 20, 2018 15:24
Fix for _x*stat callls on Linux in Shine (richardhundt/shine)
-- lib/sys/ffi/linux.shn
local ffi = require("ffi")
require "sys.ffi.posix"
ffi::cdef"""
static const int PATH_MAX = 4096;
/* types */
typedef unsigned long ino_t;
typedef unsigned long nlink_t;
@tarkin000
tarkin000 / rsa.lua.patch
Last active November 13, 2017 23:55
Patch to add PKCS#8 key generation to lua-resty-rsa
--- rsa.lua.oem 2017-11-13 01:02:14.272018211 -0500
+++ rsa.lua 2017-11-13 18:54:02.587237476 -0500
@@ -29,13 +29,18 @@
PKCS8 = "PKCS#8",
}
+--[[ tarkin000: MOD added -
+ int PEM_write_bio_RSA_PUBKEY(BIO *bp, RSA *x);
+ int PEM_write_bio_PKCS8PrivateKey(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, char *kstr, int klen, pem_password_cb *cb, void *u);
+ int EVP_PKEY_set1_RSA(EVP_PKEY *e, RSA *r);
@tarkin000
tarkin000 / civetweb_ssl_verify_mod_sgm.patch
Created April 16, 2017 23:14
Civetweb SSL_VERIFY_FAIL_IF_NO_PEER_CERT modification patch
--- civetweb.c 2017-04-16 19:02:51.880184872 -0400
+++ civetweb.c 2017-04-16 19:04:59.816181147 -0400
@@ -1746,6 +1746,7 @@ enum {
KEEP_ALIVE_TIMEOUT,
LINGER_TIMEOUT,
SSL_DO_VERIFY_PEER,
+ SSL_FAIL_IF_NO_PEER_CERT,
SSL_CA_PATH,
SSL_CA_FILE,
SSL_VERIFY_DEPTH,
@tarkin000
tarkin000 / noleak.c
Created February 14, 2017 07:06
A demonstration of the Sparkling API that doesn't leak 24 bytes
#include <stdio.h>
#include <spn/spn.h>
int main(int argc, char *argv[]) {
SpnParser parser;
SpnCompiler *compiler;
SpnHashMap *ast;
SpnFunction *fn;
SpnVMachine *vm;
SpnValue rv;
#if defined(_WIN32) || defined(_WIN64)
#include <malloc.h>
#define alloca _alloca
#define popen _popen
#define pclose _pclose
#define DIRCMD "dir /B "
#define SEP "\\"
#else
#include <alloca.h>
#define DIRCMD "ls -f -1 "
# This is a hex representation of a request/response exchange
# over a tcp stream
# It is a client computer (win32 COM/ActiveX control in IE)
# logging into a DVR (SHR-1041k)
# the password has been sanitized with Xs
00000000 01 01 00 00 ....
00000000 02 00 00 08 ....
00000004 21 a6 13 09 17 00 00 00 !.......
00000004 01 20 00 40 . .@
00000008 41 44 4d 49 4e 00 00 00 cc ed d8 11 04 00 00 00 ADMIN... ........
@tarkin000
tarkin000 / nginx_hyperfastcgi_dump.txt
Created December 4, 2016 09:27
Logs from Nginx and HyperFastCgi
nginx error.log:
2016/12/03 23:16:57 [debug] 11395#11395: bind() 0.0.0.0:80 #6
2016/12/03 23:16:57 [notice] 11395#11395: using the "epoll" event method
2016/12/03 23:16:57 [debug] 11395#11395: counter: 00007F2CB3A1C080, 1
2016/12/03 23:16:57 [notice] 11395#11395: nginx/1.10.2
2016/12/03 23:16:57 [notice] 11395#11395: OS: Linux 3.2.0-4-amd64
2016/12/03 23:16:57 [notice] 11395#11395: getrlimit(RLIMIT_NOFILE): 1024:4096
2016/12/03 23:16:57 [debug] 11396#11396: write: 7, 00007FFD155463F0, 6, 0
2016/12/03 23:16:57 [debug] 11396#11396: setproctitle: "nginx: master process /usr/sbin/nginx"
2016/12/03 23:16:57 [notice] 11396#11396: start worker processes