This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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))} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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);} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let fib = n=>( | |
f = { | |
*f(){ | |
var [a,b]=[0,1]; | |
while(1){ | |
yield a; | |
[a,b]=[b,a+b]; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const digitCount = n => { | |
var i = 0; | |
for(; 10**i <= n; i++); | |
return i; | |
} |
OlderNewer