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 / omeganumworks.py
Last active November 17, 2021 19:27
Omega - Numworks
'''conversion functions
'''
from math import (sqrt, pi, floor, log10)
def powerise10(value):
""" Returns value as a * 10 ^ b with 0<= a <10
"""
if value == 0: return 0 , 0
_neg = value <0
@LukeGary462
LukeGary462 / max14871.hpp
Created March 19, 2021 22:21
MAX14871 Motor Driver Arduino Class
#include <Arduino.h>
class Max14871 {
public:
Max14871(uint8_t pwm_pin, uint8_t dir_pin);
void init(unsigned int pwm_freq);
void set_duty_cycle(float duty);
void set_speed(float speed);
void enable(void);
void disable(void);
@LukeGary462
LukeGary462 / iir-filters.hpp
Last active March 19, 2021 21:41
Simple C++ IIR Filtering classes
/**
* @file: iir-filters.hpp
* @name: Luke Gary
* @company: <company>
* @date: 2021/3/19
********************************************************************************
* @copyright
* Copyright 2020 <company> as an unpublished work.
* All Rights Reserved.
*
@LukeGary462
LukeGary462 / .pylint_rc
Created February 26, 2021 19:05
pylint rc
[MASTER]
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=PyQt5
fail-under=9.5
ignore=CVS
ignore-patterns=
jobs=0 # let pylint use as many cores as it wants
@LukeGary462
LukeGary462 / GenerateCommentBlock.py
Last active November 20, 2023 16:10
Comment Block
#!/usr/bin/env python
# python 3
## @file: GenerateDoxyFileBlock.py
# @name: Luke Gary
# @company: <company>
# @date: 2020/2/20
####################################################################################################
# @copyright
# Copyright <year> <company> as an unpublished work.
# All Rights Reserved.
@LukeGary462
LukeGary462 / CodeTemplate.py
Created August 21, 2020 21:26
Sublime Snippet to make code templates
#!/usr/bin/env python
# python 3
# pylint: disable=
## @file: CodeTemplate.py
# @name: {author name}
# @company: {company name}
# @date: 2020/8/21
####################################################################################################
# @copyright
# Copyright 2020 {company name} as an unpublished work.
@LukeGary462
LukeGary462 / datamatrix-test.py
Last active July 28, 2020 21:21
Make Datamatrix Code with python
from pylibdmtx.pylibdmtx import encode
from PIL import Image
import sys
encoded = encode(sys.argv[1].encode('utf-8'))
img = Image.frombytes('RGB', (encoded.width, encoded.height), encoded.pixels)
img.save(sys.argv[2])
# for inserting to dymo template
@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):
"""
@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 / 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