Skip to content

Instantly share code, notes, and snippets.

Clay Graham claytantor

View GitHub Profile
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
@claytantor
claytantor / create_docker_machine.sh
Created Oct 24, 2016
how to create and size your boot3docker machine
View create_docker_machine.sh
$ docker-machine create --driver virtualbox --virtualbox-disk-size "32000" default
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.