Skip to content

Instantly share code, notes, and snippets.

@benrules2
benrules2 / queue_service.py
Last active October 8, 2017 18:31
Queue Service
import boto3
access_key = "YOUR_ACCESS_KEY"
access_secret = "YOUR_ACCCESS_SECRET"
region ="YOUR_REGION"
queue_url = "YOUR_QUEUE_URL"
def post_message(client, message_body, url):
response = client.send_message(QueueUrl = url, MessageBody= message_body)
import boto3
access_key = "YOUR_ACCESS_KEY"
access_secret = "YOUR_ACCCESS_SECRET"
region ="YOUR_REGION"
queue_url = "YOUR_QUEUE_URL"
def build_speechlet_response(title, output, reprompt_text, should_end_session):
return {
'outputSpeech': {
@benrules2
benrules2 / check_queue.py
Last active October 13, 2017 03:14
Read Queue on Target Platform
import boto3
import os
import time
access_key = "ACCESS_KEY"
access_secret = "ACCESS_SECRET"
region = "REGION"
queue_url = "QUEUE_URL"
def pop_message(client, url):
@benrules2
benrules2 / tvoff.sh
Created January 25, 2017 04:47
Scripts to start and stop smart mirror
#!/bin/bash
tvservice -o
@benrules2
benrules2 / orbits.py
Last active February 11, 2017 13:34
RK4 Python
def calculate_single_body_acceleration(self, body_index):
G_const = 6.67408e-11 #m3 kg-1 s-2
acceleration = point(0,0,0)
target_body = self.bodies[body_index]
k1 = point (0,0,0)
k2 = point (0,0,0)
k3 = point (0,0,0)
k4 = point (0,0,0)
tmp_loc = point (0,0,0)
@benrules2
benrules2 / orbits.py
Created February 10, 2017 23:19
Python RK4 orbits
import math
import random
import matplotlib.pyplot as plot
from mpl_toolkits.mplot3d import Axes3D
class point:
def __init__(self, x,y,z):
self.x = x
self.y = y
self.z = z
@benrules2
benrules2 / StarTracking.ino
Created June 6, 2017 11:43
Arduino code for star tracking
// Controls a threaded stepper motor to open levered board at same rate the earth spins
// for astrophotograph.
byte directionPin = 3;
byte stepPin = 2;
byte ledPin = 13;
float adjacent = 0.24;
float earth_rads_per_s = 0.00007272205;
@benrules2
benrules2 / album_counter.py
Last active August 21, 2017 02:56
Main script file for counting duplicate sets of words in album lyrics
client_id = 'Your Genius Client ID'
client_secret = 'Your Genius Client Secret'
client_access_token = 'Your Genius Access Token'
import plot_albums
import string
import requests
import nltk
from sys import argv
from bs4 import BeautifulSoup
@benrules2
benrules2 / plot_albums.py
Created August 19, 2017 14:37
Script to automatically generate a bar graph of album word duplicate rates
import matplotlib.pyplot as plt
from matplotlib import rcParams
def plot_album_ngrams(albums, artist):
pos = list(range(len(albums)))
width = 0.25
rcParams.update({'figure.autolayout': True})
fig, ax = plt.subplots(figsize=(12,6))
# External module imp
import RPi.GPIO as GPIO
import datetime
import time
init = False
GPIO.setmode(GPIO.BOARD) # Broadcom pin-numbering scheme
def get_last_watered():