Skip to content

Instantly share code, notes, and snippets.

View una-ada's full-sized avatar
👩‍💻
Trying my best!

una una-ada

👩‍💻
Trying my best!
  • Seattle, WA
  • 09:29 (UTC -07:00)
View GitHub Profile
<html>
<head>
<style>
/** Context Menu **/
.c-menu {position:fixed;z-index:500;opacity:1;transform:rotateZ(0);}
.c-menu:focus {outline:0;}
.c-menu-hex-div {width:70px;height:80px;position:absolute;-webkit-animation-duration:.6s;-webkit-animation-delay:.1s;animation-duration:.6s;animation-delay:.1s;z-index:3;}
.c-menu-hex-top {width:0;border-bottom:21px solid #93D2FF;border-left:35px solid transparent;border-right:35px solid transparent;}
.c-menu-hex-mid {width:70px;height:40px;background:#93D2FF;}
.c-menu-hex-bot {width:0;border-top:21px solid #93D2FF;border-left:35px solid transparent;border-right:35px solid transparent;}
// original
window.setInterval(() => {
var r = () => Math.random(),
d = document.querySelectorAll('*');
d[~~(r() * d.length)].style.background = `hsl(${r()*360}, ${40+~~(r()*60)}%, ${75+~~(r()*15)}%)`
}, 100);
// minified
window.setInterval(()=>{var r=()=>Math.random(),d=document.querySelectorAll('*');d[~~(r()*d.length)].style.background=`hsl(${r()*360}, ${40+~~(r()*60)}%, ${75+~~(r()*15)}%)`},100);
var http = require('https'),
args = process.argv.splice(process.execArgv.length + 2),
artists = {};
function search(query){
http.get(
'https://api.spotify.com/v1/search?q='
+ encodeURIComponent(query)
+ '&type=artist'
,(r0)=>{//request(0)
// Set random elements on the page to random colors
setInterval(()=>{r=()=>Math.random(),d=document.querySelectorAll('*');d[~~(r()*d.length)].style.background=`hsl(${r()*360},80%,60%)`},10);
// Generate an m x n matrix with elements filled in order
f=(m,n)=>{for(var a=[],i=0;i<m*n;)(a[~~(i/m)]||(a[~~(i/m)]=[]))[~~(i%m)]=++i;return a}
// Maximum value in a multidemnsional array
m=(a)=>{return Math.max(...[].concat(...a))}
// Math
const
ℏ = 1, // 1.05e-34 m2kg/s
π = Math.PI;
/** Schrodinger Equation Solver */
class Ψ {
/**
* Create a Schrodinger solver
* @param {array} x - Points to solve at (must be evenly spaced)
* @param {array} ψ_0 - ψ at time t_0 at each point x
@una-ada
una-ada / clamp.js
Created September 12, 2019 05:07
a perfectly sensible and legible function for clamping numbers
clamp=(val,min,max)=>{let j=(a,b,h)=>{if(a==b)return a;let c,d;[c,d]=[a,b].map((v)=>v>>31==-1);if(c!=d)return h?b:a;for(let i=30,e,f,g;i>=0;i--){if((e=a>>i&1)==(f=b>>i&1))continue;return e!=f&&e?h?a:b:h?b:a;}};return j(j(val,max,0),min,1);}
let fib = n=>(
f = {
*f(){
var [a,b]=[0,1];
while(1){
yield a;
[a,b]=[b,a+b];
}
}
}
// Fill integer array 1...n
var a = n => [...Array(n).keys()].map(x => ++x),
// Lazy shortcut
c = x => new Array(x.length).fill(0),
// Matrix multiplication
m4m = (A, B) => c(A)
.map((r, i) => c(B[0])
.map((v, j) => A[i]
.reduce((s, e, k) => s+(e*B[k][j]), 0)
)
@una-ada
una-ada / ReZero Director's Cut S01E01.nfo
Created February 3, 2021 00:58
ReZero Director's Cut .nfo Files (for Kodi)
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<episodedetails>
<title>The End of the Beginning and the Beginning of the End</title>
<originaltitle>始まりの終わりと終わりの始まり</originaltitle>
<showtitle>Re:ZERO Director's Cut</showtitle>
<season>1</season>
<episode>1</episode>
<displayseason>-1</displayseason>
<displayepisode>-1</displayepisode>
<outline></outline>
const digitCount = n => {
var i = 0;
for(; 10**i <= n; i++);
return i;
}