Skip to content

Instantly share code, notes, and snippets.

View calebhailey's full-sized avatar
:shipit:
Hustlin'

Caleb Hailey calebhailey

:shipit:
Hustlin'
View GitHub Profile
@calebhailey
calebhailey / example.md
Last active April 17, 2024 20:09
SOLVED: Mysterious HTMLRewriter Issue – async bug or PEBKAC?

Mysterious HTMLRewriter Issue – Async Bug or PEBKAC?

UPDATE: this was solved, thanks to the Cloudflare Community Discord. See comments for the solution.

I've been wanting to kick the tires with Cloudflare's HTMLRewriter to see if it could be used as an HTML parser. As a simple example, can Cloudflare Workers + HTMLRewriter be used to build an API to parse OpenGraph metadata and return the properties as a JSON document? Based on a cursory review of the documentation, it appears as if this should be quite simple.

However, I have observed a race condition where HTMLRewriter will always find fewer than the present number of matching elements unless a simulate a 1 millisecond "sleep":

await new Promise( function(resolve) { setTimeout(resolve, 1); })
// VanillaJS Logger
//
// NOTE: You probably shouldn't use this in production... you've been warned.
let logger = {};
// Log levels
// debug=0, info=1, log=2, warn=3, error=4
const LOG_LEVELS = [
"debug",
"info",

Hi there 👋 I'm a newbie to the Apple Developer ecosystem. I recently shipped my very first app to the App Store (see: https://themagichighlighter.com, or check it out on the App Store for more info).

Here's an excerpt from my manifest.json file, with the corresponding action and commands configuration:

{
    "...": "...",
    "action": {
        "default_popup": "popup.html",
        "browser_style": true,

Keybase proof

I hereby claim:

  • I am calebhailey on github.
  • I am calebhailey (https://keybase.io/calebhailey) on keybase.
  • I have a public key ASB9Z-HGNCb7bgJApqK1uVBdqCX2JmWpg9FJp1spFYR27Qo

To claim this, I am signing this object:

#!/usr/bin/sh
# Google Domains Dynamic DNS Updater Script
# See: https://support.google.com/domains/answer/6147083?hl=en
DDNS_USERNAME=xxxxxxxxxxxxxxxx
DDNS_PASSWORD=xxxxxxxxxxxxxxxx
DDNS_HOSTNAME=foo.yourcompany.com
DDNS_IPADDRESS=$(curl -s http://checkip.amazonaws.com)
DDNS_STATUS=$(curl -s -XPOST "https://${DDNS_USERNAME}:${DDNS_PASSWORD}@domains.google.com/nic/update?hostname=${DDNS_HOSTNAME}&myip=${DDNS_IPADDRESS}")
echo "$(date) ${DDNS_STATUS}"
@calebhailey
calebhailey / sensu-summit-open-spaces-afternoon-session.md
Created August 16, 2017 23:43
Infrastructure Tests as Monitoring Checks

Infrastructure Tests as Monitoring Checks

Notes from an afternoon discussion at the 2017 Sensu Summit.

Attendees:

  • Ben Abrams (HPE)
  • Jeff Barrows (GE)
  • Tim Smith (Chef)
  • Andre Niemann (Becon)
{
"handlers": {
"example_handler": {
"type": "pipe",
"command": "notify_somebody.rb",
"timeout": 30,
"filter": "filter_weekly_maintenance"
}
}
}
@calebhailey
calebhailey / resolve_filter.json
Last active May 16, 2016 20:14
Only execute a handler on event resolution
{
"filters": {
"resolve": {
"negate": false,
"attributes": {
"action": "resolve"
}
}
}
}
@calebhailey
calebhailey / occurences.md
Last active October 20, 2017 14:27
Preempt sensu-plugin `occurrences` and `refresh` functionality with a simple / lightweight filter

UPDATE (2017-10-20): it has recently been brought to my attention that this gist has been circulated amongst Sensu users as a sort of best practice or "guide". This gist was never meant to be adopted as a long-term solution, but rather an alternative/temporary solution while many changes regarding Sensu event filtering were "in-flight". Many more words regarding changes to event filtering have been captured on the Sensu blog since the writing of this gist: https://blog.sensuapp.org/deprecating-event-filtering-in-sensu-plugin-b60c7c500be3. The TL;DR here is: use the new built-in occurrence filtering that has been available in Sensu Core since version 0.26.0 (release notes).

Hi friends.

There has been a lot of confusion over the past few months about how the Sensu check definition attributes occurrences and refresh actually work. The attributes occurrences and refresh are not (currently) a part of the Sensu [check definitio

NOTE: This is an excerpt from an upcoming rewrite of the Sensu installation guide, so some references may be made to documentation contents that don't currently exist, but they are coming soonicorn.com. :shipit:

The 5-minute Sensu Install

Although Sensu’s architecture is one of its most compelling features, and the installation guide can help you get Sensu installed in a variety of configurations in any operating environment, you might not actually care