Skip to content

Instantly share code, notes, and snippets.

View highfestiva's full-sized avatar

highfestiva highfestiva

View GitHub Profile
@highfestiva
highfestiva / duck_mesh.py
Created May 3, 2024 14:37
Classic 3D demo duck mesh
vertices = [
( 0.23, -1.339, -0.626, ),
( 0.32, -1.346, -0.503, ),
( 0.38, -1.353, -0.334, ),
( 0.402, -1.358, -0.142, ),
( 0.384, -1.36, 0.053, ),
( 0.328, -1.359, 0.225, ),
( 0.24, -1.357, 0.354, ),
( 0.131, -1.355, 0.425, ),
( 0.12, -1.336, -0.69, ),
@highfestiva
highfestiva / git_log_quantity_per_person.py
Created December 8, 2023 14:57
Measures quantity of git changes, both summarized and over time
#!/usr/bin/env python
import pandas as pd
import sys
goodext = ('java')
removalfactor = 2.0 # Paraphrasing Tolstoy: "nothing can improve a piece of software as much as code removal".
commitfactor = 0.1 # A commit is only as good as it's content.
@highfestiva
highfestiva / regexpReplaceFiles.py
Last active November 3, 2023 15:44
Replace file contents while traversing all subdirectories
#!/bin/env python
def printUsage():
import sys
print("%s <regexp-search> <regexp-replace> <wildcard>" % sys.argv[0])
print("Example: %s \"<td>[0-9]*</td>\\r\\n\" 0 *.html" % sys.argv[0])
def doreplace(r, search, replace):
@highfestiva
highfestiva / renameFiles.py
Last active November 3, 2023 15:08
Recursively rename multiple files
#!/usr/bin/env python3
import glob
import os
import re
import sys
def printUsage():
print("%s <wildcard> <replacement wildcard>" % sys.argv[0])
@highfestiva
highfestiva / mandelbrot-vectorized.zig
Last active July 12, 2023 16:49
Vectorized monochrome mandelbrot in Zig 0.11.0-dev.3913+116a99d3c
const std = @import("std");
const ArrayList = std.ArrayList;
const VEC_SIZE = 8;
const Vec = @Vector(VEC_SIZE, f64);
const global_allocator = std.heap.c_allocator;
pub fn main() !void {
const n = try get_n();
@highfestiva
highfestiva / mandelbrot-simple.zig
Last active July 12, 2023 16:49
Straightforward mandelbrot implementation in Zig 0.11.0-dev.3913+116a99d3c
const std = @import("std");
const print = std.debug.print;
fn mandelbrot(cReal: f64, cImag: f64, maxIter: u32) u32 {
var zReal: f64 = 0.0;
var zImag: f64 = 0.0;
var n: u32 = 0;
while (n < maxIter and zReal * zReal + zImag * zImag < 4.0) : (n += 1) {
var nextZReal: f64 = zReal * zReal - zImag * zImag + cReal;
@highfestiva
highfestiva / sudoku-solver.py
Created March 27, 2023 15:41
Just another sudoku solver
#!/usr/bin/env python3
import pandas as pd
puzzle = '''
+-----+-----+-----+
|5 | 8 | 4 9|
| |5 | 3 |
@highfestiva
highfestiva / haversine.py
Last active December 9, 2022 14:45
Calculate meters between two geo-coords
from math import *
class Coord:
def __init__(self, x, y=None):
if y is None:
self.lat = x[1]
self.lng = x[0]
else:
self.lat = x
@highfestiva
highfestiva / pctOutage.flux
Created September 21, 2022 07:48
InfluxDB comparison between 1w and 2w back for outage monitoring
import "experimental"
import "math"
import "system"
/* Compares a value with 1w and 2w back. If the percentage diff is large
(positive or negative), it means that we have some outage or other anomaly. */
subQuery = (start, stop, myField, label, timeShiftDuration) =>
from(bucket: "my-bucket")
@highfestiva
highfestiva / automap.py
Last active October 24, 2022 14:48
Streamlit parsing and plotting of geo-coordinates
'''
# AutoMap
A tool for plotting pretty much anything with geo-coordinates in it.
First install Python3 and Streamlit (https://docs.streamlit.io/). Start script by running
```bash
streamlit run automap.py
```