Skip to content

Instantly share code, notes, and snippets.

View scjody's full-sized avatar
🐅

Jody McIntyre scjody

🐅
View GitHub Profile
@scjody
scjody / tramp-gcloud-ssh
Created February 5, 2018 18:16
EMACS TRAMP setup for "gcloud compute ssh"
;; TRAMP gcloud ssh
(add-to-list 'tramp-methods
'("gssh"
(tramp-login-program "gssh")
(tramp-login-args (("%h")))
(tramp-async-args (("-q")))
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-args ("-c"))
(tramp-gw-args (("-o" "GlobalKnownHostsFile=/dev/null")
("-o" "UserKnownHostsFile=/dev/null")
@scjody
scjody / gssh
Last active October 8, 2021 01:55
"gcloud compute ssh" wrapper to figure out the zone automatically
#!/bin/bash
HOST="$1"
if [[ $HOST = *"@"* ]] ; then
USER=$(echo $HOST | cut -d'@' -f1)
HOST=$(echo $HOST | cut -d'@' -f2)
fi
gcloud config list | grep 'Your active'
@scjody
scjody / gc
Created February 5, 2018 18:12
"gcloud config" wrapper to easily select the correct configuration
#!/bin/bash
if [[ -z "$1" ]]; then
gcloud config configurations list;
else
case "$1" in
# These clauses implement aliases for my most commonly used configurations.
# Change them to support your needs or remove them.
prod)
gcloud config configurations activate default
@scjody
scjody / keybase.md
Last active September 10, 2019 12:22
keybase.md

Keybase proof

I hereby claim:

  • I am scjody on github.
  • I am firetiger (https://keybase.io/firetiger) on keybase.
  • I have a public key ASBEDo8uV5GusW0YPudA5zXkSUqBsN-0PLU1IjAhkxY9fAo

To claim this, I am signing this object:

@scjody
scjody / gscp
Last active December 7, 2018 15:15
"gcloud compute scp" wrapper to figure out the zone automatically
function gscp {
gcloud config list |grep 'Your active'
for arg in "$@"; do
if echo "$arg" | grep -q : - ; then
break
fi
done
INST=$(echo "$arg" | cut -f1 -d:)
import socket
import re
PORT = 1075
LINE_VALIDATOR = re.compile(r"(0|1)(0|1)(0|1)(0|1)(0|1)")
def main():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(("0.0.0.0", PORT))
@scjody
scjody / barnsley.py
Created May 12, 2013 23:36
Script to plot a Barnsley fern using plot.ly. I feel this pushes the boundaries of what the site was made to do, but it works and I like it :)
# Python 2.7.3 (default, Apr 20 2012, 23:04:22) [GCC 4.6.3]
# Use plot() to plot lists or arrays
# Use print to show results in the command line history
from numpy import matrix
import random
# Define probabilities, multiplication matrices, and transforms
p1 = 0.01
@scjody
scjody / sierpinski.py
Last active December 17, 2015 03:38
Sierpinski triangle script for plot.ly, based on their Lindenmayer System demo
# Python 2.7.3 (default, Apr 20 2012, 23:04:22) [GCC 4.6.3]
# Use plot() to plot lists or arrays
# Use print to show results in the command line history
from numpy import sin, cos, pi
def f(s,itr):
xo=0
yo=0
a=0
#!/usr/bin/env ruby
# coding: utf-8
# @todo Properly case the organization name.
# @todo Handle case where the organization has >1 contact but no email
# address on the first contact, e.g. CSSS DE CHICOUTIMI.
# @todo For organizations without any email address, HTML-ify their
# postal address and put it in the notes section.
# @todo Investigate why we get BAIEJAMES in some cases.
require 'csv'
@scjody
scjody / bar_class.js
Last active August 29, 2015 13:59
That moment when you realize that, despite its numerous warts, it's possible to love JavaScript. This straghtforward construct just saved me 80 lines of cut and pasted code.
var default_value = parseInt(details.default_value);
function bar_class(d) {
if (default_value >= d.x && default_value < d.x + d.dx) {
return "default";
} else if (median >= d.x && median < d.x + d.dx) {
return "median";
}
return "standard";
}