Skip to content

Instantly share code, notes, and snippets.

View rindPHI's full-sized avatar

Dominic Steinhöfel rindPHI

View GitHub Profile
@rindPHI
rindPHI / LLVMParser.g4
Created August 24, 2018 12:42
ANTLR4 parser for LLVM IR (human readable ASM representation), parser part (lexer is separate)
// This ANTLR4 parser grammar is based on the parser part of an LLVM BNF grammar from
// https://gist.github.com/mewmew/a2487392d5519ef49658fd8f84d9eed5,
// which in turn has been based on the source code of the official LLVM project,
// as of 2018-02-19 (rev db070bbdacd303ae7da129f59beaf35024d94c53).
// * lib/AsmParser/LLParser.cpp
// === [ Module ] ==============================================================
// https://llvm.org/docs/LangRef.html#module-structure
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rindPHI
rindPHI / LLVMLexer.g4
Created August 24, 2018 12:41
ANTLR4 parser for LLVM IR (human readable ASM representation), lexer part
// This ANTLR4 lexer grammar is based on the lexer part of an LLVM BNF grammar from
// https://gist.github.com/mewmew/a2487392d5519ef49658fd8f84d9eed5,
// which in turn has been based on the source code of the official LLVM project,
// as of 2018-02-19 (rev db070bbdacd303ae7da129f59beaf35024d94c53).
lexer grammar LLVMLexer;
LT : '<' ;
EQSIGN : '=' ;
GT : '>' ;
@rindPHI
rindPHI / wordle-solver.py
Last active November 29, 2022 18:39
Wordle Solver Based on Z3
# MIT License
#
# Copyright (c) 2022 Dominic Steinhöfel
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@rindPHI
rindPHI / bibtool-umlauts.rsc
Created November 3, 2022 13:37
A bash script for reformatting BibTeX bibliographies in place using BibTool. Takes special care to don't break cross references and handle German umlauts correctly.
tex.define {\"[1]=#1e}
tex.define {\ss=ss}
tex.define {\AE=AE}
tex.define {\OE=OE}
tex.define {\aa=aa}
tex.define {\AA=AA}
tex.define {\o=o}
tex.define {\O=O}
tex.define {\l=l}
tex.define {\L=L}
@rindPHI
rindPHI / find_functions.py
Created June 7, 2022 09:35
Finding functions in Jupyter notebooks by matching names and signatures.
import inspect
import sys
import types
from typing import Dict
def global_functions() -> Dict[str, str]:
result = {}
module = sys.modules['__main__']
for key in dir(module):
@rindPHI
rindPHI / assignments.pl
Last active June 15, 2021 08:01
Prolog program for preference-based assignments (e.g., papers to students)
:- use_module(library(clpfd)).
:- use_module(library(aggregate)).
% How to use:
%
% - Add preference(student, paper_id, pref_value) facts for the preferences of all students
% (see end of file!)
% - student is any kind of value, e.g., strings or atoms
% - paper_id is a numeric identifier starting a 0
% - pref_value is a numeric value. Higher values indicate higher preferences
@rindPHI
rindPHI / inkscape2pdfs.py
Created November 29, 2020 11:28
Python script to convert an Inkscape SVG file with LaTeX Beamer-like layer names (e.g., "My layer [3,5-7,10-]") to a series of PDF files for use in, e.g., Beamer presentations, or as a step to create an animated gif.
#!/usr/bin/python3
import xml.etree.ElementTree as ET
import re
import sys
import os
import threading
from pathlib import Path
from subprocess import call
###########################################################################
@rindPHI
rindPHI / exportInkscapeLayers.py
Last active November 12, 2018 11:45
Python script which extracts PDFs from inkscape layers annotated by LaTeX overlay specifications, for the use in LaTeX beamer presentations. The attached SVG file is an example Inkscape SVG for seeing how it works.
#!/usr/bin/python3
import xml.etree.ElementTree as ET
import re
import sys
import os
import pyperclip
from pathlib import Path
from subprocess import call
###########################################################################
@rindPHI
rindPHI / firstorder.v
Last active September 27, 2018 16:52
An attempt to define the syntax and semantics of a predicate logic language, with a theorem on conservativity of structure extension. It's a failed attempt, therefore it contains "challenges". If somebody knows how to resolve them -- please let me know"
(*
Compile to PDF with
coqc firstorder.v ; coqdoc --latex --no-lib-name -s -p "\usepackage{parskip}\renewcommand{\thesection}{\arabic{section}}" firstorder.v ; pdflatex firstorder.tex
*)
Require Import Coq.Strings.String.
Require Import Coq.Vectors.VectorDef.
Require Import Coq.Relations.Relation_Definitions.
Module firstorder.