Skip to content

Instantly share code, notes, and snippets.

@ephsmith
ephsmith / aeris_response.py
Last active May 26, 2022
Coding 1 - Cached Request Response JSON for dictionary examples
View aeris_response.py
# aeris_response.py
# response_dict is the dictionary returned from a requests.Response.json() method
# call.
#
# Details regarding the response fields can be found at:
# https://www.aerisweather.com/support/docs/api/reference/endpoints/observations/#response
response_dict = {
"success": True,
"error": None,
@ephsmith
ephsmith / trans.py
Created Aug 1, 2020
Transpose a 2D Python List
View trans.py
m = [[1,2,3],[4,5,6],[7,8,9]]
m_t = list(map(list,zip(*m)))
# m_t is now -> [[1,4,7], [2,5,8], [3,6,9]]
@ephsmith
ephsmith / linecodes.py
Created Sep 30, 2019
Sample plot for line codes using MatPlotLib.
View linecodes.py
"""
linecodes.py
Credit: StackOverflow via Bas Swinckels
URL: https://stackoverflow.com/a/20037521/845744
"""
import matplotlib.pyplot as plt
import numpy as np
def my_lines(ax, pos, *args, **kwargs):
if ax == 'x':
@ephsmith
ephsmith / Makefile
Created Feb 7, 2019 — forked from kristopherjohnson/Makefile
Makefile that uses Pandoc to generate HTML, PDF, DOCX, etc. from Markdown source files
View Makefile
# Makefile
#
# Converts Markdown to other formats (HTML, PDF, DOCX, RTF, ODT, EPUB) using Pandoc
# <http://johnmacfarlane.net/pandoc/>
#
# Run "make" (or "make all") to convert to all other formats
#
# Run "make clean" to delete converted files
# Convert all files in this directory that have a .md suffix
@ephsmith
ephsmith / subtract_params.py
Created Oct 3, 2018
Subtract values for params in one file from another and save the result to a new file.
View subtract_params.py
#!/usr/bin/env python3
import argparse
def read(f):
"""Reads the contents of param=value file and returns a dict"""
d = {}
with open(f,'r') as fin:
for item in fin.readlines():
@ephsmith
ephsmith / add-row-handler.js
Last active Jul 2, 2018
Add click events to all rows in an HTML table
View add-row-handler.js
/* See: http://jsfiddle.net/oh16h7cj/ */
function addRowHandlers() {
var table = document.getElementById("tableId");
var rows = table.getElementsByTagName("tr");
for (i = 0; i < rows.length; i++) {
var currentRow = table.rows[i];
var createClickHandler =
function(row)
{
return function() {
@ephsmith
ephsmith / org-airmail.el
Last active Sep 2, 2021
org-airmail.el adds an org-hyperlink handler for Airmail email URLs
View org-airmail.el
;;; org-airmail.el - Support for links to Airmail 3 messages in Org
(require 'org)
(org-add-link-type "airmail" 'org-airmail-open)
(defun org-airmail-open (url)
"Visit the Airmail message referenced by URL.
URL should be a vaid Airmail message url retrieved from Airmail with
'Copy Message Link'."
@ephsmith
ephsmith / GIF-Screencast-OSX.md
Created May 16, 2018 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF
View GIF-Screencast-OSX.md

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@ephsmith
ephsmith / ussensor.py
Created May 3, 2018
USSensor is a simple class for reading measurements from the HC-SR04 on the RaspberryPi.
View ussensor.py
# -*- coding: utf-8 -*-
# Author: Forrest Smith
import RPi.GPIO as io
import time
class USSensor():
'''Simple class for interfacing an HC-SR04'''
def __init__(self, echo=None, trigger=None):
@ephsmith
ephsmith / README.md
Created May 1, 2018 — forked from xavriley/README.md
Original NES Mario Theme for Sonic Pi
View README.md

Making Chiptune Music using Sonic Pi v2.0

Warning: this might not work on a RaspberryPi yet

I was curious about making retro gaming sounds using Sonic Pi. A couple of months and a lot of Googling later, here's the original Mario Bros theme as it was heard on the NES console.

I'm (just about) old enough to remember rushing home from school to play this game at Philip Boucher's house, sitting cross-legged in front of the TV till my feet got pins and needles. Working out how to recreate it for Sonic Pi was a lot of fun!

Getting the sounds of the NES chip