Skip to content

Instantly share code, notes, and snippets.

View datenwolf's full-sized avatar

datenwolf datenwolf

  • Lübeck, Germany, Europe, Earth, Star System "Sol", Milky Way, Virgo Cluster, Universe
View GitHub Profile
@datenwolf
datenwolf / gist:151486f6d73c9b25ac701bdbdef373a5
Last active July 23, 2023 14:20
Online RDTSC visualisation
#include <GL/glut.h>
#include <imgui.h>
#include <imgui_impl_glut.h>
#include <imgui_impl_opengl2.h>
#include <sched.h>
#include <math.h>
#include <stdio.h>
#include <x86intrin.h>
#include <time.h>
@datenwolf
datenwolf / ensure_fpu.py
Created September 7, 2022 09:46 — forked from moyix/ensure_fpu.py
Some handy utils for messing with MXCSR (x86-64 SSE FPU control register)
#!/usr/bin/env python
import sys, os
import platform
import ctypes as ct
import mmap
from enum import Enum
import importlib
import functools
import errno
@datenwolf
datenwolf / pidfdino.c
Created December 21, 2020 12:09
Create Linux pidfds for several processes and dump their inode numbers.
#define _GNU_SOURCE
#include <sys/fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <wait.h>
#include <stdio.h>
static int pidfd_open(pid_t pid, unsigned flags)
`timescale 1ns / 1ps
// iCEstick signals
//
// clk_12MHz: on board 12MHz crystal oscillator
//
// USB <-> RS232 converter has standard RS232 signals
// DCD, DSR, DTR, CTS, RTS, RXD, TXD
//
// /----------------------------------------
// / A7 A6 A5 A4 A3 A2 A1 A0 GND +3.3V |
# Copyright 2020 Jannis Harder
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
@datenwolf
datenwolf / b64op.c
Created April 3, 2018 18:06
Modified base64 variant that is order preserving
/*
Sorting order preserving base64 implementation.
Based on the original implementation of
picoweb / litheweb -- a web server and application framework
for resource constraint systems.
Copyright (C) 2012 - 2018 Wolfgang Draxinger
This program is free software; you can redistribute it and/or modify
@datenwolf
datenwolf / dxiw.bat
Created December 24, 2016 17:34
CPU affinity setting starting batch script for DX:IW
start /affinity 1 dx2.exe
#include "shaderloader.h"
#include <stdlib.h>
#include <stdio.h>
#if defined(_WIN32)
#include <windows.h>
#define shader_gl_proc(x) wglGetProcAddress(#x)
#elif defined(__APPLE__) && defined(__MACH__)
#define shader_gl_proc(x) ((void(*)())x)
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <sys/prctl.h>
@datenwolf
datenwolf / xscreensaver-lockall
Created May 12, 2015 13:36
Small Python script that locks all XScreenSaver instances running on a system – useful for suspend to … scripts
#!/usr/bin/python2
# vim: set fileencoding=utf-8 syntax=python tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab:
import os, os.path, psutil
def procenv(pid):
try:
env_fd = open(os.path.join('/proc', str(pid), 'environ'), 'r')
environ = env_fd.read()
env_fd.close()