Skip to content

Instantly share code, notes, and snippets.

View ax3l's full-sized avatar

Axel Huebl ax3l

View GitHub Profile
@jsomers
jsomers / websockets.md
Created September 27, 2018 12:50
Using websockets to easily build GUIs for Python programs

Using websockets to easily build GUIs for Python programs

I recently built a small agent-based model using Python and wanted to visualize the model in action. But as much as Python is an ideal tool for scientific computation (numpy, scipy, matplotlib), it's not as good for dynamic visualization (pygame?).

You know what's a very mature and flexible tool for drawing graphics? The DOM! For simple graphics you can use HTML and CSS; for more complicated stuff you can use Canvas, SVG, or WebGL. There are countless frameworks, libraries, and tutorials to help you draw exactly what you need. In my case, this was the animation I wanted:

high-priority

(Each row represents a "worker" in my model, and each rectangle represents a "task.")

@SimeonEhrig
SimeonEhrig / clingArgs.md
Last active November 13, 2019 08:39
Get arguments of a cling interpreter instance with reflection

To get the arguments of cling, which are passed on start, you can use the reflection feature of cling.

#include "cling/Interpreter/Interpreter.h"
#include "cling/Interpreter/InvocationOptions.h"

// gCling is an object of type cling::Interpreter
std::vector<const char*> remaining = gCling->getOptions().CompilerOpts.Remaining;
remaining
@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 November 5, 2025 05:09
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 November 4, 2025 12:56
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/