Skip to content

Instantly share code, notes, and snippets.

View johnmccabe's full-sized avatar
🍕
eat sleep rebase repeat

John McCabe johnmccabe

🍕
eat sleep rebase repeat
View GitHub Profile
@johnmccabe
johnmccabe / txdocker
Created March 30, 2019 22:07 — forked from JasonAtNvidia/txdocker
Short Bash script to enable use of the GPU within a docker container running on an NVIDIA Jetson TX2. Place inside /usr/local/bin/, chmod +x txdocker, ensure it is in your system PATH, and use just as you would the docker command.
#!/bin/bash
#Jason T. 2-6-2018
# Check specifically for the run command
if [[ $# -ge 2 && $1 == "run" ]]; then
# Tell docker to share the following folders with the base system
# This allows the docker containers to find CUDA, cuDNN, TensorRT
LIB_MAPS="/usr/lib/aarch64-linux-gnu \
/usr/local/cuda \
/usr/local/cuda/lib64"
@johnmccabe
johnmccabe / recover_source_code.md
Created March 12, 2017 12:04 — forked from simonw/recover_source_code.md
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@johnmccabe
johnmccabe / tmux.md
Last active October 19, 2016 18:02 — 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

@johnmccabe
johnmccabe / cloudstack-sethostname.sh
Created April 25, 2016 18:55 — forked from makuk66/cloudstack-sethostname.sh
dhclient hook for setting the hostname, updating /etc/hosts, and re-generating ssh keys on Ubuntu.Useful for creating CloudStack templates.See https://issues.apache.org/jira/browse/CLOUDSTACK-4556
#!/bin/sh
echo "Running dhclient change hostname script for Ubuntu. reason=${reason}"
timestamp=$(date +%s)
if grep localhost /etc/hostname; then
echo "Current hostname:"
cat /etc/hostname
echo "Attempting to configure hostname"
if [ "x$reason" = "xBOUND" ]; then
hostname=$new_host_name
#!/bin/sh
# Filename: /etc/dhcp/dhclient-exit-hooks.d/sethostname
# Purpose: Used by dhclient-script to set the hostname of the system
# to match the DNS information for the host as provided by
# DHCP.
# logs in /var/log/syslog
#
echo dhclient-exit-hooks.d/sethostname: reason = $reason, interface = $interface
@johnmccabe
johnmccabe / gist_tag.rb
Created January 26, 2016 22:12 — forked from imathis/gist_tag.rb
A Liquid tag for Jekyll sites that allows embedding Gists and showing code for non-JavaScript enabled browsers and readers. [Working as of 26/01/2016]
require 'cgi'
require 'digest/md5'
require 'net/https'
require 'uri'
module Jekyll
class GistTag < Liquid::Tag
def initialize(tag_name, text, token)
super
@text = text
@johnmccabe
johnmccabe / manipulate_qdisc.py
Last active August 11, 2017 13:10 — forked from jolynch/manipulate_qdisc.py
Shows how to manipulate a plug qdisc manually using pyroute2
import pyroute2
from pyroute2 import IPRoute
from pyroute2.iproute import transform_handle
from pyroute2.netlink import NLM_F_ACK
from pyroute2.netlink import NLM_F_REQUEST
from pyroute2.netlink.rtnl.tcmsg import tcmsg
PLUG_CLASS = '1:4'
PLUG_QDISC = '40:'
@johnmccabe
johnmccabe / README.md
Last active August 29, 2015 14:21 — forked from mbostock/.block

This example is the second of three in the Path Transitions tutorial; see the previous example for context.

The desired pairing of numbers for path interpolation is like this:

M x0, y0 L x1, y1 L x2, y2 L x3, y3 L xR, y4
   ↓   ↓    ↓   ↓    ↓   ↓    ↓   ↓
M xl, y0 L x0, y1 L x1, y2 L x2, y3 L x3, y4

Where xl is some negative value off the left side, and xr is some positive value off the right side. This way, the first point ⟨x0,y0⟩ is interpolated to ⟨xl,y0⟩; meaning, the x-coordinate is interpolated rather than the y-coordinate, and so the path appears to slide off to the left. Likewise, the incoming point ⟨xr,y4⟩ is interpolated to ⟨x3,y4⟩.