Skip to content

Instantly share code, notes, and snippets.

View jay-johnson's full-sized avatar

Jay jay-johnson

View GitHub Profile
@jay-johnson
jay-johnson / Python 2 vs Python 3 sys.path - things to check when a user has an "alias python" set in bash, sh, zsh profile.md
Created November 14, 2018 16:37
Python 2 vs Python 3 sys.path - things to check when a user has an "alias python" set in bashrc/shell profile
Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-x86_64-linux-gnu', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages']
>>> 
jay@dev:~$ python3
Python 3.6.5 (default, Apr 1 2018, 05:46:30) 
@jay-johnson
jay-johnson / run-equity-algorithm-using-the-stock-analysis-engine.py
Created November 8, 2018 08:38
Run an Equity Algorithm using the Stock Analysis Engine
import pandas as pd
from analysis_engine.algo import EquityAlgo
ticker = 'SPY'
demo_algo = EquityAlgo(
ticker=ticker,
balance=1000.00,
commission=6.00,
name='test-{}'.format(ticker))
date_key = '{}_2018-11-05'.format(
ticker)
@jay-johnson
jay-johnson / run_daily_with_zipline.py
Last active November 4, 2018 16:16
SPY - stock analysis engine with Quantopian zipline run_algorithm with portfolio and benchmark using matplotlib
#!/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 October 10, 2018 22:08
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#
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 October 10, 2018 07:14
Bash function for logging into a Kubernetes container and running a command with support for N-args
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 September 22, 2018 20:59
vimrc file for python
"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"
@jay-johnson
jay-johnson / iterm2-profile.json
Last active October 7, 2018 15:15
iterm2 profile
{
"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 September 22, 2018 20:39
vim prepare steps with vundle and you complete me
#!/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
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 September 2, 2018 20:21
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
ip_vs
ip_vs_rr
ip_vs_wrr
ip_vs_sh
nf_conntrack_ipv4