Skip to content

Instantly share code, notes, and snippets.

View rhee's full-sized avatar

Sang-Hoon RHEE rhee

View GitHub Profile
@rhee
rhee / (bookmarklet) py-repl
Last active April 20, 2023 23:16
A bookmarklet to open python repl page using py-repl
data:text/html, <link rel="icon" type="image/png" href="https://pyscript.net/assets/images/favicon.ico"/> <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" /> <script defer src="https://pyscript.net/latest/pyscript.js"></script> <title>py-repl</title><body style="font-size:2rem;line-height:1.4;max-width:60rem;margin:2rem auto;padding:4rem;border:solid red 5px;border-radius:15px"> <py-repl auto-generate="true"> </py-repl> </body>
// ==UserScript==
// @name KeepFixedWidth
// @namespace http://tampermonkey.net/
// @version 0.1
// @description use fixed width for google keep
// @author You
// @match https://keep.google.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant none
// ==/UserScript==
@rhee
rhee / proc_stdout_gen.py
Created May 16, 2022 01:08 — forked from rhee-elten/proc_stdout_gen.py
## gen() function for proc.stdout ( run_commands, vdl_run ) ## async read from proc.stdout
## gen() function for proc.stdout ( run_commands, vdl_run )
## async read from proc.stdout
if True:
def gen(proc):
remains = b'' # remaining from prev read
while proc.poll() is None:
rlist, _, _ = select([proc.stdout],[],[],500)
if proc.stdout not in rlist:
continue
data = os.read(proc.stdout.fileno(), 16384)
"""
# https://gist.github.com/rhee/c038393822eabec681092b6941ef1f1e
# fake_ipython.py
Usage:
from fake_ipython import get_ipython
"""
from inspect import stack
def get_ipython():
#!/usr/bin/env python
# coding: utf-8
# // update: 2022-04-15 - single-cell python version
# // gist: https://gist.github.com/rhee/f42aa18c8e3dcb7b6c03c23e750124f7
with open('__nb-convert__.bash', 'w') as fout:
fout.write('''#!/bin/bash
try_nbconvert() {
local prefix="$1"; shift;
if test ! -z "$prefix"
then
## monitor GPU usage in jupyter notebook -- rhee.elten@gmail.com
## migrated to: https://gist.github.com/rhee-elten/1a1070e3a812ca863c3b937b5180b2f8
@rhee
rhee / tmux.md
Created February 6, 2022 22:48 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@rhee
rhee / manipulate_tf_pipeline_config.py
Created December 13, 2019 08:39
manipulate_tf_pipeline_config.py
# -*- coding: utf-8 -*-
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.3.0+dev
# kernelspec:
@rhee
rhee / detect-pypi-apt-proxy.sh
Created October 18, 2019 06:10
detect-pypi-apt-proxy.sh
$ cat detect-pypi-apt-proxy.sh
set -x
PYPI_PROXY_PORT=$1
APT_PROXY_PORT=$2
HOST_IP=$(awk '/^[a-z]+[0-9]+\t00000000/ { printf("%d.%d.%d.%d\n", "0x" substr($3, 7, 2), "0x" substr($3, 5, 2), "0x" substr($3, 3, 2), "0x" substr($3, 1, 2)) }' < /proc/net/route)
if test -z "$HOST_IP";then echo "HOST_IP not found" 1>&2; exit 1; fi
mkdir -p $HOME/.config/pip && cat > $HOME/.config/pip/pip.conf <<-EOL
[global]
index-url = http://$HOST_IP:$PYPI_PROXY_PORT/root/pypi/+simple/
[install]
@rhee
rhee / jupyter_hide_input_when_printing.js
Created October 16, 2019 15:34
jupyter_hide_input_when_printing.txt
%%javascript
(function() {
var node = document.createElement('style');
document.body.appendChild(node);
window.addStyleString = function(str) {
node.innerHTML = str;
}
}());
addStyleString(`
@media print