Skip to content

Instantly share code, notes, and snippets.

@joshmurr
joshmurr / printer-poll.py
Created April 3, 2025 21:57
Printer-Hub Polling
#!/home/joshmurr/Documents/Stuff/printer-hub/venv/bin python3
from datetime import datetime, timedelta
import requests
from escpos.printer import Network
def load_last_check_time(timestamp_file):
try:
with open(timestamp_file, "r") as f:
@joshmurr
joshmurr / AsyncListInput.jsx
Last active November 20, 2023 15:54
Custom Sanity Schema and Component
/* https://www.sanity.io/answers/how-to-fetch-data-from-an-external-api-for-a-custom-component-in-sanity-io- */
import { useState, useEffect } from 'react'
export const AsyncListInput = (props) => {
const [listItems, setListItems] = useState([])
const { schemaType, renderDefault } = props
const { options } = schemaType
const { url, formatResponse } = options

Preparing Hubspot for API form integration

If you've been using Hubspot for a little while you may have to migrate the existing account details to what is called a Private App. The previous way of way of working with API keys has been deprecated in favour of Private App which offer a bit more security.

If you have never dealt with API keys before it's not a problem, should just be a case of creating a new Private App and giving it access to the correct data already on your Hubspot account. You give it via the relevant 'scopes', such as crm.objects.contacts, which is likely a scope you have been using if you have been collecting client/customer contact information in the Contacts table.

There is a good short video and more information on this page about how to carry out the migration (it is a short process). This is the view where you choose the scopes the Private App will have access to. This is the

@joshmurr
joshmurr / words+pixels-email-signature.md
Last active July 12, 2023 14:12
How to: Words+Pixels Email Signature

Words+Pixels Email Signature

Screenshot

A custom HTML signature should be simple but it turns out it's not. Email clients can work within a browser, but have their own standards which conflict with the comfy modern standards of HTML5 browsers use. Email clients use HTML and CSS as if it were 1999 so there are certain limitations. The email signature is as close to the design as possible given those limitations and unfortunately will likely appear differently in different email clients (GMail, Apple Mail, Outlook, etc.).

Unfortunately the underlined links are one thing I haven't been able to override. It seems to be a style that is insisted on being applied.. by GMail at least.

That said, updating your email signature should be fairly simple. Below are the instructions for GMail, I think it will be similar for whatever email service you use.

@joshmurr
joshmurr / inactivity.js
Created March 8, 2023 11:49
Javascript Inactivity Timer
const inactivityTime = function () {
/* Declare timer */
let time = 0
/* Reset the timer under the following conditions */
window.onload = resetTimer
document.onmousemove = resetTimer
function idle() {
MOUSE.hover = 0
}
function resetTimer() {
@joshmurr
joshmurr / functions.ts
Created July 19, 2022 10:08
Useful JS Functions
/* Inigo Quilez
* cosine based palette, 4 vec3 params
* vec3 palette( in float t, in vec3 a, in vec3 b, in vec3 c, in vec3 d ) {
* return a + b*cos( 6.28318*(c*t+d) );
* }
*/
const colorPalette = (t: number, a: color, b: color, c: color, d: color) => {
const _r = a[0] + b[0] * Math.cos(6.28318 * (c[0] * t + d[0]))
const _g = a[1] + b[1] * Math.cos(6.28318 * (c[1] * t + d[1]))
I am attesting that this GitHub handle joshmurr is linked to the Tezos account tz1MHV1VChMRpW4gkahmM4J5zrRkTqCNGBga for tzprofiles
sig:edsigtwqv95AeccNMzs6BY42aMpVcuyssNccq8dpBeu4zceeyrJZkwveTfx514BPg245G53fNdK3Ch59JAMZZgcG7gPuhXR13y4
@joshmurr
joshmurr / projection_training_loop.py
Created November 14, 2021 15:12
Training loop for 'projecting' into GAN latent space. Used on a simple DCGAN.
def find_closest_vector(initial, target_image, num_optimization_steps):
images = []
vector = initial.detach().clone().requires_grad_(True)
optimizer = torch.optim.Adam([vector], lr=0.1)
loss_fn = torch.nn.MSELoss(reduction='sum')
for step in range(num_optimization_steps):
image = netG(vector)
@joshmurr
joshmurr / mat.js
Created June 14, 2021 10:31
2-Layer Neural Network
/* Matrix Functions
*
* These function operate on vanilla 1D or 2D arrays.
* This could be extended to a matrix class which might
* allow for a better API as chaining operations in this
* form gets pretty ugly and unmanageable pretty quickly.
*/
export function matmul(a, b) {
/* Matrix Multiplication */