Skip to content

Instantly share code, notes, and snippets.

View lewdev's full-sized avatar

Lewis Nakao lewdev

View GitHub Profile
@lewdev
lewdev / my-modal.html
Created February 8, 2023 22:12
🖼 CSS-Only Modal with outside-click close & fade animation
<style>
.my-modal:target {
opacity: 1;
pointer-events: auto;
}
.my-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
@lewdev
lewdev / speak-japanese.html
Last active February 10, 2023 22:48
🗣 Speech Synthesis in Japanese
<p id=o></p>
<script>
/*
Sources:
* https://manu.ninja/using-the-speech-synthesis-interface-of-the-web-speech-api/
* https://css-tricks.com/using-the-web-speech-api-for-multilingual-translations/
* https://www.zeolearn.com/magazine/the-new-speech-synthesis-web-api
*/
let syn = speechSynthesis;
@lewdev
lewdev / #code-minifier.md
Last active February 26, 2023 11:04
👨‍💻 My general HTML/CSS/JavaScript Code Minifier

👩‍🔧 My general HTML/CSS/JavaScript Code Minifier

This is by no means, a reliable code minifier. It makes several assumptions and treats ALL common code characters (i.e. brackets, parenthesis, operators, etc.) as "code" such that if you are writing text as example code, that will get minified.

The general assumption is you will be writing purely code and not English trying to explain code.

I found other solutions but they were isolated by their languages. i.e. HTML minifier, CSS minifier, & JavaScript terser.

There wasn't one single solution and I didn't want something very complicated since I'm making my code smaller by hand anyway.

@lewdev
lewdev / MiniDwitter-by-xem.md
Last active April 6, 2023 23:00
⬛ Dwitter Shim by KilledByAPixel in one HTML file

Source: https://xem.github.io/codegolf/minidwitter.html

<body onload='t=0;x=c.getContext`2d`;with(Math)S=sin,C=cos,T=tan;R=(r,g,b,a=1)=>`rgba(${[r|0,g|0,b|0,a]})`;setInterval("eval(A.value);t+=.016",16)'><canvas id=c width=1920 height=1080 style=width:5in></canvas><br><textarea id=A cols=60 oninput=t=0>
for(i=0;i<65;i++)for(j=0;j<65;j++)x.fillStyle=R(i*9,j*9,C(t)*255),x.fillRect(900+400*S((i+t/9)*3)*C((j+t/9)*1.5),500+400*S((j+t/9)*1.5),5,5)
@lewdev
lewdev / tiny-dwitter-editor.html
Last active April 24, 2023 22:57
⬛ Tiny Dwitter Editor. Run dweets on your own (Ctrl-Enter to run)
<style>/*Dwitter Shim by Frank Force 2020 - MIT License (https://codepen.io/KilledByAPixel/pen/YzyyOEr)*/*{box-sizing:border-box;margin:0}textarea,iframe{width:100%;height:50vh}</style>
<script>let shim=`<canvas id=c width=1920 height=1080></canvas><script>u=t=>{z}
let time = frame = nextFrameMs = 0
,FPS = 60
,x = c.getContext("2d")
,S = Math.sin
,C = Math.cos
,T = Math.tan
,R = (r,g,b,a=1) => "rgba("+[r|0,g|0,b|0,a]+")"
,loop = frameTime => {
@lewdev
lewdev / smb-in-url.md
Last active September 27, 2024 01:16
🦘👨‍🔧 Super Mario Bros in your URL

🦘👨‍🔧 Super Mario Bros in your URL

This was made by xem or @MaximeEuziere on twitter.

Source

Copy-paste the code below into your address bar to run it. Unfortunately, making it compatible to the URL, the size of the app explodes to 1560 characters.

data:text/html,
@lewdev
lewdev / date-distance.html
Last active February 27, 2023 04:03
📅 Date Distance JavaScript function (i.e. "3mo ago", "5d until")
<pre id=o></pre>
<script>
const TIME = [1e3, "s", 6e4, "min", 36e5, "hr", 864e5, "d", 2592e6, "wk", 2592e6, "mo", 31536e6, "yr"];
const dateDistance = dateStr => {
const now = new Date().getTime();
let diff = now - new Date(dateStr).getTime();
let agoOrUntil = " ago";
if (diff < 0) { agoOrUntil = " until"; diff = Math.abs(diff); }
for (let i = 12; i >= 0; i-=2) {
@lewdev
lewdev / nth-fibonacci.html
Last active September 16, 2025 20:57
🔢 Nth Fibbonacci bookmarklet (99b)
data:text/html,<input id=o onblur=with(Math)r=sqrt(5),o.value=round(pow((1+r)/2,o.value)/r)>
@lewdev
lewdev / pet-sim.html
Last active June 7, 2025 01:40
🐶 Simple Pet Sim
<!DOCTYPE html>
<head><title>🐶 Pet Sim</title></head>
<body>
<div id="start">
<h2>🐶 What would you like to name your pet?</h2>
<input id="n" onkeyup="event.keyCode===13&&n.value?start_game(n.value):null"/>
<button onclick="start_game(n.value)">Start</button>
</div>
<div id="controls" style="display:none">
@lewdev
lewdev / worksheet-generators.md
Last active September 25, 2024 04:46
🏫📄 Worksheet Generators List