Skip to content

Instantly share code, notes, and snippets.

View johnmccabe's full-sized avatar
💀

John McCabe johnmccabe

💀
View GitHub Profile
@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 / 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 / timeout_buffered_error_channel.go
Created April 11, 2017 14:51
Dealing with Timeout via a buffered error channel
package main
import (
"fmt"
"log"
"time"
)
func work() error {
for i := 0; i < 1000; i++ {
@johnmccabe
johnmccabe / timeout_with_context.go
Created April 11, 2017 15:14
Using context to handle timeouts
package main
import (
"fmt"
"sync"
"time"
"golang.org/x/net/context"
)
@johnmccabe
johnmccabe / lumogon_tidyup.sh
Created May 11, 2017 13:31
purge old lumogon containers
#!/bin/bash
echo "Removing lumogon containers"
docker ps -a | grep lumogon_ | awk '{ print $1 }' | xargs -I {} docker rm {}
@johnmccabe
johnmccabe / README.md
Last active April 24, 2025 10:07
Installing cockpit-docker with Docker CE on CentOS7

Install cockpit-docker for Docker CE on CentOS

sudo yum install epel-release
sudo yum -y install dnf dnf-plugins-core
dnf download cockpit-docker
sudo rpm -Uvh --nodeps cockpit-docker-138-6.el7.centos.x86_64.rpm
sudo service cockpit restart
@johnmccabe
johnmccabe / Current version
Last active June 20, 2017 09:48
Docker 1.12 - Fedora 25 - Client latest/PR159
[root@do2mgs0hdqqkkbj ~]# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock puppet/lumogon version
Client:
Version: 20170524205424-0.2.0-27-ge10ec0d
Git commit: e10ec0df4c031da28e3972915ffd868731af4ce6
Built: 2017-05-24 08:54:24 UTC
[root@do2mgs0hdqqkkbj ~]# docker run --rm -v /var/run/docker.sock:/var/run/docker.sock puppet/lumogon scan --debug
[lumogon] 2017/06/07 19:52:25.475292 [Analytics] Initializing Google Analytics: scan
[lumogon] 2017/06/07 19:52:25.475334 [Docker Adapter] Creating container runtime client: Docker
[lumogon] 2017/06/07 19:52:25.495651 [Scheduler] Creating scheduler
[lumogon] 2017/06/07 19:52:25.495682 [Docker Adapter] Creating container runtime client: Docker
version: '3'
services:
brooklyn:
image: johnmccabe/brooklyn
ports:
- "8081:8081"
links:
- "node1:node1"
node1:
image: johnmccabe/fakevmtest
@johnmccabe
johnmccabe / out.json
Created July 4, 2017 22:41
libral.GetTypes() go wrapper output
{
"providers": [
{
"name": "file::posix",
"type": "file",
"source": "builtin",
"desc": "A provider to manage POSIX files.\n",
"suitable": true,
"attributes": [
{
"target": "/etc/hosts",
"title": "localhost"
},
{
"ensure": "present",
"ip": "255.255.255.255",
"name": "broadcasthost",
"provider": ":aug",
"resource": "host",
"target": "/etc/hosts",