Skip to content

Instantly share code, notes, and snippets.

View thchr's full-sized avatar

Thomas Christensen thchr

View GitHub Profile
@thchr
thchr / gdb-trace-meep.log
Last active May 15, 2025 20:23
gdb trace for PythonCall meep segfault
$ gdb --args julia pythoncall1-debug.jl
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
@thchr
thchr / multiset-permutation-indices.jl
Created November 11, 2024 09:16
Multiset permutation indices
using Combinatorics
struct MultiSetPermutationIndices
f::Vector{Int}
end
Base.eltype(::Type{MultiSetPermutationIndices}) = Vector{Int}
Base.length(c::MultiSetPermutationIndices) = multinomial(c.f)
# copy of https://github.com/JuliaMath/Combinatorics.jl/pull/170, until merged & public
function _multinomial(k)
@thchr
thchr / gist:08af2a42aeca5fa175d4f7ccd9a37a5b
Created September 27, 2024 17:10
Floating point gcd
float_gcd(x,y; atol=1e-9) = (abs(y) < atol ? x : float_gcd(y, x % y; atol))
float_gcd(x, y, z...) = float_gcd(x, float_gcd(y, z...))
float_gcd(6, 4, 2.000000000001, 8.000000000001) 1.999999999999
@thchr
thchr / duality-check.jl
Created March 18, 2024 11:37
Verify that topological classification is invariant under duality transformations of symmetry eigenvalues
using BandGraphs
using Crystalline
using Test
using SymmetryBases
using LinearAlgebra
@eval Crystalline begin
struct SiteIrrep{D} <: AbstractIrrep{D}
cdml :: String
g :: SiteGroup{D}
@thchr
thchr / gist:4b273fe78dd833729bc0b946fbb6eecc
Created April 18, 2023 13:00
Profile.print(C=true) for using StaticArrays.jl
Overhead ╎ [+additional indent] Count File:Line; Function
=========================================================
1╎1 ...c2+0.x64.linux.gnu/bin/../lib/julia/libLLVM-14jl.so:?; _Z19write_unsigned_implIjEvRN4llvm11raw_ostreamET_mNS0_12IntegerStyleEb
╎2 ...up/julia-1.9.0-rc2+0.x64.linux.gnu/lib/julia/sys.so:?; jl_system_image_data
1╎ 1 ...ci5-5/julialang/julia-release-1-dot-9/src/subtype.c:1394; may_contain_union_decision
╎ 1 [unknown stackframe]
1╎ 1 ...i5-5/julialang/julia-release-1-dot-9/src/subtype.c:1394; may_contain_union_decision
╎271 ...cdir/glibc-2.12.2/csu/../sysdeps/x86_64/elf/start.S:113;
╎ 271 /lib/x86_64-linux-gnu/libc.so.6:?; __libc_start_main
╎ 271 ...-5/julialang/julia-release-1-dot-9/cli/loader_exe.c:59; main
@thchr
thchr / mapBackslash.ahk
Created January 17, 2022 22:17
AutoHotkey config
; We bind the same stuff also to RAlt+keys
<^>!z:: ; bind RAlt+z to \
SendRaw, \
Return
<^>!,:: ; bind RAlt+, to <
SendRaw, <
Return
<^>!.:: ; bind RAlt+. to >
@thchr
thchr / bench-minimal.scm
Last active July 16, 2020 14:37
Minimal reproducer for strange REPL/include behavior in Guile
; variables
(define uc-gvecs (list #(0 0 0) #(0 -1 -1) #(0 -1 1) #(-1 0 -1) #(-1 0 1) #(1 0 -1) #(1 0 1) #(0 1 -1) #(0 1 1) #(-1 -1 0) #(1 1 0) #(1 -1 0) #(-1 1 0) #(0 0 -2) #(0 0 2) #(0 -1 -2) #(0 -1 2) #(-1 0 -2) #(-1 0 2) #(1 0 -2) #(1 0 2) #(0 1 -2) #(0 1 2) #(0 -2 0) #(-2 0 0) #(2 0 0) #(0 2 0) #(-1 -1 -2) #(-1 -1 2) #(1 1 -2) #(1 1 2) #(1 -1 -2) #(1 -1 2) #(-1 1 -2) #(-1 1 2) #(0 -2 -1) #(0 -2 1) #(-2 0 -1) #(-2 0 1) #(2 0 -1) #(2 0 1) #(0 2 -1) #(0 2 1) #(0 -2 -2) #(0 -2 2) #(-2 0 -2) #(-2 0 2) #(2 0 -2) #(2 0 2) #(0 2 -2) #(0 2 2)))
(define uc-coefs (list 0.006509988713824982-0.07430991596602736i -0.14858501604673846+0.037798932181882614i 0.14858501604673843-0.03779893218188265i 0.1485850160467384-0.037798932181882586i -0.1485850160467385+0.0377989321818826i -0.1485850160467385+0.03779893218188263i 0.1485850160467385-0.03779893218188265i 0.14858501604673843-0.03779893218188259i -0.1485850160467385+0.03779893218188263i -0.05796045325126349+0.009834853427071608i -0.057960453251263505+0.00983485342707161
@thchr
thchr / vscode-default-keybindings.json
Created April 2, 2020 21:22
VSCode default keybindings (pruned of the "when" field)
[
{ "key": "escape escape", "command": "workbench.action.exitZenMode"},
{ "key": "shift+escape", "command": "closeReferenceSearch"},
{ "key": "escape", "command": "closeReferenceSearch"},
{ "key": "shift+escape", "command": "cancelSelection"},
{ "key": "escape", "command": "cancelSelection"},
{ "key": "ctrl+end", "command": "cursorBottom"},
{ "key": "ctrl+shift+end", "command": "cursorBottomSelect"},
{ "key": "ctrl+shift+alt+down", "command": "cursorColumnSelectDown"},
{ "key": "ctrl+shift+alt+left", "command": "cursorColumnSelectLeft"},