Skip to content

Instantly share code, notes, and snippets.

View leonid-shevtsov's full-sized avatar
🇺🇦
Help Ukraine Win

Leonid Shevtsov leonid-shevtsov

🇺🇦
Help Ukraine Win
View GitHub Profile
// adapted from https://gitlab.com/manzhara157/nanobelts/-/blob/main/example.pas
package main
import (
"bufio"
"fmt"
"math"
"os"
"strconv"
# translated from https://gitlab.com/manzhara157/nanobelts/-/blob/main/example.pas
import math
import os
import numpy
from contextlib import suppress
def clean_files():
with suppress(FileNotFoundError):
# translated from https://gitlab.com/manzhara157/nanobelts/-/blob/main/example.pas
import array
import math
import random
import os
from contextlib import suppress
n0 = 200000
The goal: swap White and Black knights:
+-+
A |W|
+-+-+
B | | |
+-+-+-+
C | |W| |
+-+-+-+-+
D |B| |B| |
max_precise = 10 ** Float::DIG
last_best = 10
2.upto(256) do |base|
total = base
bits = 0
power2 = 1
chars = 1
require 'json'
canvas = JSON.parse(STDIN.read, symbolize_names: true)
all_ids = canvas[:nodes].map { |n| n[:id] }
dest_ids = canvas[:edges].map {|e| e[:toNode] }.uniq
root_ids = all_ids - dest_ids
nodes_by_id = canvas[:nodes].to_h {|n| [n[:id],n] }
graph = canvas[:edges].group_by {|e| e[:fromNode] }.transform_values { |vv| vv.map {|v| v[:toNode] }}
@leonid-shevtsov
leonid-shevtsov / README.md
Created June 20, 2024 08:44
Mindmap helpers for Obsidian Canvas Style Menu
  1. Install https://github.com/michaellw/Obsidian-Canvas-Style-Menu into your vault
  2. Copy mindmap_helpers.json to vault/.obsidian/plugins/canvas-style-menu/packages/mindmap_helpers.json
  3. Copy mindmap_helpers.css to `vault/.obsidian/snippets
  4. Enable "Mindmap Helpers" in Canvas Style Menu settings
  5. Enable snippets in Appearance settings
@leonid-shevtsov
leonid-shevtsov / chromium_pickle.imhex
Created June 13, 2024 08:39
ImHex protocol description for Chromium Pickle data
struct PickleString {
u32 length;
char16 chars[length];
char16 zeroChar;
};
struct PickleEntry {
PickleString key;
PickleString value;
};
@leonid-shevtsov
leonid-shevtsov / lines_to_canvas.rb
Created June 13, 2024 07:20
Convert a list of lines into Obsidian Canvas
# ruby lines_to_canvas.rb <items.txt >items.canvas
require 'random/formatter'
require 'json'
nodegap = 10
nodewidth = 300
nodeheight = 60
list = STDIN.readlines
package main
import (
"fmt"
"runtime"
)
func main() {
var stats runtime.MemStats