Skip to content

Instantly share code, notes, and snippets.

@xem
xem / codegolf.md
Last active March 22, 2024 15:41
JS code golfing

codegolf JS

Mini projects by Maxime Euzière (xem), subzey, Martin Kleppe (aemkei), Mathieu Henri (p01), Litterallylara, Tommy Hodgins (innovati), Veu(beke), Anders Kaare, Keith Clark, Addy Osmani, bburky, rlauck, cmoreau, maettig, thiemowmde, ilesinge, adlq, solinca, xen_the,...

(For more info and other projects, visit http://xem.github.io)

(Official Slack room: http://jsgolf.club / join us on http://register.jsgolf.club)

@xem
xem / README.md
Last active August 29, 2015 14:01 — forked from 140bytes/LICENSE.txt
Mini string encoders for the Web

Mini string encoders/decoders for the Web

Here's a list of tiny functions whose goal is to convert any Unicode string in 28 different formats used on the Web, and do the reverse operation.

An online converter using those functions can be found here: http://xem.github.io/escape

Please contribute in the comments (or by pull request) if you have a feature idea or a code-golf improvement to make or a bug to solve.

NB: to be as short as possible, all those functions assume a valid input and convert all chars (including ASCII chars and non-ASCII chars that don't really need to be converted in some cases).

@xem
xem / README.md
Last active August 29, 2015 14:02 — forked from 140bytes/LICENSE.txt

Mini Mini Game of life

A game of line engine where everything that can be passed as parameter, is.

Score: 81b.

@xem
xem / gist:670dec8e70815842eb95
Last active January 19, 2023 22:43
beep boop
<!-- solution 1, 117b, inspired by http://www.p01.org/releases/140bytes_music_softSynth/ -->
<button onclick="new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(1e3).join(123)).play()">Beep</button>
<!-- Solution 2, 107b, inspired by http://xem.github.io/chip8/c8.html -->
<button onclick="o=(A=new AudioContext()).createOscillator();o.connect(A.destination);o.start(0);setTimeout('o.stop(0)',500)">Boop</button>
@xem
xem / gist:cf8c21239c39f2c6ce27
Created June 17, 2014 17:41
multiple file drop
<html ondrop="f(event);return!1"ondragover=return!1>
<script>
f=function(e){
r=new FileReader;
d=e.dataTransfer.files;
for(i=0;i<d.length;i++){
r.readAsArrayBuffer(d[i]);
}
r.onload=function(a){
console.log(r.result); // wat? If I drop multiple files, there's only one ArrayBuffer there (on FF) and it doesn't work at all (on chrome)
@xem
xem / gist:f2a98e4df3ae3076b8fd
Last active August 29, 2015 14:02
log the binary content of files dropped in the browser. also works for multiple files.
<html ondrop="f(event);return!1"ondragover=return!1>
<script>
f=function(e){
d=e.dataTransfer.files;
for(i=0;i<d.length;i++){
with(new FileReader){
readAsArrayBuffer(d[i]);
onload=function(){console.log(new Uint8Array(result))};
}
}
@xem
xem / index.html
Created June 26, 2014 09:41
A Pen by xem.
<div class="content smallSizeLayout">
<div class="intro" data-stretch-parent-if-n-lines="2" data-stretch-parent=".content" data-bind="css:{ 'bulletHidden': !isVisited()}" id="id_186">
<p data-bind="html:text"><div class="richText"><p>Intro: Lorem ipsum dolor sit, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa</p></div></p>
</div>
<table class="bulletpoint bulletHidden first">
<tbody>
<tr>
<td class="bullet-icon">
@xem
xem / index.html
Last active July 30, 2023 09:57
miniCodeEditor in 162b (Fx, Chrome, Opera)
<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>
@xem
xem / readme.md
Last active August 29, 2015 14:06
A bookmarklet to fill any input with your e-mail

...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"}})()