Skip to content

Instantly share code, notes, and snippets.

View bjpcjp's full-sized avatar
💭
Fully caffeinated for your safety

brian piercy bjpcjp

💭
Fully caffeinated for your safety
View GitHub Profile
@bjpcjp
bjpcjp / example.sh
Created October 29, 2022 01:00
shell script best practices template
#!/usr/bin/env bash
# source: https://sharats.me/posts/shell-script-best-practices/
set -o errexit
set -o nounset
set -o pipefail
if [[ "${TRACE-0}" == "1" ]]; then
set -o xtrace
fi
@bjpcjp
bjpcjp / metrics.py
Created January 15, 2022 18:06 — forked from bfan1256/metrics.py
5 Performance Metrics for Trading Algorithms and Investment Portfolios
from blankly import Alpaca, CoinbasePro # supports stocks, crypto, and forex
import numpy as np
from math import sqrt
def cagr(start_value: float, end_value: float, years: int):
return (end_value / start_value) ** (1.0 / years) - 1
def sharpe(account_values: np.array, risk_free_rate, annualize_coefficient):
diff = np.diff(account_values, 1) / account_values[1:] # this gets our pct_return in the array
@bjpcjp
bjpcjp / approximate_nearest_neighbors.py
Created April 1, 2021 19:38
https://scikit-learn.org example - approximate_nearest_neighbors.py
# Author: Tom Dupre la Tour
#
# License: BSD 3 clause
import time
import sys
try:
import annoy
except ImportError:
print("The package 'annoy' is required to run this example.")
@bjpcjp
bjpcjp / gist:73c9f2048fe174ec335c891815731778
Created July 30, 2020 12:10
Rails 6.0.2.3 - test failure out-of-the-box
# Rails 6.0.2.3
# 'Behavior' = std Rails scaffold with one name:string attribute.
# rails db:migrate = no problem.
# rails test = 2 fails below. other controllers (~60, identical except for object name) pass.
Error:
BehaviorsControllerTest#test_should_destroy_behavior:
NoMethodError: undefined method `count' for ActionDispatch::IntegrationTest::Behavior:Module
test/controllers/behaviors_controller_test.rb:42:in `block in <class:BehaviorsControllerTest>'
test/controllers/behaviors_controller_test.rb:42:in `block in <class:BehaviorsControllerTest>'
@bjpcjp
bjpcjp / gist:c3bb322015e80a11a98463ac5025408a
Created May 15, 2020 15:09
$rails (6.0.3) test issue - unknown root cause
31: from -e:1:in `<main>'
30: from /home/<myname>/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:72:in `require'
29: from /home/<myname>/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0/rubygems/core_ext/kernel_require.rb:72:in `require'
28: from /home/<myname>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
27: from /home/<myname>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
26: from /home/<myname>/projects/ideas/factory-inabox/v20200501/bin/rails:9:in `<top (required)>'
25: from /home/<myname>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/zeitwerk-2.3.0/lib/zeitwerk/kernel.rb:23:in `require'
24: from /home/<myname>/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
23: from /home/<myname>/.rbenv/versions/2.5.1/lib/ru
@bjpcjp
bjpcjp / gist:6c44091abd0e8e7b35b30cb0d773709a
Created April 14, 2020 18:06
$vagrant plugin install vagrant-share error
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
conflicting dependencies fog-core (~> 1.43.0) and fog-core (= 1.45.0)
Activated fog-core-1.45.0
which does not match conflicting dependency (~> 1.43.0)
Conflicting dependency chains:

The Art of Profitability

Original notes by James Clear

  • Do the math yourself. Too many people take numbers from unreliable sources.

  • There are 4 levels of learning: Awareness, Awkwardness, Application, Assimilation

  • Customer-Solution Profit: Know your customers incredibly well and create a solution specifically for them.

@bjpcjp
bjpcjp / dash-hello-world.py
Created February 20, 2019 02:10
$python app.py -- launches basic example of Dash web app framework. View results on localhost port# 8050.
import dash
import dash_core_components as dcc
import dash_html_components as html
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div(children=[
html.H1(children='Hello Dash'),
@bjpcjp
bjpcjp / housingScrape.py
Created February 8, 2018 22:57 — forked from theriley106/housingScrape.py
Scraping Valid Addresses from all US ZipCodes
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
import requests
import bs4
import zipcode
import threading
import re
import json
import time
@bjpcjp
bjpcjp / main.r
Created February 8, 2016 02:46
Build your own neural network classifier in R (source: http://junma5.weebly.com/data-blog)
# How to build your own NN classifier in r
# source: http://www.r-bloggers.com/build-your-own-neural-network-classifier-in-r/
# reference: http://junma5.weebly.com/data-blog/build-your-own-neural-network-classifier-in-r
# project:
# 1) build simple NN with 2 fully-connected layers
# 2) use NN to classify a dataset of 4-class 2D images & visualize decision boundary.
# 3) train NN with MNIST dataset
# ref: stanford CS23 source: http://cs231n.github.io/