Skip to content

Instantly share code, notes, and snippets.

razamatan /
Last active February 1, 2024 10:11
clean gentoo WSL2 setup with automounting encrypted home partition

mounting dmcrypted disks/partitions using openrc in wsl2

This assumes you can find and follow other directions elsewhere. github is silly w/ not allowing / in filenames, so i used \.

  1. install gentoo on wsl2 and make sure your starting openrc at wsl boot
  2. follow to get your disk setup. if you follow that, it's encrypting an entire drive, but you can do partitions or whatever disk setup you want for your linux setup. the key thing is that you need to pass the entire drive (--bare) to let linux
$ brew --config
HEAD: d0a2ed907ddb750c519bb9f56d7055490f968edf
HOMEBREW_PREFIX: /usr/local/homebrew
HOMEBREW_CELLAR: /usr/local/homebrew/Cellar
CPU: 8-core 64-bit ivybridge
OS X: 10.8.3-x86_64
Xcode: 4.6.1
razamatan /
Created March 10, 2011 01:26
simple conversion from etree parsed xml to objects
''' xml utilities '''
__author__ = ''
from itertools import groupby
from operator import attrgetter
def split_ns(txt):
''' returns [ns, tag] for '{ns}tag'
>>> split_ns('{}nil')
razamatan /
Created February 8, 2011 22:43
fix for ZSI 2.0 and python 2.6's ssl handling
# in class TimeoutHTTPS:
def connect(self):
sock = TimeoutSocket(self.timeout)
sock.connect((, self.port))
self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
razamatan / randomize iterator in python
Created December 10, 2010 10:10
randomize python iterator
from random import shuffle, randrange
def randomize(iterable, bufsize=1000):
''' generator that randomizes an iterable. space: O(bufsize). time: O(n). '''
buf = list()
for x in iterable:
if len(buf) == bufsize:
i = randrange(bufsize)
yield buf[i]
buf[i] = x