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
@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
@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
# ======================================================================================
@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.
@adamsilver
adamsilver / Validator.js
Last active August 6, 2020 14:33
Server side form validator component for Express
function Validator(req, res) {
this.req = req;
this.res = res;
this.validators = [];
this.errors = [];
}
Validator.prototype.add = function(name, rules) {
this.validators.push({
name: name,
@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';
@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 **/ {
/**
@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.

@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';
}
@allmarkedup
allmarkedup / fractal.js
Last active February 23, 2016 01:39
Custom theme development in Fractal
'use strict';
const fractal = require('@frctl/fractal');
//.... other config items
fractal.set('plugins.web.theme', 'example-theme');
@mattandrews
mattandrews / foo.js
Created October 21, 2014 22:23
execute arbitrary shell commands in node
var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { sys.puts(stdout) }
// pass in your command line arguments here – this one uses the default local config
exec("converjon --config node_modules/converjon/config/development.yml", puts);