Skip to content

Instantly share code, notes, and snippets.

Avatar

Jaeho Shin netj

View GitHub Profile
View ⌨️=HHKB-BT.30s.sh
#!/usr/bin/env bash
#
# <bitbar.title>BluetoothConnector</bitbar.title>
# <bitbar.version>v1.0</bitbar.version>
# <bitbar.author>Jaeho Shin</bitbar.author>
# <bitbar.author.github>netj</bitbar.author.github>
# <bitbar.desc>Quick handle for showing whether a Bluetooth device is connected or not and quickly connecting/disconnecting it</bitbar.desc>
# <bitbar.image>http://icons.iconarchive.com/icons/bokehlicia/captiva/256/bluetooth-icon.png</bitbar.image>
# find bluetooth device name from filename
@netj
netj / Enby Code R.css
Created Mar 11, 2019
a Blink Shell Font
View Enby Code R.css
@font-face {
font-family: "Envy Code R";
font-style: normal;
font-weight: normal;
src: url(data:font/opentype;charset-utf-8;base64,T1RUTwALAIAAAwAwQ0ZGIEFt83wAABB4AAHV7UZGVE1cbC2QAAHwwAAAABxHREVGArsABAAB5mgAAAAgT1MvMuc/K8kAAAEgAAAAYGNtYXBAlmy5AAAIoAAAB7ZoZWFk/f3CSgAAALwAAAA2aGhlYQvHBLUAAAD0AAAAJGhtdHj133xSAAHmiAAACjhtYXhwAo5QAAAAARgAAAAGbmFtZcZfgEgAAAGAAAAHIHBvc3T/NgBnAAAQWAAAACAAAQAAAAAUOTjh3h1fDzz1AAsIAAAAAADNQbHgAAAAAM1BseD/xP1OBJgIBgAAAAgAAgAAAAAAAAABAAAHaP4mAAAETP/E/7QEmAABAAAAAAAAAAAAAAAAAAACjgAAUAACjgAAAAMETAGQAAUAAADNAM0AAAEfAM0AzQAAAR8AZgIACAQCAAUJAAAAAgAEoAAAr0AAePsAAAAAAAAAAEVOVlkAQAAg+wYFjv4mAAAHaAHaIAAAk83UAAAEUgWOACAAIAABAAAAHgFuAAEAAAAAAAAASgCWAAEAAAAAAAEAGQEVAAEAAAAAAAIABwE/AAEAAAAAAAMAKgGdAAEAAAAAAAQAGQH8AAEAAAAAAAUADQIyAAEAAAAAAAYAFQJsAAEAAAAAAAcAOAL0AAEAAAAAAAgAGQNhAAEAAAAAAAkADAOVAAEAAAAAAAoASgQ4AAEAAAAAAAsAGQS3AAEAAAAAAAwAFgT/AAEAAAAAABAAGQVKAAEAAAAAABIAGQWYAAMAAQQJAAAAlAAAAAMAAQQJAAEAMgDhAAMAAQQJAAIADgEvAAMAAQQJAAMAVAFHAAMAAQQJAAQAMgHIAAMAAQQJAAUAGgIWAAMAAQQJAAYAKgJAAAMAAQQJAAcAcAKCAAMAA
View rename-audio-files.sh
#!/usr/bin/env bash
# rename-audio-files.sh -- prints a shell script to rename .m4a, .mp3 files according to its tags
#
# Why/where would anyone use this:
# My car's USB audio (iDrive) works much better if the files are named with their metadata than the terse names (track-title) given by iTunes.
#
# Author: Jaeho Shin <netj@sparcs.org>
# Created: 2019-03-10
set -euo pipefail
View exshell
#!/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 \
View remocon
#!/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 "📡 ⚠️ " "$@"; }
View gist:08ec7f560222e4650d733c69b3b04407
# 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
View ts2dur.pl
#!/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;
View restoring_variable_ids_benchmark.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View bwtest.sh
#!/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 Sep 14, 2016 — forked from alisey/scrollSelectionIntoView.js
Scroll selection into view
View scrollSelectionIntoView.js
// 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
You can’t perform that action at this time.