Skip to content

Instantly share code, notes, and snippets.

Avatar
🐅

Jody McIntyre scjody

🐅
View GitHub Profile
@scjody
scjody / keybase.md
Last active September 10, 2019 12:22
keybase.md
View 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 / tramp-gcloud-ssh
Created February 5, 2018 18:16
EMACS TRAMP setup for "gcloud compute ssh"
View tramp-gcloud-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 / gscp
Last active December 7, 2018 15:15
"gcloud compute scp" wrapper to figure out the zone automatically
View gscp
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:)
@scjody
scjody / gc
Created February 5, 2018 18:12
"gcloud config" wrapper to easily select the correct configuration
View gc
#!/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 / gssh
Last active October 8, 2021 01:55
"gcloud compute ssh" wrapper to figure out the zone automatically
View gssh
#!/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'
View test_flamepixel_server.py
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 / 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.
View bar_class.js
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";
}
@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 :)
View barnsley.py
# 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
View sierpinski.py
# 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
View quebec_public_bodies.rb
#!/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'