Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
npx fitsum

Fitsum Belay fitsum

💭
npx fitsum
View GitHub Profile
@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') // "ፍፁም፡በካይ"
@fitsum
fitsum / ASCIIcade.txt
Last active Oct 6, 2020
based on fun cascading thing I used to do manually on twitter
View ASCIIcade.txt
// OG
// https://jsfiddle.net/fitsum/40t8h2no/
// params
s:String = string
f:String = filler character
e:String = effect name; eg. "rev", "zig"
w:Number = horizontal spacing
const ASCIIcade = (s, f = null, e = null, w = 3) => {
@fitsum
fitsum / mouse-trace.js
Created Feb 7, 2020
getting mousemove direction for custom cursor
View mouse-trace.js
//TODO: add cursor bg and rotate script. can't tell what's happening without visual
let lastCoords = [];
const handleDir = e => {
let xDiff, yDiff, currCoords = [e.x, e.y];
if ( lastCoords.length !== 0 ){
xDiff = currCoords[0] - lastCoords[0];
yDiff = currCoords[1] - lastCoords[1];
}
View english-bibles-by-denom.js
fetch('https://api.scripture.api.bible/v1/bibles', {headers: {'api-key': 'ace65b88c21bc3d190f3f95754e2eede'}})
.then((r) => r.json())
.then((j) => {
const worldenglish = j.data.filter(item => item.name.indexOf('World English Bible') !== -1 ).map((item) => {return {"name":item.name, "description": item.description}});
console.table(worldenglish);
});
// Feeling fine about using `indexOf`
// https://stackoverflow.com/a/54538979
View practical-curry.js
const a = [1,2,3,4];
const checkType = (type, collection2check) => collection2check.every((each) => typeof each === type);
const curr = (collection) => {
return (actionOrType, actionFn) => {
return actionFn(actionOrType, collection) ? `all in ${collection} are ${actionOrType}s` : `few or none in ${collection} are ${actionOrType}s`;
};
}
const arr = curr(a);
console.log(arr('number', checkType))
@fitsum
fitsum / rm-FB-page-like-suggestions.js
Last active Jan 1, 2020
drop in console and remove like suggestions (in case I forget)
View rm-FB-page-like-suggestions.js
Array.from(document.querySelectorAll('[data-tooltip-content="Remove Suggestion"]')).forEach((each)=>{each.click()})
@fitsum
fitsum / class-and-element-lists-using-Set.js
Last active Jan 1, 2020
jstip from Lea Verou for capturing lists of DOM stuff using Set
View class-and-element-lists-using-Set.js
list of classes
[...new Set($$("[class]").flatMap(e => [...e.classList]))]
list of elements
[...new Set($$("*").map(e => e.nodeName.toLowerCase()))]
Use * * * for elements inside <head> and <body> or body * for elements inside <body> only
@fitsum
fitsum / App.svelte
Last active Jul 29, 2019
svelte component
View App.svelte
<script>
import Greet from "./Greet.svelte";
let config4Pants = {
name: "Pants",
greeting: "What's up!"
},
config4Son = {
name: "Son",
greeting: "Sup?"