Skip to content

Instantly share code, notes, and snippets.

View lucasnad27's full-sized avatar

Lucas Culbertson lucasnad27

View GitHub Profile
@lucasnad27
lucasnad27 / typeform-us-states-list.txt
Created February 6, 2022 18:06
Formatting needed to provide a dropdown of all 50 US States in Typeform
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
District Of Columbia
Florida
@lucasnad27
lucasnad27 / INSTRUCTIONS.md
Last active October 31, 2021 00:40
Setting up a python environment in Mac OSX

Purpose

An opinionated setup for python on Mac OSX. Opinions subject to change as new tooling gains traction. I've used this setup for the past ~5 years.

Prerequisites

Understanding of a .bashrc or .zshrc file. Why? There are commands that need to be ran every time you open a terminal window. If you don't have a strong opinion about your own "rc" setup file, install ohmyzsh. This will give you some sane defaults for your terminal, makes it clear where to do things like modify your $PATH env var (needed for a good python or node setup), and adds some nice extras like displaying the version of node you are currently using. The tldr; for installing ohmyzsh is below, but you'll want to read through the docs to understand how to utilize it...

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

@lucasnad27
lucasnad27 / portfolio_example_1.py
Created September 8, 2021 20:09
Implementing class structure with a lot of business logic
"""
Portfolio implementation
"""
class Portfolio:
"""Used for backtesting strategies and taking actions through time."""
def __init__(self, **kwargs):
self.capital_allocation = capital_allocation
@lucasnad27
lucasnad27 / portfolio_example_2.py
Last active September 8, 2021 20:09
Implementing class structure with minimal logic
"""
Portfolio implementation
"""
def eligible_for_rebalance(trading_day: Arrow) -> bool:
"""Decides if a given trading day should trigger a rebalance and returns a boolean."""
return is_eligible
@lucasnad27
lucasnad27 / settings.json
Created July 26, 2021 14:35
Custom docker keybindings for VSpaceCode
{
"vspacecode.bindingOverrides": [
{
"keys": "d",
"name": "Docker...",
"type": "bindings",
"bindings": [
{
"key": "c",
"name": "Containers",
;; -*- mode: emacs-lisp -*-
;; This file is loaded by Spacemacs at startup.
;; It must be stored in your home directory.
(defun dotspacemacs/layers ()
"Configuration Layers declaration.
You should not put any user code in this function besides modifying the variable
values."
(setq-default
;; Base distribution to use. This is a layer contained in the directory
;; `+distribution'. For now available distributions are `spacemacs-base'
from enum import Enum
import rq
from redis import Redis
import settings
class Priority(Enum):
low = 'low'
default = 'default'
import csv
from pathlib import Path
def get_headers():
# total hack
with open('File1.txt') as f:
headers = []
for line in f:
if ':' not in line:
{
"build_systems":
[
{
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"name": "Anaconda Python Builder",
"selector": "source.python",
"shell_cmd": "\"/Users/luke/.pyenv/versions/kris-kringle/bin/python\" -u \"$file\""
}
],
@lucasnad27
lucasnad27 / beautiful_idiomatic_python.md
Last active November 27, 2022 13:39 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides and pycon US 2015 video

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]: