Skip to content

Instantly share code, notes, and snippets.

View ax3l's full-sized avatar

Axel Huebl ax3l

View GitHub Profile
@jbn
jbn / pretty.py
Created May 13, 2018 15:11
Pretty Squares
def portray_neighborhood_offsets(C, origin, dist_func=None):
C = C.copy()
C[origin] = 2
fig, ax = plt.subplots(1, 1)
ax.imshow(C,
interpolation='nearest', # Not 'none'!
aspect='equal',
cmap=plt.cm.Purples)
@codingS3b
codingS3b / submitter_class.ipynb
Last active April 24, 2018 12:49
Prototype for a slurm submitter as a jupyter widget
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@likema
likema / glibc.cmake
Last active July 11, 2025 00:16
CMake macro to detect glibc version by filename.
# - Check glibc version
# CHECK_GLIBC_VERSION()
#
# Once done this will define
#
# GLIBC_VERSION - glibc version
#
MACRO (CHECK_GLIBC_VERSION)
EXECUTE_PROCESS (
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.so.6
@shafik
shafik / WhatIsStrictAliasingAndWhyDoWeCare.md
Last active July 10, 2025 19:24
What is Strict Aliasing and Why do we Care?

What is the Strict Aliasing Rule and Why do we care?

(OR Type Punning, Undefined Behavior and Alignment, Oh My!)

What is strict aliasing? First we will describe what is aliasing and then we can learn what being strict about it means.

In C and C++ aliasing has to do with what expression types we are allowed to access stored values through. In both C and C++ the standard specifies which expression types are allowed to alias which types. The compiler and optimizer are allowed to assume we follow the aliasing rules strictly, hence the term strict aliasing rule. If we attempt to access a value using a type not allowed it is classified as undefined behavior(UB). Once we have undefined behavior all bets are off, the results of our program are no longer reliable.

Unfortunately with strict aliasing violations, we will often obtain the results we expect, leaving the possibility the a future version of a compiler with a new optimization will break code we th

@cpascual
cpascual / gaussianfit.py
Created December 21, 2017 12:31
A simple example on fitting a gaussian
from __future__ import print_function
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def gauss(x, H, A, x0, sigma):
return H + A * np.exp(-(x - x0) ** 2 / (2 * sigma ** 2))
def gauss_fit(x, y):
@mbinna
mbinna / effective_modern_cmake.md
Last active July 6, 2025 12:55
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@jaraco
jaraco / Dockerfile
Last active December 7, 2017 15:11
Dockerfile reproducer for pypa/setuptools#1229
FROM ubuntu:xenial
# general environment for docker
ENV DEBIAN_FRONTEND=noninteractive \
FORCE_UNSAFE_CONFIGURE=1
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
bzip2 \
build-essential \
@sandsmark
sandsmark / api.txt
Last active January 10, 2023 05:47
reMarkable USB "restish" API
Enable in Settings -> Storage.
Listing documents (returns json blob): http://10.11.99.1/documents/
Listing documents in folder: http://10.11.99.1/documents/${folder_id}/
Getting thumbnail for last opened page: http://10.11.99.1/thumbnail/${document_id}
Upload/import (standard POST call, with 'file' parameter, accepts pdfs and epubs): http://10.11.99.1/upload/
Download (svg or zip with pngs): http://10.11.99.1/download/${document_id}/{pdf,png}
All other requests are served from /usr/share/remarkable/webui/
@ageis
ageis / YubiKey-GPG-SSH-guide.md
Last active June 25, 2025 15:14
Technical guide for using YubiKey series 4 for GPG and SSH

YubiKey 4 series GPG and SSH setup guide

Written for fairly adept technical users, preferably of Debian GNU/Linux, not for absolute beginners.

You'll probably be working with a single smartcard, so you'll want only one primary key (1. Sign & Certify) and two associated subkeys (2. Encrypt, 3. Authenticate). I've published a Bash function which automates this slightly special key generation process.

@kafene
kafene / gpg-wkd.md
Last active July 4, 2025 11:55
Setting up WKD for self-hosted automatic key discovery

I just got this working so I figured I'd share what I found, since there's hardly any information about this anywhere online except an RFC, the GPG mailing list and one tutorial from the GnuPG blog.

You can use automatic key discovery with WKD (Web key directory) to make it easy for users to import your key, in GPG since version 2.1.12. Since this feature is fairly new, it isn't yet available in the current LTS release of Ubuntu (16.04; xenial), however it is available in Debian stable (stretch).

I couldn't add a DNS CERT or DANE / OPENPGPKEY record through my email service (which also hosts my nameservers). I tried making the PKA record - a foo._pka.example.com TXT record but GPG doesn't seem to recognize it and fails; I'm still investigating why.

So the last option for self-hosted auto-discovery was WKD.

First thing I had to do was add an email address to my key. My primary UID is just my name so the key represents my identity rather