Skip to content

Instantly share code, notes, and snippets.

View subzey's full-sized avatar

Anton Khlynovskiy subzey

View GitHub Profile
@subzey
subzey / index.html
Created June 25, 2018 17:11
jq 1.7 cache leak
<!doctype html>
<html>
<head>
<title>jQuery 1.7.2 cache leak</title>
</head>
<body>
<script src="https://code.jquery.com/jquery-1.7.2.min.js" crossorigin="anonymous"></script>
<script>
(function(){
var leaky = new function Leaky(){};
@subzey
subzey / index.html
Last active June 18, 2018 12:19
Self-replacement scripts
<!doctype html>
<html>
<body>
<p>Local resolve (<code>selfreplacement.js</code>): <script async defer src="selfreplacement.js">#1: OKAY</script>
<p>Local resolve (<code>./selfreplacement.js</code>): <script async defer src="./selfreplacement.js">#2: OKAY</script>
<p>bl.ocks full: <script async defer src="https://bl.ocks.org/subzey/raw/ccd85c8c424120350157a5a4a3b9c47d/selfreplacement.js">#3: OKAY</script>
<p>bl.ocks protocol-relative: <script async defer src="//bl.ocks.org/subzey/raw/ccd85c8c424120350157a5a4a3b9c47d/selfreplacement.js">#4: OKAY</script>
<p>rawgit full: <script async defer src="https://rawgit.com/subzey/ccd85c8c424120350157a5a4a3b9c47d/raw/selfreplacement.js">#5: OKAY</script>
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++) {
@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
@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,
/* Изменение проперти */
html {
- color: red;
+ color: green;
}
/* Добавление проперти */
html {
color: red;
+ margin: 0;
@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 && '→'
@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);
})();
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 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>