Skip to content

Instantly share code, notes, and snippets.

💭
Doing and Being

Clay Graham claytantor

💭
Doing and Being
Block or report user

Report or block claytantor

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:cf525ffe375e8fabae7d40260f11ff4e
update_PS1 () {
VENV_PROMPT="(${VIRTUAL_ENV##*/})"
if [ $VENV_PROMPT == "()" ]; then
VENV_PROMPT=""
fi
PS1="\[$(tput bold)\]\[\033[38;5;214m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;76m\]@\[$(tput sgr0)\]\[\033[38;5;82m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;226m\]\W\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]"
PS1="$PS1$(__git_ps1 "\[\e[32m\][%s]\[\e[0m\]") $VENV_PROMPT $ "
}
shopt -u promptvars
View bootstrap.sh
#!/bin/bash
# stop script on error
set -e
THING_NAME=$1
THING_ENDPOINT=$2
python3 -m venv venv --system-site-packages
@claytantor
claytantor / iot.py
Created Jan 13, 2019
IOT client using MQTT
View iot.py
#!/usr/bin/env python
# coding: utf-8
import yaml
import os, sys
import time
import logging
import json
# Import SDK packages
View time_slicer.py
#!/usr/bin/env python
#coding: utf-8
#python 2.7
# for use with android app Timesheet https://play.google.com/store/apps/details?id=com.rauscha.apps.timesheet&hl=en
import json
import logging
import sys
import argparse
import csv
@claytantor
claytantor / kill_pid_port.bat
Created Jun 29, 2017
kill a process on a port windows
View kill_pid_port.bat
#Open command prompt and run the following commands, works in poweshell
netstat -o -n -a | findstr 0.0:3000
# TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 3116
taskkill /F /PID 3116
@claytantor
claytantor / capture_all.py
Created Jun 18, 2017
capturing both stderr and std to a single list of strings.
View capture_all.py
from cStringIO import StringIO
class Capturing(list):
def __enter__(self):
self._stdout = sys.stdout
self._stderr = sys.stderr
sys.stdout = self._stringio = StringIO()
sys.stderr = self._stringio
return self
@claytantor
claytantor / docker_travis.md
Created May 10, 2017
Using Docker with Travis
View docker_travis.md

Creating and shipping the Docker image

In the after_success section of the .travis.yml file, we log on Docker Hub registry, then we build the image.

We also tag the generated image with:

the short git commit hash the travis build number latest if it is the master branch, otherwise the name of the branch And finally we push it on the Docker Hub registry

@claytantor
claytantor / generate_model.py
Last active Mar 23, 2017
Allows for the generation of Rasa NLU models from a simpler form. It seems the native format has a lot of redundant information. This allows for a normalized model.
View generate_model.py
#!/usr/bin/env python
# coding: utf-8
import sys
import json
import re
import traceback
def load_model(model_file):
model = {}
with open(model_file, 'r') as f:
@claytantor
claytantor / OktaGetpublickeyNimbus.java
Created Nov 7, 2016
getting okta key with nimbus
View OktaGetpublickeyNimbus.java
/**
Okta provides the kid field in the header part of the JWT token.
**/
PublicKey loadKey(String keyId) {
try {
JSONObject key = getProviderRSAJWK(
retrieveOIDCProviderMetadata().getJWKSetURI().toURL().openStream(),
keyId);
@claytantor
claytantor / docker_bash.sh
Created Oct 27, 2016
how to set a osx shell to run docker
View docker_bash.sh
#!/bin/bash
export DOCKER_HOST=tcp://192.168.99.101:2376
export DOCKER_CERT_PATH=/Users/claytongraham/.docker/machine/machines/default
export DOCKER_TLS_VERIFY=1
You can’t perform that action at this time.