Skip to content

Instantly share code, notes, and snippets.

@shigenobuokamoto
shigenobuokamoto / network-mirrored.service
Last active May 18, 2024 20:39
/etc/systemd/system/network-mirrored.service
[Unit]
Wants=network-pre.target
Before=network-pre.target shutdown.target
[Service]
User=root
ExecStart=/bin/sh -ec '\
[ -x /usr/bin/wslinfo ] && [ "$(/usr/bin/wslinfo --networking-mode)" = "mirrored" ] || exit 0;\
echo "\
add chain ip nat WSLPREROUTING { type nat hook prerouting priority dstnat - 1; policy accept; };\
@jfrancos
jfrancos / docs-to-indexeddb.ts
Last active January 14, 2022 04:13
Turn an RxDB `bulkInsert` into an exported indexeddb.json file using Node.js
import 'fake-indexeddb/auto';
import { readFile, writeFile } from 'fs/promises';
import { exportToJsonString } from 'indexeddb-export-import';
import { getDatabase } from './Database';
const inFile = 'bulkInsertableData.json';
const outFile = 'indexeddb.json';
const collectionName = 'collection';
const prepIndexedDB = async () => {
@allenyllee
allenyllee / install_tools.sh
Last active May 17, 2024 21:21
mount vhdx in linux
#!/bin/bash
# install qemu utils
sudo apt install qemu-utils
# install nbd client
sudo apt install nbd-client
@Schnouki
Schnouki / middleware.py
Last active February 10, 2021 02:39
WhiteNoiseMiddleware that restrics access to sourcemaps to authorized users
import fnmatch
from django.conf import settings
from django.http import HttpResponseForbidden
from whitenoise.middleware import WhiteNoiseMiddleware
class AuthenticatedWhiteNoiseMiddleware(WhiteNoiseMiddleware):
def __init__(self, *args, **kwargs):
@ericremoreynolds
ericremoreynolds / bisect_key.py
Last active August 9, 2022 20:44
Key-like functionality recipe for Python's bisect functions
class KeyifyList(object):
def __init__(self, inner, key):
self.inner = inner
self.key = key
def __len__(self):
return len(self.inner)
def __getitem__(self, k):
return self.key(self.inner[k])