Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Spencer Phillip Young spyoungtech

💭
I may be slow to respond.
View GitHub Profile
View voice_commander.py
from fuzzywuzzy import process
import keyboard
import speech_recognition as sr
r = sr.Recognizer()
m = sr.Microphone()
commands = {
"deploy landing gear": lambda: keyboard.write("l"),
"retract landing gear": lambda: keyboard.write("l"),
View awsexample.py
from __future__ import print_function
import boto3
import json
print('Loading function')
def respond(err, res=None):
return {
@spyoungtech
spyoungtech / data_dict.py
Created Mar 1, 2017
example api response
View data_dict.py
data = {'forecast': {'simpleforecast': {'forecastday': [{'avehumidity': 87,
'avewind': {'degrees': 161,
'dir': 'SSE',
'kph': 5,
'mph': 3},
'conditions': 'Clear',
'date': {'ampm': 'PM',
'day': 28,
'epoch': '1488326400',
'hour': 19,
View connectfour.py
from itertools import cycle
class Player(object):
def __init__(self, token, name):
self.token = token
self.name = name
class ConnectFour(object):
@spyoungtech
spyoungtech / simple_mjpeg_streamer_http_server
Created May 11, 2017 — forked from n3wtron/simple_mjpeg_streamer_http_server
Simple Python Motion Jpeg (mjpeg server) from webcam. Using: OpenCV,BaseHTTPServer
View simple_mjpeg_streamer_http_server
#!/usr/bin/python
'''
Author: Igor Maculan - n3wtron@gmail.com
A Simple mjpg stream http server
'''
import cv2
import Image
import threading
from BaseHTTPServer import BaseHTTPRequestHandler,HTTPServer
from SocketServer import ThreadingMixIn
View dbnonsense.py
"""Contains the User, Category, and Recipe classes"""
from types import SimpleNamespace
class DB(dict):
def query(self, **query_params):
results = []
for key, obj in self.items():
if all(getattr(obj, attr) == value for attr, value in query_params.items()):
@spyoungtech
spyoungtech / parse_dates.py
Last active Mar 29, 2018
Decorate a function to automatically convert specified arguments from strings to datetimes
View parse_dates.py
"""
Decorator to convert string arguments into datetimes automatically.
The decorated function will also still accept datetime objects per normal.
Useful for commandline tools, for example.
import dateutil.parser
import datetime
@parse_dates('start', 'some_date')
def days_until(some_date, start=None):
if start_time is None:
@spyoungtech
spyoungtech / appveyor_lambda_codedeploy.py
Created Jun 22, 2018
A lambda function intended to be triggered by S3 object creations made by Appveyor S3 deployments
View appveyor_lambda_codedeploy.py
import boto3
client = boto3.client('codedeploy')
def lambda_handler(event, context):
s3_event = event['Records'][0].get('s3')
bucket_name = s3_event['bucket']['name']
key = s3_event['object']['key']
etag = s3_event['object']['eTag']
View lovely_printer.py
import builtins
from textwrap import dedent
from unittest import mock
from contextlib import contextmanager
from itertools import cycle
_print = builtins.print
TEMPLATE_HEART = dedent('''
#### ####
# # # #
View gist:d6f759622765d88761146ed88fc9cf34
from selenium.webdriver.common.keys import Keys
import time
from browsermobproxy import Server
import ast
import urllib2 as UR
import os
import eyed3 as ED3
from django.utils.encoding import force_text
import re
from selenium import webdriver