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 / 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 / sample_marathon_task.json
Created March 25, 2016 13:20
Triggering the UNMANAGED ON_FIRE
MARATHON_URL=http://xxx.xxx.xxx.xxx:8080
curl -X POST ${MARATHON_URL}/v2/apps -d @sample_marathon_task.json -H "Content-type: application/json"
@johnmccabe
johnmccabe / test_catalog.bom
Created January 13, 2016 11:45
#212 test
brooklyn.catalog:
version: 0.9.0-SNAPSHOT # BROOKLYN_VERSION
items:
# load everything in the classpath with a @Catalog annotation
- scanJavaAnnotations: true
- id: server
description: |
Provision a server, with customizable provisioning.properties and credentials installed,
#!/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 / 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
@johnmccabe
johnmccabe / gist:f60f900ea05ce2a222dd13cebe028981
Created May 18, 2016 09:46
GeoscalingDNS + external config supplier - deadlock?
"brooklyn-jetty-server-8443-qtp878715618-32" prio=10 tid=0x00007f7ecd87d000 nid=0x7371 waiting on condition [0x00007f7eba19a000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x00000007be966a90> (a java.util.concurrent.FutureTask)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:186)
at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:425)
at java.util.concurrent.FutureTask.get(FutureTask.java:187)
at com.google.common.util.concurrent.ForwardingFuture.get(ForwardingFuture.java:63)
at org.apache.brooklyn.util.core.task.BasicTask.get(BasicTask.java:361)
at org.apache.brooklyn.util.time.Durations.get(Durations.java:43)
hello
@johnmccabe
johnmccabe / fixssh_fn.sh
Created September 28, 2016 19:55
Bash function to fix access to SSH agent when using TMUX and agent forwarding
# via https://coderwall.com/p/_s_xda/fix-ssh-agent-in-reattached-tmux-session-shells
fixssh() {
for key in SSH_AUTH_SOCK SSH_CONNECTION SSH_CLIENT; do
if (tmux show-environment | grep "^${key}" > /dev/null); then
value=`tmux show-environment | grep "^${key}" | sed -e "s/^[A-Z_]*=//"`
export ${key}="${value}"
fi
done
}
@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