Skip to content

Instantly share code, notes, and snippets.

View claytantor's full-sized avatar
💭
Doing and Being

Clay Graham claytantor

💭
Doing and Being
View GitHub Profile
@claytantor
claytantor / cf_cname_subdomain.json
Last active April 21, 2020 12:05
create a subdomain using a CF template
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Template Route53_CNAME. This uses the patameters to create a subdomain CNAME",
"Parameters" : {
"HostedZone" : {
"Type" : "String",
"Description" : "The DNS name of an existing Amazon Route 53 hosted zone",
"AllowedPattern" : "(?!-)[a-zA-Z0-9-.]{1,63}(?<!-)",
@claytantor
claytantor / lambda_log4j2.xml
Created May 4, 2016 01:33
How to set your log4j2 file to support the lambda appender.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO" packages="com.amazonaws.services.lambda.runtime.log4j">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %C - %msg%n"/>
</Console>
<LambdaAppender name="LambdaAppender">
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n"/>
</LambdaAppender>
</Appenders>
@claytantor
claytantor / iot.py
Created January 13, 2019 15:13
IOT client using MQTT
#!/usr/bin/env python
# coding: utf-8
import yaml
import os, sys
import time
import logging
import json
# Import SDK packages
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
#!/bin/bash
# stop script on error
set -e
THING_NAME=$1
THING_ENDPOINT=$2
python3 -m venv venv --system-site-packages
@claytantor
claytantor / dax_first_hour.txt
Created July 18, 2016 01:42
DAX first hour for TradeStation
// EasyLanguage (TradeStation) / PowerLanguage (MultiCharts) code
// basic code to play around with :-)
// DAX, 5min time frame, default settings, exchange time
input:
RangeMultiplier(0.95),
BegTime(0900),
EndTime(0955),
CloseTime(2155),
#!/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 June 29, 2017 23:10
kill a process on a port windows
#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 June 18, 2017 21:59
capturing both stderr and std to a single list of strings.
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 15:29
Using Docker with Travis

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