Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@xem
xem / draft.md
Last active August 29, 2015 14:00
Character encodings on the Web

Introduction

Every single component of the Web handles strings, and especially Unicode characters encoding, differently.

This document aims to gather all the important information about character encodings on the Web.

File charsets

@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: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 / 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"}})()
@xem
xem / dabblet.css
Created February 22, 2012 08:00
Y U NO ?
/* Y U NO ? */
body { background: #13579B; }
.outer1 { width: 100px; height: 100px; margin: 100px auto; }
.inner1 { width: 100%; height: 100%; text-align: center; background: #FEDCBA; transition: all 1s ease; }
.outer1:hover { position: absolute; top: 0; left: 0; }
.outer2 { width: 100px; height: 100px; position: relative; margin: 100px auto; }
.outer2:hover { position: static; }
@xem
xem / dabblet.css
Created February 27, 2012 16:04
zoom
/* zoom */
* { margin: 0; padding: 0; }
.containerTable { width: 200px; height: 100px; margin: 100px 0 0 300px; background: #987654; }
.containerTd { width: 100px; height: 100px; vertical-align:top; }
div { text-align: center; width: 100px; height: 100px; background: #ECA864; border: 1px solid black; transition: all 1s ease; position: absolute; }
div.zoom { width: 1024px; height: 700px; margin-left: -300px; margin-top: -100px; position: absolute; }
@xem
xem / dabblet.css
Created February 27, 2012 16:01
Y U NO ?
/* Y U NO ? */
body { background: #13579B; }
.outer1 { width: 100px; height: 100px; margin: 100px auto; }
.inner1 { width: 100%; height: 100%; text-align: center; background: #FEDCBA; transition: all 1s ease; }
.outer1:hover { position: absolute; top: 0; left: 0; }
.outer2 { width: 100px; height: 100px; position: relative; margin: 100px auto; }
.outer2:hover { position: static; }