Skip to content

Instantly share code, notes, and snippets.


Roger Qiu CMCDragonkai

Block or report user

Report or block CMCDragonkai

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
CMCDragonkai /
Created Feb 18, 2020
Load Images and Numpy Arrays from Filesystem URLs and From Standard Input #python
import io
import sys
import fs
import contextlib
import urllib.parse
import numpy as np
from PIL import Image
from typing import Tuple, Iterator, IO, Optional, List
CMCDragonkai /
Created Jan 20, 2020
Building the NixOS netboot release.nix (from the nixpkgs source) #nix
#!/usr/bin/env sh
revCount="$(git rev-list --count HEAD)"bootstrap
shortRev="$(git rev-parse --short HEAD)"
nix-build nixos/release.nix \
--attr netboot.x86_64-linux \
--arg nixpkgs "{ outPath = ./.; revCount = $revCount; shortRev = \"$shortRev\"; }" \
-o netboot
CMCDragonkai / docker_containers_with_cacert_and_tzdata.nix
Created Jan 8, 2020
Docker Containers with CA certificates and timezone database built using Nix #cli #nix #docker
View docker_containers_with_cacert_and_tzdata.nix
# if you have networked applications that use the TLS or timezones
# you need to have these dependencies in the container
# note that these don't get put in the default.nix derivation
# because the package will use the OS provided cacert and tzdata
# but inside the container, they will need these 2 bundled explicitly
# or mounted...
# both cacert and tzdata has setup hooks
# this means when the container is built
# these pieces of data gets added into the container root filesystem
# at their standard locations
CMCDragonkai /
Last active Nov 20, 2019
Virtualizing Linux USB Host Controller Drivers for QEMU #linux #qemu

Virtualizing Linux USB Host Controller Drivers for QEMU

USB is a device-host protocol. So the host, which is likely your operating system requires a host controller interface (which is a piece of hardware).

The host controllers require drivers to run.

There are 3 kinds of USB host controller drivers:

  • ohci - Open Host Controller Interface - USB 1
CMCDragonkai /
Created Nov 11, 2019
QEMU-KVM boot a new x86-64 Virtual Machine from kernel and initrd #qemu
#!/usr/bin/env sh
# assume you have bzImage, initrd, cmdline, share, bootdisk, maindisk
# the below will boot a QEMU VM with 2 disks attached (as raw), with host port 55555 mapped to 22
# and also pass the share directory into the VM
qemu-system-x86_64 \
-kernel ./bzImage \
-initrd ./initrd \
-smp $(nproc) \
CMCDragonkai /
Last active Nov 6, 2019
Check if your machine is capable of virtualization (with QEMU & KVM) #linux

Check if your machine is capable of virtualization (with QEMU & KVM) without going into the BIOS

Run virt-host-validate which is the part of the libvirt package.

> virt-host-validate
  QEMU: Checking for hardware virtualization                                 : PASS
  QEMU: Checking if device /dev/kvm exists                                   : PASS
  QEMU: Checking if device /dev/kvm is accessible                            : PASS
  QEMU: Checking if device /dev/vhost-net exists                             : PASS
CMCDragonkai /
Last active Oct 25, 2019
Dask Ideas #python #dask

Dask Ideas

  • dd.Series is linearly partitioned into smaller pd.Series
  • dd.Series.apply and are the same and executes a function on each element
  • dd.Series.map_partition maps a function to partitions of the series
  • dd.Series.reduction chunks each partition, then aggregates each partition
  • pd.Series is backed by a Numpy array with additional metadata

Series Reduction

View vega_timeline.json
"$schema": "",
"width": 1000,
"height": 300,
"padding": 5,
"data": [
"name": "events",
"values": [
You can’t perform that action at this time.