Skip to content

Instantly share code, notes, and snippets.

View aolo2's full-sized avatar

Алексей Олохтонов aolo2

View GitHub Profile
@aolo2
aolo2 / zoom.js
Last active January 17, 2024 10:48
zoom around the mouse
// What we want is the mouse position to stay the same relative to the zoomable object (it's a map in this example)
// To do that we solve the equation "oldMouseRelativePos = newMouseRelativePos" to find the value of newMapOffset.
// We know the values of oldZoom, newZoom, oldMapOffset and mousePos
//
// It is assumed that canvas->screen (something you would use in OpenGL, for example) transform is "(p - offset) / zoom",
// meaning screen->canvas (something you would use in Canvas2D) transform is "p / zoom - offset".
// mousePos is assumed to be in some kind of screen coordinates
// mapZoom is assumed to be zooming relative to the top left corner of the map
//
// "map relative mouse position" is:
@SMUsamaShah
SMUsamaShah / list_of_p2p_file_sharing.md
Last active June 17, 2025 18:11
List of P2P file sharing tools

Browser Based

  1. Web Wormhole https://webwormhole.io/ https://github.com/saljam/webwormhole
  2. ToffeeShare https://toffeeshare.com/
  3. FilePizza https://file.pizza/
  4. ShareDrop sharedrop.io https://github.com/szimek/sharedrop (SOLD, not recommended, use one of the forks)
    1. A clone SnapDrop snapdrop.net https://github.com/RobinLinus/snapdrop (SOLD, not recommended, use one of the forks)
      1. A fork PairDrop https://pairdrop.net/ https://github.com/schlagmichdoch/pairdrop
  5. Instant.io https://instant.io/
  6. FileTC https://file.tc/
@mauskin
mauskin / bare-drag-no-drop.js
Last active May 26, 2025 15:41
Minimal cross-browser drag with no drop function
// The most bare cross-browser drag with no drop function I could do.
// Example:
//
// make_draggable(
// thing,
// () => console.log("let’s go"),
// (event) => {
// console.log(event.clientX, event.clientY);
// element.style.transform = `translate(${event.clientX}px, ${event.clientY}px)`;
@mmozeiko
mmozeiko / pcg32.h
Last active May 18, 2025 01:47
simple standalone C headers for PCG random number generator
#pragma once
#include <stdint.h>
// pcg32_next() implementation matches pcg_engines::oneseq_xsh_rr_64_32
// NOTE: use this only for compatibility with 32-bit architectures
// otherwise prefer using pcg64.h implementation with 128-bit state
typedef struct {
@mmozeiko
mmozeiko / etw_createfile.c
Last active October 12, 2024 23:26
Monitor which files are accessed with ETW
// this code will work only when compiled as 64-bit code, and on Windows 10
// older Windows version might require different structure definitions
#define NOMINMAX
#define INITGUID
#include <windows.h>
#include <evntrace.h>
#include <evntcons.h>
#pragma comment (lib, "shell32.lib")
@rygorous
rygorous / magic_ring.cpp
Created July 22, 2012 03:55
The magic ring buffer.
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <string.h>
#include <Windows.h>
// This allocates a "magic ring buffer" that is mapped twice, with the two
// copies being contiguous in (virtual) memory. The advantage of this is
// that this allows any function that expects data to be contiguous in
// memory to read from (or write to) such a buffer. It also means that