Skip to content

Instantly share code, notes, and snippets.

View CypherpunkSamurai's full-sized avatar
😶
Currently Busy 🌻🐢

Cypherpunk Samurai CypherpunkSamurai

😶
Currently Busy 🌻🐢
View GitHub Profile
@CypherpunkSamurai
CypherpunkSamurai / OpenInSciHub.user.js
Created February 23, 2025 07:41 — forked from ifeelagood/OpenInSciHub.user.js
Open In Sci-Hub Userscript
// ==UserScript==
// @name Open In Sci-Hub
// @namespace Violentmonkey Scripts
// @match https://sciencedirect.com/*
// @match https://link.springer.com/article/*
// @match https://ieeexplore.ieee.org/document/*
// @match https://www.sciencedirect.com/science/article/*
// @match https://www.nature.com/articles/*
// @match https://journals.plos.org/plosone/article?id=*
// @match https://academic.oup.com/journals/*
@CypherpunkSamurai
CypherpunkSamurai / Run RabbitMQ on Windows with Docker.md
Last active February 20, 2025 15:46
Run RabbitMQ on Windows with Docker

Run RabbitMQ on Windows with Docker

# run rabbitmq on port 5672
# run rabbitmq-management on port 15672
docker run --name rabbitmq -d -p 5672:5672 -p 15672:15672 rabbitmq:4-management-alpine
# stop rabbitmq
docker ps -a --filter "name=rabbitmq" -q | ForEach-Object { docker stop $_ }
# remove rabbitmq container
# docker rm rabbitmq
@CypherpunkSamurai
CypherpunkSamurai / Run Redis on Windows Using Docker.md
Last active February 20, 2025 15:39
Run Redis on Windows using Docker

Run Redis on Windows using Docker

# docker rm redis if exists
docker rm -f redis redis-container redis-server
# docker run
docker run --name redis -d -p 6379:6379 redis:alpine

you can now connect to redis:

@CypherpunkSamurai
CypherpunkSamurai / Stockfish Chess Sanic REDIS.md
Last active February 20, 2025 04:36
Stockfish Chess Sanic REST

Stockfish Chess Sanic REDIS

# cache.py
import redis
from typing import Optional, Any, Dict
import json
import asyncio
from store import ChessStore
@CypherpunkSamurai
CypherpunkSamurai / FastAPI Uvicorn or Sanic or Async Await `_make_subprocess_transport` subprocess error when reload is enabled.md
Created February 20, 2025 03:39
FastAPI Uvicorn or Sanic or Async Await `_make_subprocess_transport` subprocess error when reload is enabled

FastAPI Uvicorn / Sanic / Async Await _make_subprocess_transport subprocess error when reload is enabled

There are two main reasons why reload was causing problems:

Event Loop Switching: When uvicorn runs with reload=True on Windows, it uses a different event loop implementation (SelectorEventLoop) for the file watcher. However, Windows requires ProactorEventLoop for subprocess support. This mismatch causes the NotImplementedError when trying to create subprocesses. Process Signal Handling: When uvicorn reloads on Windows, it sends a CTRL+C event to terminate the old process. However, on Windows, this signal can propagate to all child processes in the terminal session, including our Stockfish subprocess. This means every time the server reloads, it would accidentally kill the chess engine process. This is why disabling reload fixed the issue - it keeps us on a single ProactorEventLoop and avoids the problematic process signaling behavior.

For development, you have a few options:

@CypherpunkSamurai
CypherpunkSamurai / pygame_breaker.py
Created February 19, 2025 16:26
Pygame Breaker
import pygame
import sys
import random
import abc
import math
from typing import List, Tuple
# Initialize Pygame
pygame.init()
@CypherpunkSamurai
CypherpunkSamurai / # Go VSCode Tools Install in One Go.md
Created February 19, 2025 11:03
Go VSCode Tools Install in One Go

Go VSCode Tools Install in One Go

#  gocode
#  gopkgs
#  go-symbols
#  guru
#  gorename
#  gotests
# gomodifytags
@CypherpunkSamurai
CypherpunkSamurai / settings.json.diff
Created February 19, 2025 10:58
Change Default Git Branch for VSCode
{
+ // add this to ~/AppData/Roaming/VSCode/User/settings.json
+ // or open Command Palette and select "Open Settings (JSON)"
+ "git.defaultBranchName": "master"
}
@CypherpunkSamurai
CypherpunkSamurai / sign-all-git-commits.md
Last active February 19, 2025 10:54
Sign All Git Commits

Sign all Git Commits

Alias it

assign an alias


# git config --global alias.commit "commit -S"
[alias]
// read https://pieces.app/blog/vs-code-snippets-guide
// ctrl + space to enable snippet
{
"Insert Current Date": {
"prefix": "!date",
"body": [
"${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}"
],
"description": "Insert current date (YYYY-MM-DD)"
},