Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
npx fitsum

ፍፁም fitsum

💭
npx fitsum
View GitHub Profile
@fitsum
fitsum / speak-english.js
Last active Dec 31, 2021
speaks english voices in given browsers
View speak-english.js
speakEnglish = () => { voices = speechSynthesis.getVoices(); voices.filter(voice => voice.lang === "en-US" ).forEach(voice => {
const utterance = new SpeechSynthesisUtterance("What's poppin, bitches?")
utterance.voice = voice;
// default volume !== 1
utterance.volume = 1;
speechSynthesis.speak(utterance);
// next line causes function not to fire on first invocation 🤷🏾‍♂️
utterance.addEventListener('start',()=>{console.log('voice name:', voice.name)})
}) }
speakEnglish()
@fitsum
fitsum / remove-youtube-likes.js
Last active Nov 3, 2021
removing likes from youtube clips until YT baffles the effort
View remove-youtube-likes.js
// https://www.youtube.com/playlist?list=LL
let currentLike = 1,
// should allow time for menu open and click
removeDelay = 150,
// should be double remove delay
countDelay = removeDelay*2,
// get current total from stats section
totalLikes = parseInt(document.querySelector('#stats yt-formatted-string').textContent);
const countLikes = setInterval(()=>{
View reset.css
/*** The new CSS Reset - version 1.2.0 (last updated 23.7.2021) ***/
/* Remove all the styles of the "User-Agent-Stylesheet", except for the 'display' property */
*:where(:not(iframe, canvas, img, svg, video):not(svg *)) {
all: unset;
display: revert;
}
/* Preferred box-sizing value */
*,
@fitsum
fitsum / selection-snippet.js
Last active May 12, 2021
styled output causes linebreaks in Chrome but not Firefox
View selection-snippet.js
// FIXME?
document.styleSheets[document.styleSheets.length - 1].addRule("::selection", "background: red; color: pink");
document.addEventListener('selectionchange', e => {
console.clear();
slice = document.getSelection().toString();
if (slice !== "") {
parent = document.getSelection().getRangeAt(0).commonAncestorContainer.textContent;
preSlice = parent.slice(0, parent.indexOf(slice));
postSlice = parent.slice(parent.indexOf(slice) + slice.length, parent.length - 1);
@fitsum
fitsum / same-as-eval.js
Last active May 5, 2021
no more eval() I guess ...
View same-as-eval.js
(() => {return Function(`"use strict";return (${__f__})`)();}).call(null)()
// would normally do `eval(__f__)` where __f__ might be a stringified function
// name in an array
@fitsum
fitsum / fizzBuzz-OCD.js
Last active May 2, 2021
Super accurate output
View fizzBuzz-OCD.js
// getting the output to look exactly like what's here
// https://node-girls.gitbook.io/beginners-javascript/challenges/challenge-4-fizzbuzz
const fizzBuzz = ( start, end ) => {
const format = ( idx, output ) => {
let out = output || '';
outColors = {
true: 'color: #71a7ff',
false: 'color: orange'
}
@fitsum
fitsum / .eslintrc.json
Last active Jun 25, 2021
boilerplate eslint
View .eslintrc.json
{
"env": {
"browser": true,
"es2021": true,
"node": true
},
"extends": [
"standard"
],
"parserOptions": {
@fitsum
fitsum / three.html
Created Dec 27, 2020 — forked from nasser/three.html
a three.js boilerplate scene in a single 30 line self-contained html file
View three.html
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/reset-css@5.0.1/reset.min.css">
<script type="module">
import * as THREE from "https://cdn.jsdelivr.net/npm/three@0.124.0/build/three.module.js"
import { OrbitControls } from "https://cdn.jsdelivr.net/npm/three@0.124.0/examples/jsm/controls/OrbitControls.js"
var scene = new THREE.Scene()
var camera = new THREE.PerspectiveCamera(75)
camera.position.z = 4
@fitsum
fitsum / scratchmarklet.js
Created Nov 22, 2020
bookmarklet version of scratch.js
View scratchmarklet.js
data:text/html, <html lang="en"><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>*scratch*</title><style> body{font-family:Hack,Menlo,Monaco,'Droid Sans Mono','Courier New',monospace;white-space:pre}body style{display:inline}style::before{content:'<style>'}style::after{content:'<\/style>'}*::before,*::after{color:rgba(136,18,128,0.5)}</style><script> const selectOuterMostNonBodyNode = (node) => node.parentNode.tagName === 'BODY' ? node : node.parentNode;function insertAfterSelection(selection,html){if(html === '') return;let nodeToInsert=document.createElement('div');nodeToInsert.innerHTML=html + '<br>';let range=selection.getRangeAt(0);let clone=range.cloneRange();let {endContainer} = range;range.setStartAfter(selectOuterMostNonBodyNode(endContainer)); range.insertNode(nodeToInsert);clone.setStart(clone.endContainer, clone.endOffset);selection.removeRange(range); selection.addRange(clone);} var globalEval=eval;function evaluate(){let selection=documen
@fitsum
fitsum / amharic.txt
Created Oct 29, 2020
my name in amharic in unicode
View amharic.txt
console.log('\u134D\u1341\u121D\u1361\u1260\u12AB\u12ED') // "ፍፁም፡በካይ"