Skip to content

Instantly share code, notes, and snippets.

View jay-johnson's full-sized avatar

Jay jay-johnson

View GitHub Profile

Set these under iTerm2 > Preferences > Keys

Vim Page Down

control + d

Send Text with "vim" Special Chars

to

@jay-johnson
jay-johnson / Asciinema Command Example
Created January 9, 2019 16:59
Asciinema Command Example
file=/data/asciinema/sa-2-fullstack; rm -f ${file}; asciinema rec ${file} -i 2 -t "title_here"
@jay-johnson
jay-johnson / convert_date_columns_from_UTC_to_EST_dates.py
Last active January 3, 2019 19:02
Pandas Convert Date Column From UTC to EST dates
#!/usr/bin/env python
import pandas as pd
df = pd.DataFrame([
{
'date': '2019-01-01 14:30:00',
'epochms': 1546353000000
},
{
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 / Django_ReactJS_Webpack_project_setup.md
Created July 12, 2017 22:21 — forked from Belgabor/Django_ReactJS_Webpack_project_setup.md
Set up a Django + ReactJS project with Webpack manager

Guide on how to create and set up your Django project with webpack, npm and ReactJS :)

Hopefully this will answer "How do I setup or start a Django project?" I was trying to set up my own website, and there was a lot to read, learn and digest! Therefore, I put this together which is a collection of all the guides/blog posts/articles that I found the most useful. At the end of this, you will have your barebones Django app configured and ready to start building :)

NOTE: This guide was built using Django 1.9.5, NodeJS 4+ with NPM 3+

1. Setting up your dev environment

@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"
}