Skip to content

Instantly share code, notes, and snippets.

Jay jay-johnson

Block or report user

Report or block jay-johnson

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
@jay-johnson
jay-johnson / run_daily_with_zipline.py
Last active Nov 4, 2018
SPY - stock analysis engine with Quantopian zipline run_algorithm with portfolio and benchmark using matplotlib
View run_daily_with_zipline.py
#!/usr/bin/env python
import pytz
import zipline
import datetime
import matplotlib.pyplot as plt
import pandas as pd
import analysis_engine.extract as extract
from collections import OrderedDict
from zipline.api import order
@jay-johnson
jay-johnson / conf.py
Created Oct 10, 2018
read the docs - sphinx conf.py for finding source code from the docs path - example code block from https://stock-analysis-engine.readthedocs.io/en/latest/README.html#
View conf.py
import os
import sys
from unittest.mock import MagicMock
from recommonmark.parser import CommonMarkParser
from pprint import pprint
on_rtd = os.getenv("READTHEDOCS", "") != ""
# Using working source code sphinx conf.py on read the docs:
# https://github.com/mahmoud/boltons/blob/master/docs/conf.py#L20
@jay-johnson
jay-johnson / .bashrc
Last active Oct 10, 2018
Bash function for logging into a Kubernetes container and running a command with support for N-args
View .bashrc
function sl() {
use_namespace="default"
pod_name=$(kubectl get pods -n ${use_namespace} | awk '{print $1}' | grep api | head -1)
kubectl exec -it \
${pod_name} \
-n ${use_namespace} \
-- bash -c ". /opt/venv/bin/activate && sp -q 'index=\"antinex\" AND ${@}' -u trex -p 123321 -i antinex -a splunk-svc:8089 | grep -v urllib3.connectionpool"
# -- bash -c ". /opt/venv/bin/activate && echo \"sp -q 'index=\"antinex\" AND ${@}' -u trex -p 123321 -a splunk-svc:8089 | grep -v urllib3\" && sp -q '${@}' -u trex -p 123321 -i antinex -a splunk-svc:8089 | grep -v urllib3.connectionpool"
}
@jay-johnson
jay-johnson / .vimrc
Created Sep 22, 2018
vimrc file for python
View .vimrc
"2016-11-10 v1 - start"
" set tabstop=4
" set shiftwidth=4
" set smartindent
" set pastetoggle=<F10>
"2016-11-10 v1 - end"
"2016-11-10 v2 - start"
set pastetoggle=<F10>
set autoindent " always set autoindenting on"
View iterm2-profile.json
{
"Use Non-ASCII Font" : false,
"Tags" : [
],
"Ansi 12 Color" : {
"Red Component" : 0,
"Color Space" : "sRGB",
"Blue Component" : 0.985260009765625,
"Alpha Component" : 1,
@jay-johnson
jay-johnson / vim-prepare.sh
Last active Sep 22, 2018
vim prepare steps with vundle and you complete me
View vim-prepare.sh
#!/bin/bash
on_darwin=$(uname -s | grep -i darwin | wc -l)
test_brew_exists=$(which brew | wc -l)
if [[ "${test_brew_exists}" != "0" ]]; then
brew install cmake
fi
mkdir ~/.vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
View .bashrc
alias t='pushd /opt/sa && source /opt/venv/bin/activate && py.test --maxfail=1 && flake8 . && pycodestyle . && popd'
alias lsprice='source /opt/venv/bin/activate && aws --endpoint-url http://localhost:9000 s3 ls s3://pricing'
alias lsbucket='source /opt/venv/bin/activate && aws --endpoint-url http://localhost:9000 s3 ls'
use_aws() {
export S3_ACCESS_KEY=ACCESS
export S3_SECRET_KEY=SECRET
export S3_ADDRESS=s3.us-east-1.amazonaws.com
export S3_BUCKET=BUCKET_NAME
export S3_REGION_NAME=us-east-1
@jay-johnson
jay-johnson / ip_vs.conf
Last active Sep 2, 2018
kube-proxy kernel modules for kubernetes on Centos 7 - add these lines to /etc/modules-load.d/ip_vs.conf - testing proposed values from https://github.com/kubernetes/kubernetes/issues/60869 with docs https://github.com/kubernetes/kubernetes/tree/master/pkg/proxy/ipvs#run-kube-proxy-in-ipvs-mode
View ip_vs.conf
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4
@jay-johnson
jay-johnson / start-vm.sh
Last active Sep 2, 2018
KVM - virt-install to start a vm - with cpu + memory + bridge network settings - and commented out how to seed a file to the vm on startup
View start-vm.sh
virt-install \
–-name master1 \
–-vcpus 2 \
–-ram 1024 \
–-network bridge=br0 \
# –-connect qemu:///system \
# –-disk pool=master1,size=20,bus=virtio,sparse=false \
# -–location http://us.archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/ \
# -–initrd-inject=preseeds/preseed.cfg \
# -–extra-args="locale=en_US.UTF-8 console-setup/ask_detect=false keyboard-configuration/layoutcode=us file=file:/preseed.cfg vga=788 quiet console=tty0 utf8 console=ttyS0,115200" \
@jay-johnson
jay-johnson / splunk_send_json_fields_over_tcp.py
Last active Jul 4, 2018
Send Logs with JSON Fields to Splunk over TCP with sourcetype set to _json
View splunk_send_json_fields_over_tcp.py
#!/usr/bin/env python
import os
import sys
import json
import socket
import datetime
import time
You can’t perform that action at this time.