Skip to content

Instantly share code, notes, and snippets.

@bingzhangdai
bingzhangdai / 9p_virtio.md
Created July 18, 2020 08:13
Set up VirtFS (9p virtio) for sharing files between Guest and Host on Proxmox VE

How-to

  1. On Host(PVE), edit /etc/pve/qemu-server/VMID.conf
args: -fsdev local,security_model=mapped,id=fsdev0,path=/path/to/share -device virtio-9p-pci,id=fs0,fsdev=fsdev0,mount_tag=hostshare

This tells qemu to create a 9pvirtio device exposing the mount_tag hostshare (just a name to identify the mount point). That device is coupled to an fsdev named fsdev0, which specifies which portion of the host filesystem we are sharing, and in which mode.

dataset_type = 'CocoDataset'
data_root = 'data/toyleaf/'
img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='LoadAnnotations', with_bbox=True, with_mask=True, with_seg=False),
dict(type='Resize', img_scale=(1333, 800), keep_ratio=True),
dict(type='RandomFlip', flip_ratio=0.5),
@nicknapoli82
nicknapoli82 / cs50_Tideman_cycle-explanation.md
Last active November 6, 2025 01:21
My attempt at clarifying how cycles work for the Tideman algorithm

A Way to Look at Tideman Lock Pairs

I've observed that there is a little bit of a disconnect in understanding what it is that needs to be done to properly implement the lock_pairs function for cs50 Tideman. The goal of this little write-up is simply an attempt at explaining what the problem actually is, and why a cycle imposes a problem.

First:
If you are unfamiliar with the actual problem, or have not read through the entire cs50 Tideman problem description. Then I think you should start there.
cs50 Tideman

Second:
This little write-up is only narrowing in on the idea of cycles, and a way to think about what a cycle is and determine if locking a pair in the pairs array would create that cycle. This does not talk about any other part of the Tideman problem.

@ajmassi
ajmassi / LXCBindMount.md
Last active October 12, 2025 17:57
Create a bind mount from a Proxmox host on an unprivileged lxc container

Proxmox Assign Bind Mount To Unprivileged Container

In order for the LXC container to have full access the proxmox host directory, a subgid is set as owner of a host directory, and an ACL is used to ensure permissions.

Bind Mount dataset to LXC

Add the following line to /etc/pve/lxc/<CT_ID>.conf

mp0:/mount/point/on/host,mp=/mount/point/on/lxc

Create group on host

In the default Proxmox configuration, unpriviliged container subgids will have the prefix "10" followed by the expected 4-digit gid.

@gurpal2000
gurpal2000 / Using VPS as an extension to home intranet.md
Last active October 29, 2025 19:35
Using VPS as an extension to home intranet

Using VPS as extension to home intranet v1

Using Wireguard show how VPS hardware can be used as an extension to your homelab. I am not interested in exposing services to the internet from the VPS. It is not intended to be a way for a user to VPN into the homelab from the internet.

  • Refer to the diagram at: https://i.imgur.com/n5elXC4.png
  • Server = a host inside your homelab (assume it is NOT a router already).
  • VPS = external cloud host.
  • Assume Ubuntu 18.04 LTS for all hosts involved.
  • Should be able to scale this easily. So if I had numerous VPSs, I could link them (mesh?)
  • I don't know much about OpenVPN, but that may be more suited to the goal. You tell me.
@ecnerwala
ecnerwala / download_prob.py
Last active November 5, 2025 08:58
ecnerwala's CP template system
#!/usr/bin/env python3
"""Download and setup problems from Competitive Companion
Usage:
download_prob.py --echo
download_prob.py [<name>... | -n <number> | -b <batches> | --timeout <timeout>] [--dryrun]
Options:
-h --help Show this screen.
--echo Just echo received responses and exit.
@bla-rs
bla-rs / gist:c439daa0aaa5dea899056bc0b7d34ead
Last active December 19, 2020 01:43 — forked from rgs/gist:7370406
A vim status line item to display git branch name and status of the currently edited file. To be put in the ~/.vimrc.
" returns a string <branch/XX> where XX corresponds to the git status
" (for example "<master/ M>")
function! CurrentGitStatus()
let gitoutput = systemlist('cd '.expand('%:p:h:S').' && git status --porcelain -b 2>/dev/null')
if len(gitoutput) > 0
let b:gitstatus = strpart(get(gitoutput,0,''),3) .'/'. strpart(get(gitoutput,1,' '),1,2)
else
let b:gitstatus = ''
endif
endfunc
@TheJLifeX
TheJLifeX / 00-hand-gesture-recognition.gif
Last active October 21, 2025 11:32
Simple Hand Gesture Recognition Code - Hand tracking - Mediapipe
00-hand-gesture-recognition.gif
@tzvsi
tzvsi / gist:222b3b22a847004a729744f89fe31255
Last active October 6, 2025 11:29
Installing CUDA 10.2, CuDNN 7.6.5, TensorRT 7.0, Ubuntu 18.04

Step 1: Installing CUDA (~5.5 minutes)

You can also install CUDA directly from the offline installer, but this is a little easier.

sudo apt update
sudo apt upgrade -y

mkdir install ; cd install
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
import torch
from collections import OrderedDict
from typing import List
checkpoints_weights_paths: List[str] = ... # sorted in descending order by score
model: torch.nn.Module = ...
def average_weights(state_dicts: List[dict]):
everage_dict = OrderedDict()