Skip to content

Instantly share code, notes, and snippets.

@mvolfik
mvolfik / svelte_store.rs
Created March 12, 2022 23:19
Svelte store contract implemented in Rust using wasm-bindgen. No reason to use to use this on its own, but if you have a larger wasm project, this is handy to use to automatically propagate state changes to the presentation layer
use std::{cell::RefCell, collections::HashMap, rc::Rc};
use js_sys::{Array, Function};
use wasm_bindgen::{
prelude::{wasm_bindgen, Closure},
JsCast, JsValue,
};
#[wasm_bindgen]
pub struct Writable {
@nealfennimore
nealfennimore / wireguard.conf
Last active May 25, 2024 16:43
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
@cipharius
cipharius / sort-selections.kak
Last active April 18, 2024 14:39
Sort kakoune selections using GNU sort utility
define-command sort-selections -params 0.. -override -docstring '
sort-selections: Sort current selections using GNU sort utility
All parameters will be passed to the GNU sort utility
' %{
# Copy current selections to a temporary sort buffer
execute-keys %{"sy}
edit -scratch *sort-selections*
execute-keys %{"s<a-p>}
# Seperate selections with null characters
@soshial
soshial / outline_pdf2djvu.py
Last active April 30, 2022 17:35
Converting PDF table of contents into DjVu outline
import xml.etree.ElementTree
import djvu.decode as djvu
import sys
__author__ = 'soshial'
'''
1. export bookmarks from PDF using pdfminer:
> python tools/dumppdf.py -T ~/book.pdf > ~/toc_pdf.xml
2. use current script to convert bookmarks (we need python-djvulibre), but it could be easily done without it (using pages, see http://www.ub-filosofie.ro/~solcan/wt/gnu/d/bdjv.html)
@vprtwn
vprtwn / README.md
Last active June 30, 2022 14:33
Force Directed Graph Editor

Drag from an existing node to add a new node or link. Hit the DELETE key to remove the selected node or link.

Built with D3.js.