Skip to content

Instantly share code, notes, and snippets.

View kkew3's full-sized avatar

Kaiwen kkew3

View GitHub Profile
@kkew3
kkew3 / node-and-npm-in-30-seconds.sh
Last active September 21, 2018 22:07 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo. The first two scripts work for me.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@kkew3
kkew3 / hull_plot.py
Last active February 5, 2023 21:27 — forked from nicoguaro/hull_plot.py
Plot the convex hull around a set of points as a shaded polygon.
# -*- coding: utf-8 -*-
"""
Plot the convex hull around a set of points as a
shaded polygon.
@author: Nicolas Guarin Zapata and Kaiwen
@date: February 6, 2023
"""
import numpy as np
from scipy.spatial import ConvexHull
@kkew3
kkew3 / sum_filesize.sh
Last active February 17, 2023 17:27 — forked from fsteffenhagen/sum_filesize.sh
sum human readable file sizes from `du` with `numfmt` and `perl`
# Require: [`fd`](https://github.com/sharkdp/fd.git)
PATTERN='XXX' # Assume this would be a directory
fd -0 -td "$PATTERN" \
| xargs -0 du -sh \
| numfmt --from=auto --to=none \
| perl -ane 'BEGIN { my $sum = 0; } $sum += $F[0]; print; END { print $sum, " totoal\n"; }' \
| numfmt --from=none --to=si