Skip to content

Instantly share code, notes, and snippets.

View paulrobertlloyd's full-sized avatar
🐢
Moving slowly and fixing things

Paul Robert Lloyd paulrobertlloyd

🐢
Moving slowly and fixing things
View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active April 25, 2024 08:14
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@troyfontaine
troyfontaine / 1-setup.md
Last active April 24, 2024 14:19
Signing your Git Commits on MacOS

Methods of Signing Git Commits on MacOS

Last updated March 13, 2024

This Gist explains how to sign commits using gpg in a step-by-step fashion. Previously, krypt.co was heavily mentioned, but I've only recently learned they were acquired by Akamai and no longer update their previous free products. Those mentions have been removed.

Additionally, 1Password now supports signing Git commits with SSH keys and makes it pretty easy-plus you can easily configure Git Tower to use it for both signing and ssh.

For using a GUI-based GIT tool such as Tower or Github Desktop, follow the steps here for signing your commits with GPG.

@x-yuri
x-yuri / mongo + docker.md
Last active March 29, 2024 08:47
mongo + docker

mongo + docker

mongo >= 6: init-mongo.js + MONGO_INITDB_DATABASE in .env-mongo
mongo < 6: init-mongo.sh + no MONGO_INITDB_DATABASE in .env-mongo

.env:

MONGO_USER=user
MONGO_PASSWORD=userpasswd
@phpdude
phpdude / nginx.conf
Last active February 28, 2024 04:36
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@idettman
idettman / add-to-existing-namespaces.js
Last active February 26, 2024 00:57
JavaScript: JSDoc Advanced Tips
/* https://leahayes.wordpress.com/2011/08/28/documenting-javascript-with-jsdoc3/
Namespaces can still be documented when a more abstract mechanism is used. @lends allows members to be added to an existing namespace:
*/
/**
* Root namespace
* @namespace root
*/
$namespace('root', /** @lends root **/ {
/**
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying

@adactio
adactio / minimal-serviceworker.js
Last active August 18, 2023 09:15
An attempt at a minimal viable service worker.
// Licensed under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// http://creativecommons.org/publicdomain/zero/1.0/
// HTML files: try the network first, then the cache.
// Other files: try the cache first, then the network.
// Both: cache a fresh version if possible.
// (beware: the cache will grow and grow; there's no cleanup)
const cacheName = 'files';
@Vispercept
Vispercept / delete_all_workflow_runs_of_workflow_id.sh
Created January 12, 2022 10:34
Delete all github-workflow runs of a given workflow_id to cleanup the actions-section
# ======================================================================================
# Delete all github-workflow runs of a given workflow_id to cleanup the actions-section
#
# original gist:
# https://gist.github.com/zulhfreelancer/a32bee3d37ffb90c93e00bf4b7fe26cf
#
# Requirements
# * gh CLI: https://cli.github.com (make sure you are logged-in to the CLI)
# * jq CLI: https://stedolan.github.io/jq
# ======================================================================================
@tmaiaroto
tmaiaroto / image-proxy.conf
Last active December 16, 2021 03:23
Nginx Image Filter Resize Proxy Service
# Feel free to change this path of course (and keys_zone value as well, but also change the usage of it below).
proxy_cache_path /var/www/cache/resized levels=1:2 keys_zone=resizedimages:10m max_size=1G;
# Gzip was on in another conf file of mine...You may need to uncomment the next line.
#gzip on;
gzip_disable msie6;
gzip_static on;
gzip_comp_level 4;
gzip_proxied any;
# Again, be careful that you aren't overwriting some other setting from another config's http {} section.
@aaronpk
aaronpk / media-endpoint.php
Last active March 6, 2021 23:47
an example of a Micropub Media Endpoint https://www.w3.org/TR/micropub/#media-endpoint
<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Authorization');
if(isset($_SERVER['HTTP_ACCEPT']) && strpos($_SERVER['HTTP_ACCEPT'], 'text/plain') !== false) {
$format = 'text';
} else {
header('Content-Type: application/json');
$format = 'json';
}