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 Aug 6, 2019
Map Reduce with Dask Dataframes #dask
import functools
import dask
import dask.dataframe as dd
import pandas as pd
pdf = pd.DataFrame({
'x': range(0, 100),
'y': range(0, 100),
'z': range(0, 100)

GoPro on Linux (NixOS)

The GoPro Hero 7 uses MTP for transferring files. To connect on NixOS you need to have MTP.

The best GUI tool for MTP is gmtp. Connect your GoPro and use gmtp to transfer files.

For more advanced interaction with GoPro devices, see

CMCDragonkai / random_range.js
Created Jul 19, 2019
Random Ranges in JS #javascript
View random_range.js
// by scaling the uniform distribution between [0,1) to [min,max)
function randomRangeInt (min, max) {
return min + Math.floor(Math.random() * (max - min));
CMCDragonkai /
Last active Jul 18, 2019
Ideas in HTTP Restful API #http

Ideas in HTTP Restful API


Pagination should always be using 2 parameters: seek and limit.

The seek is the offset into the collection.

The limit is how many to items to acquire.

CMCDragonkai / check_types.js
Created Jun 18, 2019
Checking Types in JavaScript #javascript
View check_types.js
// you often want to check if a value is truthy
function booleanise(v) {
return !!v;
booleanise(0) // false
booleanise('') // false (empty strings is falsey)
booleanise(false) // false
booleanise(null) // false
booleanise(undefined) // false
CMCDragonkai /
Last active Jun 22, 2019
Journey into Nix Package Repository #nix

Journey into Nix Package Repository

There are 2 commits that I need in my build:

  • 8d0e3ad603dda85462161bba1351893b84339462
  • 83e01aa5e48a9107f3b988c9d4c1c21d610626fb

Clone nixpkgs and add the nixpkgs-channels as a remote.


Nix Overrides

  • overrideDerivation is used to override the call to derivation
  • overrideAttrs is used to override the call to stdenv.mkDerivation
  • override is used to override the last function call. Often this will be the callPackage call.
  • overridePythonAttrs is used to override the call to buildPython*.

This PR discusses the idea to have a generic overrideArgs that works like overridePythonAttrs for all language infrastructures.

CMCDragonkai /
Last active Jun 22, 2019
Understanding Nix Inputs #nix

Understanding Nix Inputs

Every Nix derivation produces a Nix store output that has 3 things:

  • Executables
  • Libraries
  • Data

Executables are always exported using the PATH environment variable. This is pretty much automatic.

CMCDragonkai /
Created Apr 16, 2019
Decorators in Python #python
import functools
def prepost(func=None, *, prefix=''):
def prepost_(func):
def wrapper(*args, **kwargs):
print(f'{prefix} start')
result = func(*args, **kwargs)
print(f'{prefix} end')
return result
CMCDragonkai /
Last active Apr 15, 2019
Delete files/directories within a range of Unix timestamps #shell
#!/usr/bin/env sh
# basically we go into a directory
# we list all immediate files/directories
# then we filter it by a numeric (timestamp) range
# and then we perform a deletion on them
unixtime-gc () {
find "$1" \
-maxdepth 1 \
You can’t perform that action at this time.