Instantly share code, notes, and snippets.

View js1k 2019 ideas.md
  • 3D Peach Castle (CSS3D vs. raycasting feat RomanCortes)
  • 3D solar system (feat Yonatan)
  • Two3D clone (feat BalintCsala)
  • 2D physics engine (feat BalintCsala)
  • Mandelbox (feat BalintCsala)
  • An app that generates QR codes containing 1kb demos
  • A 2D WFC tracer
  • random dweet generator
  • SMB 1-1
  • 3D plotter
View css.md
  • Don't modify strings (content: "...", font-family: '...')
  • Remove all CSS comments (ex: /* ... */ )
  • Remove all unnecessary spaces, tabs and line breaks (ex: around + > ~ ; : , ( ) { } /)
    • Keep spaces before : in selectors (ex: * :before != *:before)
    • Keep spaces around + and - in calc(...) (but not in nth-child and nth-of-type)
  • Remove all unnecessary ; (ex: a{color:red;})
  • Remove all unnecessary * in CSS selectors (ex: *:before => :before)
  • Remove leading and trailing zeros (ex: 0.1%, 1.0%, 0.0px)
  • Remove units after zero (ex: 0px 0rem 0% 0turn 0vmax 0dpi)
View v1.html
<pre id=p><script id="s" style="display:block">setInterval(z=`
/* =<,m#F^ A W###q. */ ;
/* #K q##H######Am */ ;
/* dP cpq#q##########b, */ ;
/* p##@###YG=[#######y */ ;
/* d#qg '*PWo##q#######D */ ;
/* aem1k.com Q###KWR#### W[ */ ;
/* .Q#########Md#.###OP A@ , */ ;
/* , (W#####Xx######.P^ T % */ ;
/* #y '^TqW####P###BP */ ;
View miniEditor.html
<body contenteditable oninput=eval(S.textContent)>
<h1>Hi! (edit me)</h1>
<script style="display:block;border:1px solid;;white-space:pre-wrap" id=S>
// JS (edit me)
console.log("test");
</script>
<style style="display:block;border:1px solid;white-space:pre-wrap">
/* CSS (edit me) */
* { background: #def }
</style>
View readme.md

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

View index.html
<canvas id=a>
<script>
g=a.getContext("webgl");
/*
// Coral reef
// -----------
View moz.xml
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:html="http://www.w3.org/1999/xhtml">
<binding id="mycode">
<implementation>
<constructor>
alert("XBL script executed.");
</constructor>
</implementation>
</binding>
View readme.md

...or any text you often need to write in form fields.

Works with inputs, textareas and contenteditable elements.

Doesn't work on HTTPS on Firefox 23+.

javascript:(function(d){d=document.activeElement;if(d.tagName=="INPUT"||d.tagName=="TEXTAREA"||d.contentEditable=="true"){d.value=d.innerHTML="my_email@my_email_provider.com"}})()
View index.html
<body oninput='f.srcdoc=t2[v="value"]+"<script>"+t0[v]+"</script><style>"+t1[v]'onload='for(i=3;i--;)e.innerHTML+="<textarea id=t"+i+" rows=9>"'id=e><iframe id=f>