Skip to content

Instantly share code, notes, and snippets.

@jtriley
jtriley / terminalsize.py
Created July 26, 2011 21:58
Get current terminal size on Linux, Mac, and Windows
#!/usr/bin/env python
import os
import shlex
import struct
import platform
import subprocess
def get_terminal_size():
""" getTerminalSize()
@jtriley
jtriley / ec2-fingerprint-key
Created November 1, 2013 19:28
Simple Python script that computes both public and private RSA key fingerprints as used by Amazon EC2
#!/usr/bin/env python
import hashlib
import optparse
import paramiko
from Crypto.PublicKey import RSA
def insert_char_every_n_chars(string, char='\n', every=64):
return char.join(
@jtriley
jtriley / boss-access-token.sh
Last active February 1, 2023 07:25
Shell script for requesting a boss OIDC access token
#!/bin/bash
BOSS_TOKEN_URL="https://auth.theboss.io/auth/realms/BOSS/protocol/openid-connect/token"
echo -n "BOSS Username: "
read BOSS_USER
echo -n "BOSS Password: "
read -s BOSS_PASSWORD
echo -en "\nBOSS Client Id: "
read BOSS_CLIENT_ID
@jtriley
jtriley / starcluster_loadbalance_supervisor.conf
Created October 30, 2013 20:54
Supervisor (https://pypi.python.org/pypi/supervisor) config for StarCluster's loadbalancer
[unix_http_server]
file=/tmp/supervisor.sock
[supervisord]
logfile=/tmp/supervisord.log
logfile_maxbytes=50MB
logfile_backups=10
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=false
@jtriley
jtriley / config
Created August 9, 2012 15:47
Example StarCluster plugin that tags all instances based on tags specified in the config
# This is an example config that assumes tagger.py is either in
# $HOME/.starcluster/plugins or lives somewhere in your $PYTHONPATH
[plugin tagger]
setup_class = tagger.TaggerPlugin
# add as many key=value pairs as you like separated by ','
tags = 'mykey=myvalue, mykey2=myvalue2'
[cluster default]
...
@jtriley
jtriley / keybase.md
Last active November 14, 2016 18:13

Keybase proof

I hereby claim:

  • I am jtriley on github.
  • I am jtriley (https://keybase.io/jtriley) on keybase.
  • I have a public key ASAOFDG0YCtUZcaWZrjbJGvF2J7BAk3_sntdNkYawPTmRgo

To claim this, I am signing this object:

@jtriley
jtriley / clustermanager-example.py
Created December 4, 2013 20:27
Small example showing how to use the ClusterManager class for high-level cluster management.
from starcluster import config
from starcluster import cluster
cfg = config.StarClusterConfig().load()
ec2 = cfg.get_easy_ec2()
cm = cluster.ClusterManager(cfg, ec2=ec2)
cl = cm.get_cluster("your_running_cluster_tag")
print len(cl.running_nodes)
@jtriley
jtriley / config
Created August 9, 2012 19:28
Example StarCluster plugin that configures environment variables on all nodes
# This is an example config that assumes scenv.py is either in
# $HOME/.starcluster/plugins or lives somewhere in your $PYTHONPATH
[plugin env]
setup_class = scenv.EnvPlugin
# add as many key=value pairs as you like separated by ','
env_vars_list = 'PYTHONPATH=/path/to/python/mods, MYENV=some_value'
[cluster default]
...
@jtriley
jtriley / gist:5295096
Created April 2, 2013 18:55
Plugin for StarCluster that configures a boto credentials file for the cluster user
import os
from starcluster import clustersetup
from starcluster.logger import log
BOTO_CFG_TEMPLATE = """\
[Credentials]
aws_access_key_id = %(aws_access_key_id)s
aws_secret_access_key = %(aws_secret_access_key)s
@jtriley
jtriley / ipy_parallel_push_exec_pull.ipynb
Last active October 11, 2015 13:37
IPython Parallel Push/Execute/Pull Demo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.