Skip to content

Instantly share code, notes, and snippets.

View haowen-xu's full-sized avatar

Haowen Xu haowen-xu

View GitHub Profile
@haowen-xu
haowen-xu / dowp.py
Created August 20, 2018 10:59
Import WordPress posts into DayOne
#!/usr/bin/env python
import subprocess
from xml.etree import ElementTree
tree = ElementTree.parse('wordpress.xml')
namespaces = {
'content': 'http://purl.org/rss/1.0/modules/content/',
'wp': 'http://wordpress.org/export/1.2/',
}
@haowen-xu
haowen-xu / random_k.py
Created April 9, 2019 08:28
Random k unique numbers
import random
def random_k(start, end, k):
seq = list(range(start, end))
if len(seq) < k:
raise ValueError('k too large.')
n = len(seq)
for i in range(0, min(k + 1, n - 1)):
#include <stdio.h>
#include <string.h>
const int MAX_HASH_COUNT = 1001;
const int MAX_FREE_NODES = 10000;
const int NOT_FOUND = -1;
struct Bucket {
int key;
int value;
def real_to_hex(x, k=16):
assert(0 <= x < 1)
s = ['0.']
for i in range(k):
y = int(x * 16)
s.append(hex(y)[2:])
x = x * 16 - y
return ''.join(s).rstrip('0')
#!/bin/bash
while [ "1" = "1" ]; do
"$@" && exit 0
sleep 1
done
import random
import click
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt
角色概率 = np.array(
[0.006] * 73 + # 1 ~ 73
from copy import copy
from collections import deque
"""
方向定义: 1 为正面,顺时针
3
2 4
1
@haowen-xu
haowen-xu / install-ubuntu-luks-lvm.md
Created March 31, 2024 06:13 — forked from superjamie/install-ubuntu-luks-lvm.md
How to install Ubuntu with LUKS Encryption on LVM

How to install Ubuntu with LUKS Encryption on LVM

My work requires us to have full-disk encryption, so these are the steps I use.

The basic idea is to create a LUKS-encrypted partition which is used as an LVM Physical Volume.

The GRUB boot partition isn't encrypted, but everything else is.

These steps tested and working on 22.04 (jammy) and 20.04 (focal).