Skip to content

Instantly share code, notes, and snippets.

@jtriley
jtriley / terminalsize.py
Created Jul 26, 2011
Get current terminal size on Linux, Mac, and Windows
View terminalsize.py
#!/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 Nov 1, 2013
Simple Python script that computes both public and private RSA key fingerprints as used by Amazon EC2
View ec2-fingerprint-key
#!/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(
View starcluster_loadbalance_supervisor.conf
[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 Aug 9, 2012
Example StarCluster plugin that tags all instances based on tags specified in the config
View 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 / boss-access-token.sh
Last active Mar 31, 2017
Shell script for requesting a boss OIDC access token
View boss-access-token.sh
#!/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
View keybase.md

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 Dec 4, 2013
Small example showing how to use the ClusterManager class for high-level cluster management.
View clustermanager-example.py
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 Aug 9, 2012
Example StarCluster plugin that configures environment variables on all nodes
View config
# 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 Apr 2, 2013
Plugin for StarCluster that configures a boto credentials file for the cluster user
View gist:5295096
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 Oct 11, 2015
IPython Parallel Push/Execute/Pull Demo
View ipy_parallel_push_exec_pull.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.