Skip to content

Instantly share code, notes, and snippets.

View hammertoe's full-sized avatar

Matt Hamilton hammertoe

View GitHub Profile
app.get('/tweets',
require('connect-ensure-login').ensureLoggedIn(),
function(req, res) {
// Create client instance to connect to Twitter
// We pass in the access token we got from the OAuth process
var T = new Twit({
consumer_key: process.env['TWITTER_CONSUMER_KEY'],
consumer_secret: process.env['TWITTER_CONSUMER_SECRET'],
access_token: req.user.token,
app.get('/tweets',
require('connect-ensure-login').ensureLoggedIn(),
function(req, res) {
var T = new Twit({
consumer_key: process.env['TWITTER_CONSUMER_KEY'],
consumer_secret: process.env['TWITTER_CONSUMER_SECRET'],
access_token: req.user.token,
access_token_secret: req.user.tokenSecret,
timeout_ms: 60*1000, // optional HTTP request timeout to apply to all requests.
require('dotenv').config();
var express = require('express');
var passport = require('passport');
var Strategy = require('passport-twitter').Strategy;
var Twit = require('twit');
var axios = require('axios');
// Tone analyser creds
tone_url = process.env['TONE_URL'],
import json
import os
import requests
import librosa
import io
import numpy as np
SAMPLE_RATE = 44100
# function to measure two waveforms with one offset by a certian amount

Using a docker image for a cloud function

% ic fn action create calculate_alignment calculate_alignment.py --docker hammertoe/librosa_ml:latest

Invoking the function

% ic fn action invoke calculate_alignment -p referece leader.wav -p part sarah.wav
@hammertoe
hammertoe / functions1.sh
Created May 28, 2020 18:53
Example of some IBM Cloud Function commands
# A simple hello world function
% cat hello.py
def main(args):
name = args.get("name", "unknown")
return {"message": f"Hello {name}!"}
# create an action
% ic fn action create hello hello.py
ok: created action hello
@hammertoe
hammertoe / coil_fetcher.py
Created February 6, 2020 15:58
Script to fetch content from a Coil post
import argparse
import requests
import json
from urllib.parse import urlparse
parser = argparse.ArgumentParser(description="Fetch content from a coil post")
parser.add_argument("url", help="URL to fetch from Coil")
args = parser.parse_args()
url_parts = urlparse(args.url)
@hammertoe
hammertoe / gist:981c8880a523fc04c980a8d2c89c0bf9
Created January 21, 2020 16:15
Output of running align_faces.py
(pytorch2) (base) Matts-iMac:facial_alignment matt$ ls input/
IMG_0720.JPG IMG_1784.JPG IMG_2697_2.JPG IMG_3251.JPG IMG_5523_2.JPG IMG_7489.JPG IMG_7836.JPG
IMG_1148.JPG IMG_1908.JPG IMG_2918.JPG IMG_3651.JPG IMG_7480.JPG IMG_7490.JPG IMG_9029.JPG
IMG_1215.JPG IMG_1910.JPG IMG_3028.JPG IMG_3833.JPG IMG_7482.JPG IMG_7630.JPG IMG_9622.JPG
IMG_1574.JPG IMG_2041.JPG IMG_3250.JPG IMG_5520_2.JPG IMG_7485.JPG IMG_7633.JPG IMG_9919.JPG
(pytorch2) (base) Matts-iMac:facial_alignment matt$ python align_faces.py --shape-predictor shape_predictor_68_face_landmarks.dat --images input/*.JPG
processing: input/IMG_0720.JPG
processing: input/IMG_1148.JPG
processing: input/IMG_1215.JPG
processing: input/IMG_1574.JPG
@hammertoe
hammertoe / align_faces.py
Last active January 21, 2020 16:13
align_faces.py
# USAGE
# python align_faces.py --shape-predictor shape_predictor_68_face_landmarks.dat input/example_*.jpg
# import the necessary packages
from imutils.face_utils import FaceAligner
from imutils.face_utils import rect_to_bb
import argparse
import imutils
import dlib
import cv2
input output
16 1
17 1
18 1
19 1
20 1
21 0
22 0
23 0