Skip to content

Instantly share code, notes, and snippets.

View OverShifted's full-sized avatar

Sepehr Kalanaki OverShifted

View GitHub Profile
@OverShifted
OverShifted / esp32_paint.ino
Created August 6, 2025 09:09
A simple ESP32 paint program with the option of changing color with a rotary encoder
#include <TFT_eSPI.h>
#include <SPI.h>
#define OUTPUT_BTN 13 // SW
#define OUTPUT_A 18 // CLK
#define OUTPUT_B 17 // DT
TFT_eSPI tft = TFT_eSPI();
float h = 0.0, s = 0.0, v = 1.0;
@OverShifted
OverShifted / profiler.rs
Last active January 18, 2022 14:42
Basic instrumentation profiler for Rust
// Based on https://gist.github.com/TheCherno/31f135eea6ee729ab5f26a6908eb3a5e
// Usage:
// 1. Call init before doing anything else with this file/snippet.
// 2. Put `let _timer = Timer::new()` at the begining of any scope you want to measure (DO NOT name the variable `_`. Because it will be dropped instantly after creation.)
// 3. Drag result.json into chrome://tracing (If you have a chromium-based browser) or https://ui.perfetto.dev for visualization
static mut TIMER: Option<std::time::Instant> = None;
static mut OUT_STREAM: String = String::new();
static mut NOT_FIRST: bool = false;
@OverShifted
OverShifted / $knn.py
Last active May 18, 2023 14:02
KNN algorithm in python
'''
Best KNN algorithm implementation world has ever seen
'''
import math
def EuclideanDistance(a, b): # N dimention Euclidean distance implementation
s = 0
for i in range(len(a)):
s += (a[i] - b[i]) ** 2
# return math.sqrt(s)
#include <filesystem>
#include <imgui.h>
#define BIT(x) (1 << x)
std::pair<bool, uint32_t> DirectoryTreeViewRecursive(const std::filesystem::path& path, uint32_t* count, int* selection_mask)
{
ImGuiTreeNodeFlags base_flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_OpenOnDoubleClick | ImGuiTreeNodeFlags_SpanAvailWidth | ImGuiTreeNodeFlags_SpanFullWidth;
bool any_node_clicked = false;