Skip to content

Instantly share code, notes, and snippets.

@mscalora
mscalora / letsencrypt-update-lighttpd
Last active January 18, 2024 00:28
script to auto update letsencrypt certs for debian lighttpd installation (based on script by Danny Tuppeny)
#!/usr/bin/env bash
#
# Update letsencrypt on a lighttp installation
#
# if you installed letsencrypt in a non-standard location you
# can set the LEDIR env var before you run this script
#
# setup letsencrypt install directory
STDLEDIR=/opt/letsencrypt
@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 / cmpdirs.py
Created February 18, 2018 22:07
Based on Andriy Makukha's script from https://askubuntu.com/questions/421712/comparing-the-contents-of-two-directories/996529#996529 with a third parameter of a skip/exclude regular expression
#!/usr/bin/env python3
import os, sys, re
skip = re.compile(sys.argv[3] if len(sys.argv) > 3 else '$.')
def compare_dirs(d1: "old directory name", d2: "new directory name"):
def print_local(a, msg):
print('DIR ' if a[2] else 'FILE', a[1], msg)
# ensure validity
@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:

@mscalora
mscalora / ttd_dom_ready.js
Created April 3, 2021 11:35
simplified ttd_dom_ready - does not support (old) IE
(function (){
window.ttd_dom_ready = window.ttd_dom_ready || function (cb) {
if (document.readyState === "complete" ||
(document.readyState !== "loading" && !document.documentElement.doScroll)) {
cb();
} else {
let mcb = () => {
document.removeEventListener("DOMContentLoaded", mcb);
cb();
};
@mscalora
mscalora / counter.html
Last active March 15, 2021 13:38
Perfect JS Counter
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Counter</title>
<style>
html {
height: 100%;
margin: 0;
padding: 0;
@mscalora
mscalora / geti
Created February 18, 2018 00:01
Case-insensitive get like lodash's _.get()
function geti (value, prop) {
if (_.isPlainObject(value)) {
if (_.isString(prop) && prop !== '') {
return geti(value, prop.split('.'));
} else if (_.isArray(prop) && prop.length) {
const key = _.toLower(prop.shift()),
val = Object.keys(value).reduce(function (a, k) {
if (a !== undefined) {
return a;
}