Skip to content

Instantly share code, notes, and snippets.

View netj's full-sized avatar

Jaeho Shin netj

View GitHub Profile
@netj
netj / exshell
Last active September 21, 2018 14:23
#!/usr/bin/env bash
# exshell -- a handy way to use command-line formulae's output to augment a TAB-separated input
#
# Synopsis:
# $ cat a.txt
# USA United States of America
# India Republic of India
# South_Korea Republic of Korea (ROK)
#
# $ exshell <a.txt \
@netj
netj / remocon
Last active May 21, 2018 01:10
MOVED TO: https://github.com/netj/remocon since 2018-05
#!/usr/bin/env bash
# remocon -- run given command remotely, replicating local git work tree on a remote host, and downloading remote changes if needed
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2018-03-08
##
set -euo pipefail
error() { echo >&2 "📡 ‼️ " "$@"; false; }
warning() { echo >&2 "📡 ⚠️ " "$@"; }
# StackOverflow.bash
$ (s() { echo $1; [[ $1 -le 0 ]] || s $(($1 - 1)); }; time s 6977)
Segmentation fault (core dumped)
$ (s() { echo $1; [[ $1 -le 0 ]] || s $(($1 - 1)); }; time s 6976)
real 0m10.097s
user 0m10.064s
sys 0m0.032s
#!/usr/bin/perl -w
# ts2dur -- Annotates a timestamp-per-line input with the duration between two lines
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2017-02-17
##
use strict;
use POSIX qw(strftime);
use Date::Parse;
use Time::HiRes;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@netj
netj / bwtest.sh
Last active November 24, 2016 01:16
#!/usr/bin/env bash
# simple network I/O bandwidth test with ssh and pv
# Author: Jaeho Shin <netj@cs.stanford.edu>
# Created: circa 2013
host=${1:?ssh-able host name}; shift
maxbytes=${1:-$((2 ** 29))}; shift
bs=${1:-$((2 ** 16))}; shift
# rest are ssh options
set -- ssh -S none -o Compression=no -o ControlMaster=no "$@" $host
@netj
netj / scrollSelectionIntoView.js
Last active September 14, 2016 19:59 — forked from alisey/scrollSelectionIntoView.js
Scroll selection into view
// Scroll to selection focus, but only if it's out of view. Align selection
// focus with the top or bottom edge of its scroll-container. Return true
// on success.
// * there might be several nested scroll-containers, including window
// * must not try to scroll overflow:hidden and overflow:visible elements
// * no scrolling should happen if selection focus is visible
// * selection is not necessarily collapsed
// * range.getBoundingClientRect doesn't work for collapsed ranges
// * Opera reports incorrect startOffset and endOffset for collapsed ranges
// outside of text nodes (e.g. between 2 <br> elements), range.insertNode

Keybase proof

I hereby claim:

  • I am netj on github.
  • I am netj (https://keybase.io/netj) on keybase.
  • I have a public key whose fingerprint is 1111 1252 8C8F 4747 3140 1304 7860 1291 9E35 D477

To claim this, I am signing this object:

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
RUN adduser --disabled-password --gecos "" user \
&& adduser user adm \
&& bash -c "echo '%adm ALL=(ALL:ALL) NOPASSWD: ALL' | tee -a /etc/sudoers"
USER user
ENV USER=user