Skip to content

Instantly share code, notes, and snippets.

View said-and-done's full-sized avatar

Said Nuh said-and-done

  • @tv2 Editorial Dev Team
  • Copenhagen, Denmark
View GitHub Profile
@said-and-done
said-and-done / conv.sh
Created January 24, 2025 08:42
Convert a sorted PNG sequence to GIF
convert -delay 50 -loop 0 $(ls frame*.png | sort --version-sort) seq_frames.gif
@said-and-done
said-and-done / statemachine.sh
Created August 11, 2022 13:14
AWS: stop all currently running State Machine executions
aws stepfunctions list-executions \
--state-machine-arn arn:aws:states:...:covidAutoUpdater \
--status-filter RUNNING \
--query "executions[*].{executionArn:executionArn}" \
--output text | \
xargs -I {} aws stepfunctions stop-execution \
--execution-arn {}
@said-and-done
said-and-done / map.js
Last active October 12, 2021 14:32
Linear map input domain to output range
function linearmap(inMin, inMax, outMin, outMax) {
return function (x) {
return (x - inMin) * (outMax - outMin) / (inMax - inMin) + outMin;
};
}
@said-and-done
said-and-done / douglasPeucker.js
Created May 6, 2021 08:00 — forked from adammiller/douglasPeucker.js
Javascript implementation of the Douglas Peucker path simplification algorithm
var simplifyPath = function( points, tolerance ) {
// helper classes
var Vector = function( x, y ) {
this.x = x;
this.y = y;
};
var Line = function( p1, p2 ) {
this.p1 = p1;
@said-and-done
said-and-done / serial_comma.js
Last active February 11, 2020 14:02
List items with Oxford comma
let items = [
{name: 'A'},
{name: 'B'},
{name: 'C'}
];
let serial = items.map((item) => {
return item.name
}).reduce((prevVal, currVal, currentIndex, array) => {
var delim = currentIndex === array.length-1 ? ', and ': ', '
let subscribers = ['[email protected]', '[email protected]'];
let count = subscribers.length;
let current = 0;
let URL = 'https://newsletter.services.tv2.dk/api/unsubscribe';
let unsub = (mail) => {
$.post(URL, {
@said-and-done
said-and-done / github.toc.js
Created September 9, 2019 14:08
Github Wiki: generate table of contents from sidebar
out = '';
document.querySelectorAll('li.Box-row').forEach((t) => {
var a = t.querySelector('a');
var text = a.innerText;
var link = a.getAttribute('href');
out += `## [${text}](${link})\n`;
});
console.log(out);
@said-and-done
said-and-done / .block
Last active April 17, 2019 11:14
vandring
license: mit
@said-and-done
said-and-done / Find & replace in place with sed
Last active June 13, 2018 08:54
Anonymize IP in analytics embed code
#!bash
$ find ../static -type f -name 'content.json' \
-exec grep -Hi "ga('send', 'pageview');" {} \; \
-exec gsed -i "s|ga('send', 'pageview');|ga('set', 'anonymizeIp', true);ga('send', 'pageview');|g" {} \;
@said-and-done
said-and-done / gid2wid.js
Created October 2, 2017 12:21
Google spreadsheets - gid to worksheet id
var gid2Wid = function (gid) {
var xorval = gid > 31578 ? 474 : 31578;
var letter = gid > 31578 ? 'o' : '';
return letter + parseInt((gid ^ xorval)).toString(36);
};