Skip to content

Instantly share code, notes, and snippets.

View subzey's full-sized avatar

Anton Khlynovskiy subzey

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {
background: #f5f6f7;
display: flex;
flex-flow: wrap;
justify-content: center;
@subzey
subzey / index.js
Last active November 22, 2017 17:02
Concatenated gzip test
#!/usr/bin/env node
var http = require('http');
var os = require('os');
var url = require('url');
var zlib = require('zlib');
var buf1 = zlib.gzipSync('Conca');
var buf2 = zlib.gzipSync('tenated');
var port = 8080;
@subzey
subzey / index.html
Created December 25, 2017 13:23
Happy holidays '18
<body onload="s=[7,0,15,15,24,-9366,7,14,11,8,3,0,24,18].map(v=>v+9398);setInterval(`b.innerText=String.fromCodePoint(...s=s.map(v=>32<v&Math.random()<.3?v+117914*(v<1e4||-1):v))`,500)"id=b>
console.log('Number of unique 5 bytes unordered sets.');
console.log('Calculating the long way... (it may take a while)')
const MAX = 64;
let setSize = 0;
for (let i = 0; i <= MAX; i++) {
for (let j = i; j <= MAX; j++) {
for (let k = j; k <= MAX; k++) {
for (let l = k; l <= MAX; l++) {
for (let m = l; m <= MAX; m++) {
@subzey
subzey / index.html
Created February 5, 2018 12:20
Rel noopener
<p><a href="slow.html" target="_blank">Open slow page</a></p>
<canvas id="a"></canvas>
<script>
var a = document.getElementById('a');
var c = a.getContext('2d');
(function frame(){
c.clearRect(0, 0, 300, 150);
c.fillRect(Math.cos(Date.now() / 100) * 125 + 125, 0, 50, 50);
requestAnimationFrame(frame);
})();
@subzey
subzey / index.html
Created February 5, 2018 18:16
lurdl
<script>
top.onkeyup=top.onkeydown=(e)=>top['lurdl+d+l+ur+u'[(e.which+3)%20]]=e.type[5]
</script>
<script>
setInterval(_ => document.body.textContent = [
top.l && '←',
top.u && '↑',
top.d && '↓',
top.r && '→'
/* Изменение проперти */
html {
- color: red;
+ color: green;
}
/* Добавление проперти */
html {
color: red;
+ margin: 0;
@subzey
subzey / dumb.js
Last active March 13, 2018 14:54
JS minification/compression quiz
var arr = [
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@subzey
subzey / test.sh
Created March 16, 2018 17:46
Uncompressed PNG and Broli
#!/bin/bash
if [ $1 ]
then sourceurl=$1
else sourceurl="https://upload.wikimedia.org/wikipedia/ru/2/24/Lenna.png"
fi
echo "downloading the test image ($sourceurl)..."
curl --silent $sourceurl > /tmp/source.png
function distanceBetweenPoints(p1, p2) {
return Math.hypot(p1.x - p2.x, p1.y - p2.y);
}
function closestPoints(points) {
let closestPoints = [];
let smallestDistance = Infinity;
for (let i = 1; i < points.length; i++) {
for (let j = 0; j < i; j++) {