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:36 (UTC -07:00)
View GitHub Profile
@una-ada
una-ada / alphabet.js
Last active September 13, 2023 03:01
Shortened functions for generating arrays of single character strings from codepoints (e.g. ['a', 'b', 'c', ...]).
/*------------------------------------------------------------------------------
|| Shortened functions for generating arrays of single character strings from ||
|| codepoints (e.g. ['a', 'b', 'c', ...]). Codepoints 97-122 (a-z) are used ||
|| to emulate a simple use case, allowing the canonical solution `vRef` to be ||
|| used for testing. Character counts in the left column are calculated as is ||
|| without adjustment for the variable names or frequency of their usage. ||
|| Extremely brief explanations of the methods used for each solution are ||
|| provided in the right column. ||
/*----------------------------------------------------------------------------*/
var v = [], // ----------
@una-ada
una-ada / quick-mv.bash
Created November 10, 2022 14:36
A quick command for making a still image video (output.mp4) out of an audio file (input.mp3) and image (input.png) for Twitter posts.
ffmpeg \
-loop 1 \
-i input.png \
-i input.mp3 \
-pix_fmt yuv420p \
-vcodec libx264 \
-tune stillimage \
-acodec aac \
-vb 1024k \
-minrate 1024k \
Buildings:
# You can remove items by clicking with the mouse.
L1 1x1 Detached
L1 2x2 Detached01
L1 2x2 Detached03
@una-ada
una-ada / custom.css
Last active June 29, 2021 06:53
Custom VS Code CSS
a,
code,
h2,
h3,
summary,
.author,
.badge,
.content,
.count,
.description,
const digitCount = n => {
var i = 0;
for(; 10**i <= n; i++);
return i;
}
@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>
// 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)
)
let fib = n=>(
f = {
*f(){
var [a,b]=[0,1];
while(1){
yield a;
[a,b]=[b,a+b];
}
}
}
@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);}
// 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