Skip to content

Instantly share code, notes, and snippets.

@mscalora
mscalora / micro_time.h
Last active September 15, 2025 02:17
A very small library of north american centric date/time utilities
#define ATLANTIC_TZ -5
#define EASTERN_TZ -5
#define CENTRAL_TZ -6
#define MOUNTAIN_TZ -7
#define PACIFIC_TZ -8
#define ALASKA_TZ -9
#define HAWAII_TZ -11
struct DateTime {
@mscalora
mscalora / micro_ntp.h
Created September 15, 2025 02:13
A very small NTP client
#include <vector>
#include <functional>
const char* poolNTPServerName = "pool.ntp.org";
const unsigned long seventyYears = 2208988800UL;
class MicroNTP {
public:
static const int NTP_PACKET_SIZE = 48; // NTP time stamp is in the first 48 bytes of the message
@mscalora
mscalora / get.js
Last active September 9, 2025 16:54
Client-side js helper function for GETing
function get(url, data, successCallback, errorCallback, responseType) {
const urlObj = new URL(url);
const params = urlObj.searchParams;
Object.entries(data||{}).forEach(([key, value]) => params.set(key, value));
url = urlObj.toString();
fetch(url)
.then(response => {
if (!response.ok) { throw new Error(response.status); }
const contentType = response.headers.get('content-type');
const isJson = responseType === 'json' || (responseType === 'auto' && contentType && contentType.includes('application/json'));
@mscalora
mscalora / post.js
Created September 9, 2025 15:00
Client-side js helper function for POSTing
function post(url, data, successCallback, errorCallback, responseType) {
fetch(url, {
method: 'POST',
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
body: new URLSearchParams(data),
})
.then(response => {
if (!response.ok) { throw new Error(response.status); }
const contentType = response.headers.get('content-type');
const isJson = responseType === 'json' || (responseType === 'auto' && contentType && contentType.includes('application/json'))
@mscalora
mscalora / README.md
Last active May 24, 2025 14:16
This set of scripts/files is used to link blink cameras to PrusaConnect.

This set of scripts/files is used to link blink cameras to PrusaConnect.

This is rough, you need a working knowledge of python, requirements.txt, venv to use.

The cron job has worked reliably for me for several years.

Generating the blink.creds file is an exercise left to the reader, study the blinkpy documentation.

@mscalora
mscalora / overrides.ini
Created November 24, 2023 16:53
Prusa Slicer Defaults Test INI
[print:*common*]
perimeters = 4
skirts = 0
first_layer_speed = 18
[print:*MK4*]
first_layer_speed = 19

Prusa Slicer Default Print Settings

Description

I hate skirts, I find them to be a big waste of time, a small waste of filament with little or no value. The purge line in the preamble is plenty for my printer. I got tired of turning them off manually every time I used a built-in print setting. By editing this file you can change the built-ins although you have to do this again every time a new "settings update" is applied. In the future I might automate the process with a file watcher mechanism that will run every night or something. I also like to print with at least 3 parimeters and I slow down the first layer by 10% from the usual 20.

Edit

@mscalora
mscalora / server.py
Created November 23, 2022 14:34
Python 3 HTTP Server Example
from http.server import BaseHTTPRequestHandler, HTTPServer
from urllib import parse
import json
def run_server(port):
class Server(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
#!/usr/bin/env node
# credit to Lenny Domnitser for the logic of this tool, see: https://domnit.org/blog/2007/07/fix-encoding.html
#
# This tool will fix encoding errors in text files. In my case a sql backup file contained latin1 char
# sequences that appeared like: The “magic” of ’THings’
#
# Usage: fix_encodings.js <in-file> [<out-file>]
#

Keybase proof

I hereby claim:

  • I am mscalora on github.
  • I am mscalora (https://keybase.io/mscalora) on keybase.
  • I have a public key ASBipYrZDCrdzGvlafxUvRxpYnb_7D_AWslP7efmBgH5vAo

To claim this, I am signing this object: