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 /
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": [
CMCDragonkai /
Created Oct 21, 2019
Using ffmpeg for Timelapse with Crossfade #shell
#!/usr/bin/env sh
# change 0.1 to how long a frame should be shown
# change 0.05 to how long the crossfade should show
# change 2000x1500 to the width and height of the video
# change framerate to the output framerate (this doesn't change how fast the movie is)
# change -q:v 1 to quality (1 is the highest quality for mpeg4)
ffmpeg \
-pattern_type glob \
CMCDragonkai /
Last active Oct 14, 2019
Linux Kernel Modules for NixOS #linux #nixos

Linux Kernel Modules for NixOS

You can find what kernel modules are loaded using lsmod.

However some kernel modules are required at stage 1 boot. Basically preloaded in the initial ram disk before switching to the root filesystem. These kernel modules are mostly needed to deal with peripherals, storage devices, filesystems and network devices. You may need to be wary of these required modules:

  • sd_mod - SCSI, SATA, and PATA (IDE) devices
You can’t perform that action at this time.