Skip to content

Instantly share code, notes, and snippets.

View subzey's full-sized avatar

Anton Khlynovskiy subzey

View GitHub Profile
@subzey
subzey / requiem.md
Last active August 29, 2015 13:58
Requiem for a Dragon

Requiem for a Dragon

This is post-mortem for my first JS1K entry, Breath.

Complete, almost per-line, explaination was subitted with uncompressed de-optimized source code. So it's not so "techy", this is something I would share with other coders after few beers in a bar. No code, just thoughts.

The Idea

@subzey
subzey / banner-insert.js
Created April 17, 2014 09:29
Пример асинхронной вставки
(function(){
var allScripts = document.getElementsByName('script');
var link = document.createElement('a');
for (var i=allScripts.length; i--; ){ // старый добрый ECMA 262-3
// Проходим по всем скриптам
var script = allScripts[i];
if (!script.src){
continue;
}
// определяем, подходит ли этот элемент script по его src
@subzey
subzey / dson.js
Last active August 29, 2015 14:02
DSON shim
var DSON = DSON || {
parse: function(v) {
return JSON.parse(v.replace(/"(\\"|[^"])*"|[a-z]+/gi, function(v) {
return {
such: '{',
wow: '}',
is: ':',
so: '[',
many: ']',
next: ',',
@subzey
subzey / gist:b18c482922cd17693d65
Last active August 29, 2015 14:06
Few Tricks on Compressing Js13k Entry

Few Tricks on Compressing Js13k Entry

Most important detail: in js13k entry 13k stands for zipped entry size. And this detail makes js13k differ from other code golfing compos.

Last year winner entry uncompressed size was about 70k. 70 kilobytes! In js1k you have a month to minify 1k, so how much time would it take to minify 70k? Nope, you have only 1 month. So it's very unlikely one will manually golf the entry. And this is the other thing that makes js13k special: no hardcore manual "hell yeah I've stripped one byte!" golfing.

@subzey
subzey / toms.js
Created September 27, 2014 08:10
var toMs = (function (){
function _add(a, b){
var v = new Number((a || 0) + (b || 0));
v.milliseconds = milliseconds;
v.seconds = seconds;
v.minutes = minutes;
v.hours = hours;
v.days = days;
return v;
}
@subzey
subzey / index.html
Last active August 29, 2015 14:20
Too Asynchronous
<!DOCTYPE html>
<html lang="en">
<head>
<title>Async test</title>
<meta charset="utf-8">
</head>
<body>
<pre></pre>
<script>
<!DOCTYPE html>
<html>
<head>
<title>@document demo</title>
<style>
body {
text-align: center;
}
.foo {
margin: .5em;
@subzey
subzey / index.html
Created September 21, 2015 17:34
Canvas paint test
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div>
<select id="type">
<option value="naive">Naive</option>
<option value="onefill">Fill once</option>
@subzey
subzey / LICENSE.txt
Created June 5, 2011 08:07 — forked from bytespider/LICENSE.txt
140byt.es -- encodeURIComponent based convert string to array of UTF-8 bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@subzey
subzey / ru_RU.md
Created July 4, 2011 11:29
Extended Pragma usage initiative

Инициатива расширенного использования заголовка HTTP Pragma

Назначение

Этот документ является выражением инциативы расширенного использования заголовка Pragma для указания серверу явным образом возможностей и предпочтений пользователя, касающихся представления и поведения документа HTML.

Этот документ не является нормативным.