Skip to content

Instantly share code, notes, and snippets.

xem

Block or report user

Report or block xem

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xem
xem / draft.md
Last active Aug 29, 2015
Character encodings on the Web
View draft.md

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 Aug 29, 2015 — forked from 140bytes/LICENSE.txt
Mini string encoders for the Web
View README.md

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).

View README.md

Mini Mini Game of life

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

Score: 81b.

View gist:cf8c21239c39f2c6ce27
<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 Aug 29, 2015
log the binary content of files dropped in the browser. also works for multiple files.
View gist:f2a98e4df3ae3076b8fd
<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 Jun 26, 2014
A Pen by xem.
View index.html
<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 Aug 29, 2015
miniCodeEditor in 162b (Fx, Chrome, Opera)
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>
@xem
xem / readme.md
Last active Aug 29, 2015
A bookmarklet to fill any input with your e-mail
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 dabblet.css
/* 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; }
You can’t perform that action at this time.