Skip to content

Instantly share code, notes, and snippets.

View LukeGary462's full-sized avatar

Luke Gary LukeGary462

  • Rye Effects Research
  • Philadelphia, PA
View GitHub Profile
@LukeGary462
LukeGary462 / GenerateHeaderBlock.py
Last active June 2, 2020 19:46
Sublime Plugin, Create Document Title/Header Block
#!/usr/bin/env python
# python 3
# pylint: disable=
## @file: GenerateDoxyFileBlockBiomeme.py
# @name: "Luke Gary"
# @company: "Biomeme, Inc"
# @date: 2020/6/2
####################################################################################################
# @copyright
# Copyright 2020 "Biomeme, Inc" as an unpublished work.
@LukeGary462
LukeGary462 / CDriverSectionTemplate.py
Last active September 29, 2016 23:12
Generate C File Template
## @file: CDriverSectionTemplate.py
# @par:
# @author:
# @company:
# @date: 2016/9/29
# @Created Time: Mon Sep 19 22:35:32 2016
# @Last Modified Time: Thu Sep 29 18:29:37 2016
# @brief:
# @verbatim:
# @note I like the key binding [ctrl+shift+alt+q]... :)
@LukeGary462
LukeGary462 / bokeh-csv-export-button.py
Created September 10, 2019 16:15
Export CSV of graph in bokeh. from stack overflow
#https://stackoverflow.com/questions/31824124/is-there-a-way-to-save-bokeh-data-table-content
from bokeh.models import ColumnDataSource, CustomJS
from bokeh.models.widgets import Button
from bokeh.io import show
source = ColumnDataSource({'list1':[0,1,2,3],'list2':[4,5,6,7]})
button = Button(label="Download", button_type="success")
javaScript="""
@LukeGary462
LukeGary462 / ewma.py
Created September 24, 2019 15:01
python RC filter
#!/usr/bin/env python
# python 3
# @file: EWMA.py
# @par:
# @author: Luke Gary
# @company: Biomeme, Inc
# @date: 2018/8/15
# @brief:
# @verbatim:
@LukeGary462
LukeGary462 / relationship-test.py
Last active June 2, 2020 20:19
Simple relationships in sqlalchemy and postgresql
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.engine import create_engine
from sqlalchemy.orm.session import sessionmaker, Session
from sqlalchemy import Column, DateTime, String, Integer, func, Float, Boolean, ForeignKey
from sqlalchemy.dialects.postgresql import JSON # postgres specific JSON type for better queries (dont know how yet)
from sqlalchemy.orm import relationship, backref, validates
_base = declarative_base()
# derived table classes go after _base is constructed, table classes are also children of _base
class ParentRecord(_base):
@LukeGary462
LukeGary462 / db-file-test.py
Last active June 9, 2020 21:29
connect to sqlite db file and query with pandas or sqlalchemy
from sqlalchemy import create_engine, MetaData, Table
from sqlalchemy.orm import mapper, sessionmaker
import pandas as pd
import pprint as pp
db = 'results_2020-06-01.db'
engine = create_engine(f'sqlite:///{db}', echo=False)
session = sessionmaker(bind=engine)()
# with column filter
@LukeGary462
LukeGary462 / flask_restful_test.py
Created June 11, 2020 22:34
simple python rest api using flask
#!/usr/bin/env python
# python 3
# pylint: disable=
## @file: flask-restful-test.py
# @name: "Luke Gary"
# @company: ""
# @date: 2020/6/11
####################################################################################################
# @copyright
# Copyright 2020 "" as an unpublished work.
@LukeGary462
LukeGary462 / general.py
Last active July 24, 2020 18:13
General Python Patterns
######## CUSTOM EXCEPTION ########
class Test(Exception):
def __init__(self, *args):
print(*args)
super().__init__(*args)
>>> raise Test()
#Traceback (most recent call last):
# File "<stdin>", line 1, in <module>
#__main__.Test
@LukeGary462
LukeGary462 / jira_test.py
Last active May 20, 2023 18:38
Submit Jira Issue Via Python
from os import environ
from jira import JIRA
import pprint as pp
# need to create an API Token via Atlassian Account Mgmt
# store as env variable on machine
username = '<user@email_url.gfy>'
api_token = environ.get('JIRA_API_TOKEN')
options = {'server': 'https://<company>.atlassian.net'}
# actually connect via https and API Token based authentication
jira = JIRA(options, basic_auth=(user, api_token))
@LukeGary462
LukeGary462 / mixins.py
Last active July 7, 2020 15:13
SQL Alchemy mixins I found useful for json serialization, generic queries and other boiler plate shit
from sqlalchemy.orm.session import Session
class QueryBuilder:
"""
This class describes a query builer.
"""
q_debug = False
def query_from_dict(self, db_session: Session, **q_params):
"""