Skip to content

Instantly share code, notes, and snippets.

View stivio00's full-sized avatar
👾
Hey!

Stephen Krol stivio00

👾
Hey!
View GitHub Profile
@stivio00
stivio00 / db-dev.yml
Created May 12, 2026 17:33
fast dep temp
apiVersion: v1
kind: Secret
metadata:
name: postgres-dev-secret
type: Opaque
stringData:
POSTGRES_DB: my_dev_db
POSTGRES_USER: dev_user
POSTGRES_PASSWORD: dev_password
---
#!/usr/bin/env python3
import subprocess
import argparse
from pathlib import Path
PORT = 2376
def run(cmd: list, dry_run: bool):
if dry_run:
print(f" [dry-run] {' '.join(cmd)}")
@stivio00
stivio00 / docker_import.py
Created September 18, 2025 16:24
Docker context import script
from pathlib import Path
import subprocess
import click
import os
import sys
REQUIRED_FILES = ["cert.pem", "ca.pem", "key.pem"]
def get_user_data_dir(app_name: str) -> Path:
"""
@stivio00
stivio00 / ImageProcessingBenchmark.cs
Last active June 27, 2025 06:15
Image decoding and cropping benchmarks
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using ImageMagick;
using OpenCvSharp;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SkiaSharp;
namespace ImageProcessingBenchmark;
#!/usr/bin/env python3
"""
Usage: db-tool-py test.yaml
It will run each query with the correponding db and sql, if not provided it will use the global values
To install deps
$pip install pydantic pyyaml pandas typer sqlalchemy pyodbc jinja2
Simple case query the same db with two queries:
scan:
@stivio00
stivio00 / graph.js
Created May 19, 2022 21:41
bfs dfs in js
// adj list graph representation:
const g = {
1: [2,3],
2: [4,3],
3: [5],
4: [1],
5: []
};
@stivio00
stivio00 / nodeUtils.cs
Created March 8, 2022 21:59
C# GraphUtils
class AdjListStorage : Dictionary<uint, List<uint>> {
public static AdjListStorage Random(int nodes, float density = .5f){
AdjListStorage storage = new AdjListStorage();
List<uint> nodeIds = Enumerable.Range(0, nodes - 1).Select(Convert.ToUInt32).ToList();
Random random = new Random();
foreach(var nodeId in nodeIds) {
var edges = nodeIds.OrderBy(x => random.Next()).Take((int)(nodes*density)).ToList();
storage.Add(nodeId, edges);
@stivio00
stivio00 / LevenshteinExtension.cs
Last active February 9, 2022 21:59
LINQ method for Edit Operations (inser, delet subst) using Levenshtein algo.
//Levenshtein distance. ->. "HolA".EditDifferences("Hola").Count()
//Optimal edit operations ->. "HolA".EditDifferences("Hola").Reverse()
// returns the list of operations as a 2-tuple (op_string, item)
// where op_string is "+" for insert, "-" deletions and "~" substitution
public static IEnumerable<(string, TSource)> EditDifferences<TSource>(this IEnumerable<TSource> input, IEnumerable<TSource> old){
TSource[] s1 = input.ToArray(), s2 = old.ToArray(); //cache for random access
int[,] matrix = new int[s1.Count()+1, s2.Count()+1];
using System;
using System.Reflection;
using System.Data;
using System.Linq;
using System.Collections.Generic;
namespace DataTableTools
{
static class DataTableTools
{
@stivio00
stivio00 / f.m
Created September 20, 2011 03:11
Matlab stuff
function y = f(x,m)
% f esta funcion la funcion impulso rectangulo respresentado en sus serie
% de fourier y consta de M componentes, para llamar esta funcion f(x,m)
% donde x es el valor en la funcion y m el numero de componentes.
% Si quiere ver la funcion con sus cuatros componentes seria f(x,4)
% ejemplo, para graficar con 4 componentes:
% x = 0: .001 : 10;
% plot(x, f(x,4);
y = 0;
for i =1:m