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 / binance-liquidation-calculator.py
Last active April 16, 2024 06:13
CLI Binance liquidation calculation formula
#!/usr/bin/env python3
'''2021-03-26: Reverse-engineer by searching for the following terms in features*.js:
- bracketMaintenanceMarginRate
- cumFastMaintenanceAmount
- bracketNotionalFloor
- bracketNotionalCap'''
# (max) position, maintenance margin, maintenance amount
maint_lookup_table = [
@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-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 / 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 / gen-consultancy-diary-xls.py
Last active June 13, 2023 17:39
Generates six months of consultancy diary rows
#!/usr/bin/env python3
from datetime import datetime
import pandas as pd
def prt(*args):
print('\t'.join(args), file=wf)
global line_no
line_no += 1
@highfestiva
highfestiva / bitmex-liquidation-calculator.py
Created October 26, 2019 20:54
cli bitmex liquidation calculation formula, minimal implementation
#!/usr/bin/env python3
import argparse
from math import ceil, floor
sign = lambda amt: -1 if amt<0 else (1 if amt>0 else 0)
class dobj:
@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 |