Skip to content

Instantly share code, notes, and snippets.

@victor-homyakov
victor-homyakov / APIs affecting bfcache.md
Last active August 10, 2024 22:35
API, которые влияют на попадание страницы в bfcache
  • ✔︎ - не мешает попаданию страницы в bfcache
  • ✘ - запрещает попадание страницы в bfcache
  • пустая ячейка - влияние неизвестно
API Firefox Safari Chromium IE
Подписка на beforeunload
Подписка на unload
Незавершённые запросы XHR/fetch ✘ в планах прерывать запрос и вызывать onerror при восстановлении страницы
Незавершённые запросы за ресурсами ✘ кроме favicon
@mrfolkblues
mrfolkblues / window.location.origin-polyfill.txt
Last active January 31, 2019 20:39
window.location.origin Polyfill
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
@shospodarets
shospodarets / Chrome headless Puppeteer- capture DOM element screenshot using
Last active July 29, 2024 05:58
Chrome headless Puppeteer- capture DOM element screenshot using
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1});
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'});
@ravibhure
ravibhure / git_rebase.md
Last active October 1, 2024 12:39
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@arv
arv / test.js
Created February 20, 2015 01:38
Map -0 bug
var assert = {
equal: function(x, y) {
if (x === y) return;
throw new Error();
},
isTrue: function(x) {
if (x) return;
throw new Error();
}
};

RegExp.escape(string)

Computes a new version of a String value in which certain characters have been escaped, so that the regular expression engine will interpret any metacharacters that it may contain as character literals.

When the escape function is called with one argument string, the following steps are taken:

  1. Let string be ToString(string).
  2. ReturnIfAbrupt(string).
  3. Let length be the number of characters in string.
  4. Let R be the empty string.
@JamesMGreene
JamesMGreene / clipboard.md
Last active August 29, 2015 13:56
HTML5 Clipboard API enhancements
@Yaffle
Yaffle / websql.php
Last active April 30, 2020 18:52
Web SQL Database API for PHP
<?php
/* usage:
$db = new Database("mysql:host=" . Config::$dbHost . ";dbname=" . Config::$dbName . ";", Config::$dbName, Config::$dbUser, Config::$dbPass);
$db->changeVersion("", "1", function ($tx) {
$tx->executeSql("CREATE TABLE IF NOT EXISTS `examples` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`example` mediumtext,
PRIMARY KEY (`id`)
@mathiasbynens
mathiasbynens / url-code-points.js
Last active October 27, 2016 14:46
Let’s create a JavaScript-compatible regular expression that matches any URL code point, as per the URL Standard.
// “The URL code points are ASCII alphanumeric, "!", "$", "&", "'", "(", ")",
// "*", "+", ",", "-", ".", "/", ":", ";", "=", "?", "@", "_", "~", and code
// points in the ranges U+00A0 to U+D7FF, U+E000 to U+FDCF, U+FDF0 to U+FFEF,
// U+10000 to U+1FFFD, U+20000 to U+2FFFD, U+30000 to U+3FFFD, U+40000 to
// U+4FFFD, U+50000 to U+5FFFD, U+60000 to U+6FFFD, U+70000 to U+7FFFD, U+80000
// to U+8FFFD, U+90000 to U+9FFFD, U+A0000 to U+AFFFD, U+B0000 to U+BFFFD,
// U+C0000 to U+CFFFD, U+D0000 to U+DFFFD, U+E1000 to U+EFFFD, U+F0000 to
// U+FFFFD, U+100000 to U+10FFFD.”
// — http://url.spec.whatwg.org/#url-code-points
@Yaffle
Yaffle / Math.nextUp.js
Last active February 2, 2017 22:49
Math.nextAfter, Math.nextDown, Math.nextUp, Math.ulp in javascript
(function (global) {
"use strict";
// Math.nextUp
// Note:
// Math.nextDown = function (x) { return -Math.nextUp(-x); };
// Math.nextAfter = function (x, y) { return y < x ? -Math.nextUp(-x) : (y > x ? Math.nextUp(x) : (x !== x ? x : y)); };
// Math.ulp = function (x) { return x < 0 ? Math.nextUp(x) - x : x - (-Math.nextUp(-x)); };
var EPSILON = Math.pow(2, -52);