Skip to content

Instantly share code, notes, and snippets.

View devxom's full-sized avatar

Ilia A. Reshetnikov devxom

View GitHub Profile
@devxom
devxom / APIs affecting bfcache.md
Created March 1, 2020 17:16 — forked from victor-homyakov/APIs affecting bfcache.md
API, которые влияют на попадание страницы в bfcache
  • ✔︎ - не мешает попаданию страницы в bfcache
  • ✘ - запрещает попадание страницы в bfcache
  • пустая ячейка - влияние неизвестно
API Firefox Safari Chromium IE
Подписка на beforeunload
Подписка на unload
Незавершённые запросы XHR/fetch ✘ в планах прерывать запрос и вызывать onerror при восстановлении страницы
Незавершённые запросы за ресурсами ✘ кроме favicon
@devxom
devxom / gist:b22bfb1aa933bf4a978b09300340ccdc
Created July 30, 2019 07:42 — forked from bessarabov/gist:674ea13c77fc8128f24b5e3f53b7f094
One-liner to generate data shown in post 'At what time of day does famous programmers work?' — https://ivan.bessarabov.com/blog/famous-programmers-work-time
git log --author="Linus Torvalds" --date=iso | perl -nalE 'if (/^Date:\s+[\d-]{10}\s(\d{2})/) { say $1+0 }' | sort | uniq -c|perl -MList::Util=max -nalE '$h{$F[1]} = $F[0]; }{ $m = max values %h; foreach (0..23) { $h{$_} = 0 if not exists $h{$_} } foreach (sort {$a <=> $b } keys %h) { say sprintf "%02d - %4d %s", $_, $h{$_}, "*"x ($h{$_} / $m * 50); }'
// easing functions http://goo.gl/5HLl8
Math.easeInOutQuad = (t, b, c, d) => {
t /= d/2;
if (t < 1) {
return c/2*t*t + b
}
t--;
return -c/2 * (t*(t-2) - 1) + b;
};
function getScrollTopPosition(){
return document.documentElement.scrollTop || document.body.scrollTop || document.body.scrollTop || window.pageYOffset || 0;
}
// because it's so fucking difficult to detect the scrolling element, just move them all
function moveToScrollTop(amount) {
document.documentElement.scrollTop = amount;
document.body.parentNode.scrollTop = amount;
document.body.scrollTop = amount;
}
@devxom
devxom / entrypoint.sh
Created July 16, 2019 22:38 — forked from SharpEdgeMarshall/entrypoint.sh
Monkeypatch yarn issue #761
#!/bin/bash
# Monkeypatching yarn issue #761 installing with --production flag without devDependencies
if [ -n $NODE_ENV ] && [ "$NODE_ENV" == "production" ] || [ "$NODE_ENV" == "staging" ]
then
# Backup package.json and remove devDep
cp package.json original_package.json
jq 'del(.devDependencies)' package.json > tmp.json && mv tmp.json package.json
#Install
@devxom
devxom / to_https.sh
Created April 9, 2019 14:56 — forked from icyflame/to_https.sh
Convert all GitHub git remotes to SSH or HTTPS.
#/bin/bash
#-- Script to automatically convert all git remotes to HTTPS from SSH
# Script will change all the git remotes.
# If you didn't intend to do that, run the other script in this repo.
# Original 1: https://gist.github.com/m14t/3056747
# Original 2: https://gist.github.com/chuckbjones/9dc6634fe52e56ba45ac
# Thanks to @m14t, @michaelsilver and @chuckbjones.
ssh_to_https(){
REPO_URL=`git remote -v | grep -m1 "^$1" | sed -Ene's#.*(git@github.com:[^[:space:]]*).*#\1#p'`
git log --oneline $(git describe --tags --abbrev=0 @^)..@
export const getUniqId = prefix => `${prefix}-${Math.random().toString(36).substr(2, 8)}`;
function setText(node, text) {
let c = node.firstChild
if (c && !c.nextSibling && c.nodeType==3)
c.data = text
else
node.textContent = text
}
@devxom
devxom / package.json
Created April 22, 2018 18:16 — forked from surma/package.json
Boilerplate for quick one-off TypeScript projects. Just run `npm start`
{
"name": "tsquickstart",
"version": "1.0.0",
"description": "Boilerplate for quick one-off TypeScript projects. Just run `npm start`",
"scripts": {
"init": "test -f tsconfig.json || (tsc --init -t ESNext -m ESNext && npm install)",
"start": "npm run init && concurrently \"npm run watch\" \"npm run serve\"",
"serve": "http-server",
"watch": "tsc -p . --watch",
"build": "tsc -p ."