Skip to content

Instantly share code, notes, and snippets.

Source Simian sourcesimian

Block or report user

Report or block sourcesimian

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

sshx - Run a Local Script over SSH with Interactivity

Sometimes you want to run a bit more than just one command over ssh, and you also want to maintain interactivity to the processes that you launch. Usually you could just do ssh -t <host> "foo; bar; fish; paste" however that can quickly become unwieldly, especialy if it is more than just a sequence of commands. You also can't use cat my_script | ssh <host> /bin/bash because then you loose your stdin and thus your interactivity.

However, there is a way to achieve our goal using the first form above. Consider that the maximum command line length is usually more than 2MB (see getconf ARG_MAX). Thus, we convert our entire script into a base64 encoded string with cat my_script | base64 and then call ssh -t <host> /bin/bash "<(echo <base64 string> | base64 --decode)". In this way the entire script is sent to the host in the command buffer, and so long as our total command length is less than 2MB, it will run.

sourcesimian /
Created Jan 16, 2018
Installing Python trezor API on Ubuntu Linux (17.10)

Installing Python Trezor API on Ubuntu Linux (17.10)

This proved to be quite tricky. I did so for Python 2 and Python 3. Here are my notes:

Setup for Chrome:

$ cat /etc/udev/rules.d/51-trezor.rules

SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0666", GROUP="dialout", SYMLINK+="trezor%n"
KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001",  MODE="0666", GROUP="dialout"


sourcesimian /
Created May 17, 2017
Dropin folder to generate ~/.ssh/config
# Put this script in a folder named ssh-config.d
# Add as many contributer files as you line to this folder
# They will be concatenated into ~/.ssh/config in lexical order
echo "### Auto generated by: $0 ###" >~/.ssh/config
for script in $(ls -1 $(dirname $0)/* | grep -v -e "$0" -e "~\$" ); do
echo "" >>~/.ssh/config
echo "# --- Origin: $script --- #" >>~/.ssh/config
sourcesimian /
Created Apr 16, 2017
Bitcoin: Migrate away from Armory Wallet

Bitcoin: Migrate away from Armory Wallet

Previously I setup an Armory online/offline/cold/paper bitcoin storage system. Recently I decided to migrate my bitcoin from Armory wallet cold storage to the BIP39 and related standards. I hadn't switched on the offline PC in a long time, and neither had I updated the blockchain on the online PC. Thus, I started considering my recovery options should something have broken or gone missing. Below are some of the ways I found to recover and move bitcoin in such failure scenarios.

Armory Paper Backup -> Root Key

Version 1.35c

The single-sheet Armory paper backup directly displays the Root Key, e.g.:

Root Key:     nidh jtfj ejue whkj dngt dftt hsss idgh ssss
              wwad dojw aeja idfg went ukkk sajj uuwj kwjt
View read-only-bind-mount.txt
## Setup
$ sudo mkdir /mnt/pool-RO
$ sudo mount --bind /mnt/pool /mnt/pool-RO
$ sudo mount -o remount,ro /mnt/pool-RO
## Test
$ touch /mnt/pool/t1
$ touch /mnt/pool-RO/t2
touch: cannot touch `/mnt/pool-RO/t2': Read-only file system
$ rm /mnt/pool-RO/t1
sourcesimian /
Created Jun 11, 2016
Filesystem tree content comparison using md5sum
# Filesystem tree content comparison using md5sum
# Usage:
# $ md5tree-cmd hash <folder 1> > my_hash_file_1
# $ md5tree-cmp hash <folder 2> > my_hash_file_2
# $ md5tree-cmp only <hash_file_1> <hash_file_2>
set -e
sourcesimian / tssh
Created Jun 10, 2016
Light weight MoSH using Tmux and BASH
View tssh
#! /bin/bash
# usage: tssh <host> <tmux target> [<ssh args>]
# requires ssh passwordless login to be setup and tmux to be installed on the remote machine
ssh="ssh -o ConnectTimeout=4 -o ServerAliveInterval=4 -o ServerAliveCountMax=2 -o TCPKeepAlive=yes"
if [ ! -z $target ]; then
sourcesimian /
Created Jun 9, 2016
Parser to interpret tabulated text
import re
class TextTable(object):
Parser to interpret tabulated text, e.g:
>>> text = '''-------------------------------------------------------------------
... hPa m C C % g/kg deg knot K K K
sourcesimian /
Created Jun 9, 2016
A convenience class for building hierarchical CLI argument parser with sub commands using ArgumentParser.
#!/usr/bin/env python
import sys
from argparse import ArgumentParser
class ArgParseTree(object):
A convenience class for building hierarchical CLI argument parser with sub commands using ArgumentParser.
You can’t perform that action at this time.