Skip to content

Instantly share code, notes, and snippets.

@ggorlen
ggorlen / til.md
Last active April 30, 2024 23:33
Today I learned

Random tidbits

ERR_CERT_DATE_INVALID on DigitalOcean droplet with GoDaddy-issued domain

Previously working, abruptly not with the titular error. I tried certbot -q renew --nginx but ran into an error that the .pem files weren't found. I noticed in /etc/nginx/sites-available/my-site that there was a number of incorrect paths to /etc/letsencrypt/live/my-domain.com/ (for example, ssl_certificate /etc/letsencrypt/live/wrong-domain.com/fullchain.pem). nginx -t failed to validate the path. After fixing the config paths to point to the correct domain and re-running certbot, the certificate was renewed and nginx -t ran clean.

I'm not sure how the bad links got into the nginx config in the first place, though, or why this config only suddenly started to matter, since the site worked fine for over a year without intervention (other than a domain name renewal nearly 90 days ago, but not quite--might be related).

I may need a cron job to auto-renew.

@ggorlen
ggorlen / scrape-sfpl-hours.js
Created January 5, 2024 20:49
Scrape SFPL hours
// copy and paste url into browser and run code in console
// probably use puppeteer rather than fetch if you want to automate this
// (pagination doesn't seem to work with requests, maybe user agent? dunno why)
var url =
"https://sfpl.org/locations/#!/filters?sort_by=weight&sort_order=ASC&items_per_page=50";
var hours = [...document.querySelectorAll(".location--teaser--inner")]
.map(e => ({
name: e.querySelector(".location__title").textContent.trim(),
hours: [...e.querySelectorAll(".office-hours__item")].map(
e => e.textContent.replace(/\s+/g, " ").trim()
@ggorlen
ggorlen / angularjs-hello-world.html
Created September 17, 2023 19:47
AngularJS hello world
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="color-scheme" content="dark light" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.js"></script>
</head>
<body>
<div ng-app="exampleApp">
@ggorlen
ggorlen / llm-flags.json
Last active June 21, 2023 19:41
All my LLM flags on Stack Overflow through May 2023
[
{
"title": "How to configure sanity preview to work on live?",
"href": "https://stackoverflow.com/questions/76196916/how-to-configure-sanity-preview-to-work-on-live/76267279#76267279",
"userHref": "https://stackoverflow.com/users/12207505/mathias",
"user": "Mathias",
"comment": "ChatGPT likely",
"score": 0,
"posted": "2023-05-16 21:53:19Z",
"flagged": "2023-05-23 23:29:05Z",
@ggorlen
ggorlen / gaming.md
Last active February 19, 2024 02:07
gaming
@ggorlen
ggorlen / r-gotchas.md
Last active April 18, 2023 18:40
R gotchas

R gotchas

Weird vectorized string appends

Wrong:

result <- c()
result <- c(result, "foo")
result <- c(result, paste0(rep("X", 3), "z")) # => [1] "foo" "Xz"  "Xz"  "Xz" 
print(result) # =&gt; [1] "foo\nXz\nXz\nXz"
@ggorlen
ggorlen / solid-cdn-router.js
Created February 27, 2023 03:27
Solid.js in all CDN with router
<!DOCTYPE html>
<html lang="en">
<head>
<title>solid.js</title>
<script type=importmap>
{
"imports": {
"solid-js": "https://esm.sh/solid-js@1.6.11",
"solid-js/html": "https://esm.sh/solid-js@1.6.11/html",
"solid-js/web": "https://esm.sh/solid-js@1.6.11/web",
@ggorlen
ggorlen / powershell-gotchas.md
Last active May 20, 2023 05:42
PowerShell gotchas
@ggorlen
ggorlen / JSON_stream_read.py
Last active December 6, 2023 05:57
JSON stream reader
# read file in the format of separate JSON objects without outer array
# {}
# {}
# {}
# ...
# https://stackoverflow.com/a/50384432/6243352
# https://stackoverflow.com/a/54666028/6243352
#
# other options:
# jq -s < podcasts.json