Skip to content

Instantly share code, notes, and snippets.

@wojteklu
wojteklu / clean_code.md
Last active January 17, 2025 09:49
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@ruvnet
ruvnet / app.py
Last active January 17, 2025 09:46
This repository showcases a FastAPI application seamlessly orchestrating Gradio for crafting UIs, executing dynamic code, and managing interactive sessions. Experience the power of running code snippets, generating intuitive Gradio UIs from prompts, and handling session outputs with ease.
import os
import sys
import time
import re
import json
import logging
import lzstring
import httpx
import traceback
@mmozeiko
mmozeiko / !README.md
Last active January 17, 2025 09:42
Download MSVC compiler/linker & Windows SDK without installing full Visual Studio

This downloads standalone MSVC compiler, linker & other tools, also headers/libraries from Windows SDK into portable folder, without installing Visual Studio. Has bare minimum components - no UWP/Store/WindowsRT stuff, just files & tools for native desktop app development.

Run py.exe portable-msvc.py and it will download output into msvc folder. By default it will download latest available MSVC & Windows SDK - currently v14.40.33807 and v10.0.26100.0.

You can list available versions with py.exe portable-msvc.py --show-versions and then pass versions you want with --msvc-version and --sdk-version arguments.

To use cl.exe/link.exe first run setup_TARGET.bat - after that PATH/INCLUDE/LIB env variables will be updated to use all the tools as usual. You can also use clang-cl.exe with these includes & libraries.

To use clang-cl.exe without running setup.bat, pass extra /winsysroot msvc argument (msvc is folder name where output is stored).

@darccio
darccio / Makefile.toolexec
Last active January 17, 2025 09:37
Toolexec example
@PHONY: test
test:
$(eval TMP := $(shell mktemp -d))
go build -o $(TMP)/toolexec-example.run toolexec-example.go
go build -a -toolexec=$(TMP)/toolexec-example.run -o hello main.go
./hello && go clean
rm -rf $(TMP)
@Shpigford
Shpigford / permissions.sql
Created September 8, 2024 18:06
Digital Ocean Postgres Permissions
REVOKE ALL ON DATABASE demo_database FROM demo_user;
GRANT CONNECT ON DATABASE demo_database TO demo_user;
GRANT USAGE, CREATE ON SCHEMA public TO demo_user;
GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO demo_user;
GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO demo_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO demo_user;
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT USAGE ON SEQUENCES TO demo_user;
#include <stdio.h>
#include <windows.h>
#pragma comment(lib, "winmm.lib")
void Nothing(WORD wKey)
{
}
void PrintKey(WORD wKey)
@laytan
laytan / main.odin
Last active January 17, 2025 09:32
Raylib logging callback to Odin logger
logger: log.Logger
rl_log_buf: []byte
rl_log :: proc "c" (logLevel: rl.TraceLogLevel, text: cstring, args: libc.va_list) {
context = runtime.default_context()
context.logger = logger
level: log.Level
switch logLevel {
case .TRACE, .DEBUG: level = .Debug
case .ALL, .NONE, .INFO: level = .Info
@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active January 17, 2025 09:30
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized
@kashifulhaque
kashifulhaque / NvChad.md
Last active January 17, 2025 09:30
Neovim stuff with NvChad

Neovim keybinds

  • Capital letters do the opposite of small letters in command (Press shift to trigger capital letters)
  • _ (underscore) to move the cursor at the beginning of line (doesn't switch to insert mode)
    • 0 (zero) moves the cursor to the zeroth position of the line (doesn't switch to insert mode)
  • $ (dollar) to move the cursor at the end of line (doesn't switch to insert mode)
  • d$ will delete from wherever your cursor is till the end of the line
  • f<character> to move cursor to the first occurrence of <character>
    • f( to move cursor to first occurence of (
  • t<character> to move cursor to upto but not on the first occurrence of <character>
  • t( to move cursor to first occurence of (
@philschmid
philschmid / get_memory_size.py
Created January 16, 2025 13:53
Get needed GPU per precision for a Hugging Face Model Id
from typing import Dict, Union
from huggingface_hub import get_safetensors_metadata
import argparse
import sys
# Example:
# python get_gpu_memory.py Qwen/Qwen2.5-7B-Instruct
# Dictionary mapping dtype strings to their byte sizes
bytes_per_dtype: Dict[str, float] = {