Skip to content

Instantly share code, notes, and snippets.

View winston0410's full-sized avatar
🆓
Coding hard right now

John Winston winston0410

🆓
Coding hard right now
  • United Kingdom
View GitHub Profile
@aslafy-z
aslafy-z / -kube-clear-secret.md
Created August 27, 2021 10:22
kube-clear-secret - Convert a Kubernetes secret to its stringData clear form.

kube-clear-secret

This tool takes a secret in the JSON format in STDIN and outputs the same secret with the data field replaced with a clear-text stringData. This allows to make patches to secrets from clear-text like the following:

kubectl get secret my-secret -ojson | kube-clear-secret | sed 's/my-old-value/my-new-value/g' | kubectl apply -f -

Greenlet for Node worker_threads

Works with ESM and CommonJS.

import greenlet from 'greenlet-node';

const add = greenlet(async (a, b) => {
  return a + b;
});
@sdondley
sdondley / tmux split-window subcommand.md
Last active April 23, 2024 11:49
Super Guide to the split-window tmux Subcommand (and Beyond)

Super Guide to the split-window tmux Subcommand (and Beyond)

Guide overview

tmux, like other great software, is deceptive. On the one hand, it's fairly easy to get set up and start using right away. On the other hand, it's difficult to take advantage of tmux's adanced power features without spending some quality alone time with the manual. But the problem with manuals is that they aren't geared toward beginners. They are geared toward helping seasoned developers and computer enthusiasts quickly obtain the

@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active March 28, 2024 01:45
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@soofaloofa
soofaloofa / Collection+JSON
Last active October 20, 2023 19:21 — forked from soofaloofa-zz/ On choosing a hypermedia type
On choosing a hypermedia type for your API - HAL, JSON-LD, Collection+JSON, SIREN, Oh My!
GET https://api.example.com/player/1234567890
{
"collection": {
"version": "1.0",
"href": "https://api.example.com/player",
"items": [
{
"href": "https://api.example.com/player/1234567890",
"data": [
{"name": "playerId", "value": "1234567890", "prompt": "Identifier"},
@tommmyy
tommmyy / ramdaDebounce.js
Last active October 19, 2023 15:14
Debounce function using Ramda.js
import { curry, apply } from 'ramda';
/**
* Debounce
*
* @param {Boolean} immediate If true run `fn` at the start of the timeout
* @param timeMs {Number} Debounce timeout
* @param fn {Function} Function to debounce
*
* @return {Number} timeout
@paulstatezny
paulstatezny / benchmark-object-delete-vs-assign.js
Last active January 24, 2024 17:36
Benchmarking how much faster it is to null a property of an object versus deleting that property in JavaScript
var Benchmark = require('benchmark');
function complete() {
console.log(String(this));
}
var objDeleteBenchmark = new Benchmark('Object#delete-property', {
setup: function() { var obj = {foo: 'bar'}; },
fn: function() { delete obj.foo; }
});