Skip to content

Instantly share code, notes, and snippets.

View derrickturk's full-sized avatar
💭
(Come in under the shadow of this red rock)

Derrick Turk derrickturk

💭
(Come in under the shadow of this red rock)
View GitHub Profile
@derrickturk
derrickturk / zmapgrid.py
Last active April 22, 2024 16:06
Read ZMap+ grids to NumPy arrays + metadata
# Copyright (c) 2024 dwt | terminus, LLC
# 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:
# The above copyright notice and this permission notice shall be included in all
@derrickturk
derrickturk / numbers.cpp
Created February 6, 2024 22:53
X-macros
#include <cstdio>
const std::size_t num_buttons = 16;
const std::size_t total_buttons = num_buttons + 4;
#define FOR_EACH_NUMBER(n) "Button " #n,
const char* english[total_buttons] = {
#include "numbers.def"
"Hat Up",
"Hat Down",
@derrickturk
derrickturk / metaconcat.cpp
Last active February 6, 2024 22:40
In his house at R'lyeh, dead Cthulhu waits dreaming
#include <cstddef>
#include <cstdio>
#include <utility>
constexpr std::size_t num_digits(unsigned char n) noexcept
{
if (n < 10)
return 1;
if (n < 100)
return 2;
@derrickturk
derrickturk / geo151.py
Last active November 27, 2023 22:51
pyodbc converter for SQL Server POINT, MULTIPOINT, and LINESTRING (incl XYZM) geometries and geographies
# Copyright (c) 2023 dwt | terminus, LLC
# 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:
# The above copyright notice and this permission notice shall be included in all
@derrickturk
derrickturk / evaluator.js
Created May 25, 2023 17:38
Pyodide + NumPy in the browser demo
"use strict";
const input = [1.0, 2.0, 3.0, 4.0, 5.0];
const code = document.getElementById('code');
const output = document.getElementById('output');
let timeoutId;
async function init() {
let pyodide = await loadPyodide();
await pyodide.loadPackage('numpy');
@derrickturk
derrickturk / csvdump.awk
Created May 9, 2023 16:28
flimsy "CSV" dumper
BEGIN { FS = "," }
NR == 1 {
for (i = 0; i < NF; ++i)
hdr[i] = $i
}
NR > 1 {
for (i = 0; i < NF; ++i)
print "[" i - 1 "]: " hdr[i] " = " $i
@derrickturk
derrickturk / loudness_eq.ahk
Created May 4, 2023 15:32
toggle that stupid "Loudness Equaliization" setting you need to hear anything on Zoom calls
#Requires AutoHotkey v2.0
^+F12::
{
run "rundll32.exe shell32.dll Control_RunDLL mmsys.cpl"
WinWait "ahk_class #32770"
Send "{Down 2}"
Send "{Tab 2}{Enter}"
WinWait "ahk_class #32770"
Sleep 50
Send "^{Tab}^{Tab}"
@derrickturk
derrickturk / view_grid.py
Created May 2, 2023 19:42
View SMT Kingdom .GRD data (WIP)
# Copyright (c) 2023 Derrick W. Turk / terminus, LLC
# 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:
# The above copyright notice and this permission notice shall be included in all
@derrickturk
derrickturk / filey.rs
Created March 22, 2023 19:25
sometimes Python objects are "filey"
use std::{
io::{self, Read, Seek, SeekFrom, Write},
fs::File,
};
use pyo3::{
prelude::{Python, PyObject},
};
pub enum Filey {
@derrickturk
derrickturk / plot_petra.rs
Last active March 21, 2023 17:20
Using plotters and petra_grid to half-ass something
use std::{
env,
error::Error,
fs::File,
process::ExitCode,
};
use plotters::prelude::*;
use petra_grid::{Grid, GridData};