Skip to content

Instantly share code, notes, and snippets.

Mark Hurley markph0204

  • Atlanta, GA
Block or report user

Report or block markph0204

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@markph0204
markph0204 / pygame_mac_latest.sh
Last active Dec 24, 2018
Python 3 + VirtualEnv + HighSierra + Pygame 1.9.x (Dev-Dec21) + Xcode 10.1 + Homebrew
View pygame_mac_latest.sh
# Python 3 + VirtualEnv + HighSierra + Pygame 1.9.x (Dev-Dec21) + Xcode 10.1 + Homebrew
# https://www.pygame.org/wiki/MacCompile
# 1. Install <a href="https://brew.sh">Homebrew</a> -- instructions found here.
# 2. Install XQuartz:
brew install Caskroom/cask/xquartz
# 3. Install Python 3.7.x
brew install python3
@markph0204
markph0204 / gist:d2999b0b947b49bc0c0b5f2c73e2437c
Last active Aug 1, 2018
Creality CR-10S Print Head Clean GCode
View gist:d2999b0b947b49bc0c0b5f2c73e2437c
; Pefix G-Code for Creality CR-10 by www.DIY3DTech.com to clean nozzle
; Place as start G-Code in Slicer
; Use of this code is at your own risk (no warranties made or implied)
;
M117 Clean ; Indicate nozzle clean in progress on LCD
M109 S200 ; Uncomment to set your own temp [run warmer to clean out nozzle]
M107 ; Turn layer fan off
G21 ; Set to metric [change to G20 if you want Imperial]
G90 ; Force coordinates to be absolute relative to the origin
G28 ; Home X/Y/Z axis
View py37-plugins-example
from importlib import import_module
from importlib import resources
PLUGINS = dict()
def register_plugin(func):
"""Decorator to register plug-ins"""
name = func.__name__
PLUGINS[name] = func
return func
@markph0204
markph0204 / pytest_monkey_open.py
Created Jun 14, 2018
Pytest monkey patching builtins open
View pytest_monkey_open.py
import builtins
import pytest
from io import StringIO
import yaml
TEST_CONFIG = """
environment: prod
"""
View direnv+pycharm.sh
# enable direnv for python
# this will enable the commandline support as well as support pycharm
# 1 install direnv (Homebrew / pip)
# 2 edit your .bashrc, .bash_profile or .bash_aliases
function venv-here {
# you could just use 'layout python' here for 2.7.x
echo "layout python3" > .envrc
echo "ln -s .direnv/\$(basename \$VIRTUAL_ENV)/ .env" >> .envrc
}
@markph0204
markph0204 / jupyter-notebook-starter.py
Created Dec 20, 2017
I normally use notebooks in a `notebooks` sub path in my project repository and often need to import modules that are apart of that project.
View jupyter-notebook-starter.py
import sys
sys.path.append("../") # go to parent dir
from customFunctions import *
# Then, to affect changes in customFunctions.py,
%load_ext autoreload
%autoreload 2
#ref: https://stackoverflow.com/a/42727538/23991
@markph0204
markph0204 / app_handle_errors.py
Last active Dec 14, 2017
Handling invalid requests with Flask - Implementing API Exceptions
View app_handle_errors.py
# http://flask.pocoo.org/docs/0.12/patterns/apierrors/
from flask import jsonify
class InvalidUsage(Exception):
status_code = 400
def __init__(self, message, status_code=None, payload=None):
Exception.__init__(self)
View app_list_routes.py
from collections import defaultdict
@app.cli.command("list_routes")
def list_routes():
"""
Roll through Flask's URL rules and print them out
Thank you to Jonathan Tushman
And Thank you to Roger Pence
Sourced http://flask.pocoo.org/snippets/117/ "Helper to list routes (like Rail's rake routes)"
@markph0204
markph0204 / aws-bash-aliases
Created Nov 20, 2017
AWS profile management
View aws-bash-aliases
# create new profile, prior step
# aws configure --profile=name123
# use profile with tools
alias aws_name123='export AWS_PROFILE=name123'
View async_submit_wait.py
import requests
from time import sleep
import os
import asyncio
import aiohttp
async def submit_and_wait():
print('Submitting request')
request_url = '<base url>/create_request'
You can’t perform that action at this time.