Skip to content

Instantly share code, notes, and snippets.

View OverShifted's full-sized avatar

OverShifted

View GitHub Profile
#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;
@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)
@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;