Skip to content

Instantly share code, notes, and snippets.

View devsamuelv's full-sized avatar
🌊
Bit surfing

Samuel Villegas devsamuelv

🌊
Bit surfing
View GitHub Profile
@0xdeadbad
0xdeadbad / 00-unity-sandbox-error-ubuntu24.04.md
Last active December 18, 2024 13:27
How to fix "No usable sandbox! Update your kernel... If you want to live dangerously and need an immediate workaround, you can try using --no-sandbox." Unity error on Ubuntu 24.04

New apparmor strict policies

The recent LTS release of Ubuntu introduced some more strict apparmor policies that are affecting many packages. To fix it is quite simple, add a file so apparmor don't deny Unityhub actions.

You can do it by yourself or use the script utility I wrote. For the script checkout Using the script

Commands to fix it manually

If you installed using the .deb distribution, your Unity Hub binary file is probably at /opt/unityhub/unityhub-bin, so you can just copy-paste the snippet to /etc/apparmor.d/unityhub

@ivan
ivan / asyncread poll_read footgun.md
Last active November 1, 2024 01:11
tokio::io::AsyncRead poll_read implementation footgun

The tokio::io::AsyncRead documentation confusingly states:

Poll::Ready(Ok(())) means that data was immediately read and placed into the output buffer. The amount of data read can be determined by the increase in the length of the slice returned by ReadBuf::filled. If the difference is 0, EOF has been reached.

https://docs.rs/tokio/latest/tokio/io/trait.AsyncRead.html

The footgun is that when poll_read is called, buf may already be partially filled. In some cases, this happens just a small fraction of the time in production, causing e.g. the last chunk of a file to be poll_read twice.

Setup code:

Yubikey GPG inside WSL2

  1. Install GPG4Win.
  2. Start up Kleopatra (a UI tool from 1) and make sure your YubiKey is loaded there.
    • You can also add GPG4Win to Startup folder using a link with this Target:
      "C:\Program Files (x86)\GnuPG\bin\gpg-connect-agent.exe" /bye
      
      This will only load the agent at Startup, and you won't be bothered by any UI or tray agent.
  3. Download wsl2-ssh-pageant into your Windows %userprofile%/.ssh directory (Windows dir is important for performance).
@ejs94
ejs94 / resize_apriltag.py
Last active October 19, 2022 16:26
I created this script to use python and the pillow lib to increase the size of apriltags, I believe it's easier to adapt than a postscript. You need to change the data in the variables area for desired family and tag, put this in root of the cloned apriltags-imgs repository.
# ======================================= IMPORTS ====================================#
'''
pip install Pillow
pip install numpy
'''
from PIL import Image, ImageDraw, ImageFont
import glob
import numpy as np
# ======================================= VARIABLES ====================================#

What are mixins?

Mixins are a way to inject code or change the minecraft source code directly and should be use with caution. If you can do a PR to Forge or use an event, try those first. If all else fails, then mixins may be a good option to look into. Here are some resources for mixins:

Now, I'll be honest, the official mixin doc is kind of terrible to learn from for most people. It's extremely dense and and really only helps people who already knows in-depth bytecode and stuff. But most modders aren't like that and just wants to do small stuff lol. But I'll give you the run-down here. There's a few kinds of mixins that you will encounter quite often.

@shawwn
shawwn / since2010.md
Created May 11, 2021 09:46
"What happened after 2010?"

This was a response to a Hacker News comment asking me what I've been up to since 2010. I'm posting it here since HN rejects it with "that comment is too long." I suppose that's fair, since this ended up being something of an autobiography.

--

What happened after 2010?

@byt3bl33d3r
byt3bl33d3r / websockets.cs
Created August 31, 2020 19:41
Async websocket C# client (producer/consumer pattern)
/*
Requires reference to System.Web.Extensions
*/
using System;
using System.Collections.Concurrent;
using System.Web.Script.Serialization;
using System.Text;
@sachithrrra
sachithrrra / vscode-font-stacks.css
Created August 12, 2020 14:08
VS Code CSS Font Stacks
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-family: Arial, Helvetica, sans-serif;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
font-family: 'Courier New', Courier, monospace;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
font-family: Georgia, 'Times New Roman', Times, serif;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', sans-serif;
font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
@nealfennimore
nealfennimore / wireguard.conf
Last active January 29, 2025 10:57
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@CMCDragonkai
CMCDragonkai / nix_inputs.md
Last active April 19, 2025 03:59
Understanding Nix Inputs #nix

Understanding Nix Inputs

Every Nix derivation produces a Nix store output that has 3 things:

  • Executables
  • Libraries
  • Data

Executables are always exported using the PATH environment variable. This is pretty much automatic.