Skip to content

Instantly share code, notes, and snippets.

View CMCDragonkai's full-sized avatar
🚀
Lightspeed

CMCDragonkai

🚀
Lightspeed
View GitHub Profile
@CMCDragonkai
CMCDragonkai / aws_authenticate_docker_ecr.sh
Created July 1, 2021 03:37
AWS Authenticate Docker to ECR #aws #ecr #docker
#!/usr/bin/sh
aws ecr get-login-password --region ap-southeast-2 | docker login --username AWS --password-stdin <ENTERID>.dkr.ecr.ap-southeast-2.amazonaws.com
@CMCDragonkai
CMCDragonkai / cifar10_loading.py
Last active June 16, 2021 03:49
CIFAR10 Loading #python
import os
import pickle
import numpy as np
from pathlib import Path
from typing import List, Tuple
# expect CIFAR10 to point to a directory like
# .
# ├── batches.meta
# ├── data_batch_1
@CMCDragonkai
CMCDragonkai / lockpidfile.py
Last active January 19, 2022 15:20
Singleton Process with PID Lock File #python
import os
import fcntl
import contextlib
import time
@contextlib.contextmanager
def lockpidfile(filepath):
with os.fdopen(
os.open(filepath, os.O_RDWR | os.O_CREAT, mode=0o666),
@CMCDragonkai
CMCDragonkai / Duplex Async Generator.md
Last active April 5, 2021 06:27
Duplex Async Generator #javascript #typescript

Duplex Async Generator

This code demonstrates the how to combine a reading generator and a writing generator together into a duplex generator.

The duplex generator will simultaneously read and write at the same time from both the readable and writable generator.

Throwing an exception throws it to the writable generator, but we continue on (but make sure to skip 1 iteration by using the errored flag).

We use the null value to indicate the ending of the generator, it ends both reading and writing sides.

@CMCDragonkai
CMCDragonkai / understanding_systemd_boot_execution_graph.md
Last active October 5, 2021 14:56
Understanding systemd Boot Execution Graph #systemd
@CMCDragonkai
CMCDragonkai / npm_clean.md
Created March 16, 2021 09:44
NPM Clean - Needed if SHA1 hashes are appearing #npm

NPM Clean - Needed if SHA1 hashes are appearing

npm cache clear --force
rm -r node_modules/
rm package-lock.json
npm install
@CMCDragonkai
CMCDragonkai / edit_boot_command_line_with_systemd.md
Created March 13, 2021 05:48
Edit the Boot Command Line with systemd #linux #nixos #systemd

Edit the Boot Command Line with systemd

If you hit a boot error where there is a start job that cannot be terminated, you can enter the systemd debug shell.

To do this, at the systemd-boot menu, hit the e key and specify: systemd.debug-shell=1.

In the future you can do this in configuration.nix:

systemd.additionalUpstreamSystemUnits = [ "debug-shell.service" ];
@CMCDragonkai
CMCDragonkai / flexbox_sidebar_overflowing_grid_items.md
Last active January 8, 2024 16:48
Flexbox Sidebar with Overflowing Grid Items #css #flexbox #grid

Flexbox Sidebar with Overflowing Grid Items

Most flexbox layouts work by using the intrinsic sizing.

This means the sizes of boxes are determined by the size of the contents.

This is usually a good thing because you want your layout to stretch to the content, but also to the available space.

This makes layouts "flexible".

@CMCDragonkai
CMCDragonkai / async.js
Created February 4, 2021 09:07
Synchronous and Asynchronous Node.js Scripts #nodejs #javascript
#!/usr/bin/env node
import process from 'process';
async function main(argv = process.argv): Promise<number> {
process.exitCode = 0;
return process.exitCode;
}
if (require.main === module) {
@CMCDragonkai
CMCDragonkai / asyncio_multithreading_multiprocessing.py
Created January 21, 2021 03:54
Python AsyncIO with Multithreading and Multiprocessing #python
import time
import asyncio
import logging
import uvloop
import aiojobs.aiohttp
import sys
from aiohttp import web
import aioprocessing
import concurrent.futures