Skip to content

Instantly share code, notes, and snippets.

View hammertoe's full-sized avatar

Matt Hamilton hammertoe

View GitHub Profile
try:
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
except:
from http.server import BaseHTTPRequestHandler, HTTPServer
import socket
class NumberServer(BaseHTTPRequestHandler):
def _set_headers(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
@hammertoe
hammertoe / valstream.js
Last active September 23, 2018 17:47
A script to view the validation message stream on the XRP Ledger
// npm i ripple-lib
// node valstream.js
const RippleAPI = require("ripple-lib").RippleAPI;
var api = new RippleAPI({ server: "wss://s1.ripple.com" });
api.connect().then(() => {
api.connection.on('validationReceived', (event) => {
console.log(JSON.stringify(event, null, 2))
@hammertoe
hammertoe / gist:47d46d92bcc0eb408eb9b3d06fd59a23
Created February 24, 2019 19:58
Output of some balancing runs
### I have just deposited some more XRP to what was a balanced portfolio, not is it is unbalanced
(crypto_balancer) Matts-iMac:crypto_balancer matt$ crypto_balancer binance
Connected to exchange: Binance
Balances:
XRP 4468.878282
BTC 0.01609
ETH 0.42
BNB 3.04830514
USDT 33.602051
def fft(inp):
inp = tuple(inp)
total = ""
for i, c in enumerate(inp, 1):
pat = [ [item] * i for item in base_pat ]
pat = [item for sublist in pat for item in sublist]
l1 = len(pat)
l2 = len(inp)
pat = pat * math.ceil((l2+1)/l1)
pat = pat[1:l2+1]
@hammertoe
hammertoe / heater_control.py
Last active January 5, 2020 14:49
Simple temperate control function
def heater_control(temperature):
if temperature > 20:
return 0
else:
return 1
input output
16 1
17 1
18 1
19 1
20 1
21 0
22 0
23 0
@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
@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 / 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 / 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