Skip to content

Instantly share code, notes, and snippets.

@jsejcksn
jsejcksn / noloc
Created April 26, 2018 03:23
Remove location/gps info from videos using ffmpeg
ffmpeg -i input.mov -map 0 -map_metadata -1 -c copy output-noloc.mov
@jsejcksn
jsejcksn / normalize.css
Last active June 4, 2018 02:41
normalize.css modifications
/*! Modifications to normalize */
*,
*::before,
*::after {
border: 0;
box-sizing: inherit;
font-weight: normal;
margin: 0;
padding: 0;
@jsejcksn
jsejcksn / bookmarklet-filterYTMusic.js
Last active June 9, 2018 23:30
Display only YouTube Music items in My Activity
javascript:(()=>{'use strict';const items={cards:{all:document.querySelectorAll('div.fp-display-item-holder')},titles:{all:document.querySelectorAll('div.fp-display-item-title'),notMusic:[]}};for(let i=0;i<items.titles.all.length;i++){if(items.titles.all[i].textContent.trim()!=='YouTube Music'){items.titles.notMusic.push(items.titles.all[i]);}};for(let i=0;i<items.cards.all.length;i++){for(let j=0;j<items.titles.notMusic.length;j++){if(items.cards.all[i].contains(items.titles.notMusic[j])){items.cards.all[i].remove();}}};let s=document.createElement('style');s.textContent='div.fp-date-block-overflow {display:none}';document.head.appendChild(s);})();
@jsejcksn
jsejcksn / gcp-tabs.json
Last active July 12, 2018 00:25
Is there a better way?
{
"tabs": [
"https://davesteele.github.io/raspberrypi/2016/04/23/raspberry-pi-cloudprint/",
"https://samhobbs.co.uk/2014/07/raspberry-pi-print-scanner-server",
"https://www.openprinting.org/printer/Epson/Epson-NX420_Series",
"https://github.com/google/cloud-print-connector/wiki/Installing-on-Raspberry-Pi-Raspbian-Jessie",
"https://github.com/google/cloud-print-connector/wiki"
]
}
@jsejcksn
jsejcksn / autoresize-textarea.js
Last active January 19, 2019 23:54
Auto-resize textarea
for (const tx of document.getElementsByTagName('textarea')) {
tx.style.setProperty('height', `${tx.scrollHeight}px`);
tx.style.setProperty('overflow-y', 'hidden');
tx.addEventListener('input', (ev) => {
ev.target.style.setProperty('height', 'auto');
ev.target.style.setProperty('height', `${ev.target.scrollHeight}px`);
});
}
@jsejcksn
jsejcksn / generate-element.js
Last active January 30, 2019 09:16
A function for creating an element with its content and attributes
'use strict';
function genEl (tagName, attributes, ...childNodes) {
const el = document.createElement(tagName);
if (attributes) {
for (const [prop, value] of Object.entries(attributes)) {
if (prop === 'style' && (Array.isArray(value) || value instanceof Map)) {
for (const declaration of value) {
el.style.setProperty(...declaration);
}
@jsejcksn
jsejcksn / 1p-parser.js
Last active May 14, 2019 06:22
1Password 1pif data parser Node.js module
#!/usr/bin/env node
// cli usage: `node 1p-parser.js input.1pif`
'use strict';
const getJSON = require('1pif-to-json');
(async () => {
const items = await getJSON(process.argv.slice(2)[0]);
@jsejcksn
jsejcksn / nodejs-uninstall-deletion-list.txt
Created May 21, 2019 02:32
Uninstalling system Node.js and npm in preparation for reinstall via nvm
# This list was derived from the macOS installer for Node.js v10.15 and might not be complete
# Additionally, if you have modified your npm prefix, you will also need to address that directory
/usr/local/bin/node
/usr/local/include/node
/usr/local/lib/dtrace/node.d
/usr/local/lib/node_modules
/usr/local/share/doc/node
/usr/local/share/man/man1/node.1
/usr/local/share/systemtap/tapset/node.stp
@jsejcksn
jsejcksn / monty-hall.js
Last active July 27, 2019 23:48
Monty Hall problem: Simulation
#!/usr/bin/env node
'use strict';
function makeADeal (changeDoor, initialDoorNumber) {
if (initialDoorNumber && (initialDoorNumber < 1 || initialDoorNumber > 3))
throw new Error('If provided, the inital door number must be 1, 2, or 3.');
function randomInt (max = 1, min = 0) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
@jsejcksn
jsejcksn / log-inspect.js
Created January 8, 2020 21:35
Use inspect to log deep objects in Node.js
import util from 'util';
const log = (() => {
const log = (...values) => {
console.log(...values.map(value => util.inspect(value, {
colors: true,
depth: null,
getters: true,
showHidden: false,
...log.options,