Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Doing and Being

Clay Graham claytantor

💭
Doing and Being
View GitHub Profile
@claytantor
claytantor / cf_cname_subdomain.json
Last active Apr 21, 2020
create a subdomain using a CF template
View cf_cname_subdomain.json
{
"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
How to set your log4j2 file to support the lambda appender.
View lambda_log4j2.xml
<?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 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 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 / dax_first_hour.txt
Created Jul 18, 2016
DAX first hour for TradeStation
View dax_first_hour.txt
// 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),
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