Skip to content

Instantly share code, notes, and snippets.

🚀
Lightspeed

Roger Qiu CMCDragonkai

🚀
Lightspeed
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
CMCDragonkai / linux_kernel_modules_nixos.md
Last active Oct 14, 2019
Linux Kernel Modules for NixOS #linux #nixos
View linux_kernel_modules_nixos.md

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
@CMCDragonkai
CMCDragonkai / react_lifecycle_hooks.js
Created Aug 26, 2019
React Lifecycle Hooks #js #react
View react_lifecycle_hooks.js
// all react lifecycle stages can be hooked into using the `useEffect` hooks
// acquired from here: https://stackoverflow.com/a/55041347/582917
useEffect( () => console.log("mount"), [] );
useEffect( () => console.log("will update data1"), [ data1 ] );
useEffect( () => console.log("will update any") );
useEffect( () => () => console.log("will update data1 or unmount"), [ data1 ] );
useEffect( () => () => console.log("unmount"), [] );
@CMCDragonkai
CMCDragonkai / dask_dump_csv.py
Last active Aug 22, 2019
Dump Dask Dataframe to Single CSV #python #dask
View dask_dump_csv.py
import os
import tempfile
import shutil
import pandas as pd
import dask.dataframe as df
from pathlib import Path
output_path = Path('tmp')
results = {
@CMCDragonkai
CMCDragonkai / map_reduce_dask_dataframe.py
Created Aug 6, 2019
Map Reduce with Dask Dataframes #dask
View map_reduce_dask_dataframe.py
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)
})
View gopro_linux_nixos.md

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 https://github.com/NixOS/nixpkgs/pull/65607

@CMCDragonkai
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
CMCDragonkai / ideas_in_http_restful_api.md
Last active Aug 20, 2019
Ideas in HTTP Restful API #http
View ideas_in_http_restful_api.md

Ideas in HTTP Restful API

Pagination

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
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
CMCDragonkai / journey_nix_package_repository.md
Last active Jun 22, 2019
Journey into Nix Package Repository #nix
View journey_nix_package_repository.md

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.

You can’t perform that action at this time.