Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin S stantonk

View GitHub Profile
@stantonk
stantonk / Dockerfile
Last active May 6, 2020
example of using docker container to package a python application
View Dockerfile
FROM python:3.7
RUN mkdir -p /data
COPY p.py /p.py
RUN pip install click
WORKDIR /
ENTRYPOINT ["python", "p.py"]
@stantonk
stantonk / Dockerfile
Created Jun 12, 2019 — forked from calavera/Dockerfile
Dockerfile to build the Go version of Execsnoop and run it with JSON output format
View Dockerfile
FROM ubuntu:18.04
# Install BCC Tools
RUN set -ex; \
echo "deb [trusted=yes] http://repo.iovisor.org/apt/bionic bionic-nightly main" > /etc/apt/sources.list.d/iovisor.list; \
apt-get update -y; \
DEBIAN_FRONTEND=noninteractive apt-get install -y auditd bcc-tools curl gcc git libelf1 libbcc-examples;
# Install Go
ENV GO_SHA 1dfe664fa3d8ad714bbd15a36627992effd150ddabd7523931f077b3926d736d
View s3bucketsizes.py
# from: http://www.slsmk.com/getting-the-size-of-an-s3-bucket-using-boto3-for-aws/
# modified to return rounded sizes in Gigabytes
# and sorted by descending total storage size
import boto3
import datetime
now = datetime.datetime.now()
cw = boto3.client('cloudwatch')
@stantonk
stantonk / statsd.py
Created Jan 30, 2018
statsd demo code in python
View statsd.py
import re
import time
import sys
from socket import socket
from socket import AF_INET
from socket import SOCK_DGRAM
import os
@stantonk
stantonk / Vagrantfile
Last active Jul 26, 2017
python and dockerd in an Ubuntu VM.
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision :shell, :inline => <<-EOS
sudo apt-get update && sudo apt-get install -y python-dev python-pip git
sudo apt-get install python-pip
@stantonk
stantonk / Program.out
Last active Jun 29, 2017
Demonstrating classic thread safety issue with object reference being reused and passed to another thread
View Program.out
Thread-0 Person{name='Init', age=0}
Thread-0 Person{name='Init', age=0}
Thread-0 Person{name='Init', age=0}
main Person{name='Foo', age=-1356876606}
Thread-0 Person{name='Foo', age=-1356876606}
Thread-0 Person{name='Foo', age=-1356876606}
Thread-0 Person{name='Foo', age=-1356876606}
main Person{name='Bar', age=1050348248}
Thread-0 Person{name='Bar', age=1050348248}
Thread-0 Person{name='Bar', age=1050348248}
@stantonk
stantonk / jdk_download.sh
Created Jun 3, 2017 — forked from P7h/jdk_download.sh
Script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt
View jdk_download.sh
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
@stantonk
stantonk / Dockerfile
Created May 7, 2017
barebones Docker base image w/ Oracle JVM
View Dockerfile
FROM ubuntu:16.04
# Install Java8
# Presumes you have downloaded / accepted the license file from Oracle's website.
# https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps
RUN mkdir /opt/jdk
COPY ./jdk-8u112-linux-x64.tar.gz /tmp/
RUN tar -zxvf /tmp/jdk-8u112-linux-x64.tar.gz -C /opt/jdk
RUN update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_112/bin/java 100
RUN update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_112/bin/javac 100
@stantonk
stantonk / nr.py
Created Feb 1, 2017
beginning of grabbing stats from NewRelic API
View nr.py
import json
import logging
import requests
import sys
from collections import namedtuple
from functools import partial
from urlparse import urlparse
from urlparse import parse_qs
You can’t perform that action at this time.