Skip to content

Instantly share code, notes, and snippets.

View RinatValiullov's full-sized avatar
👷‍♂️
Looking for a job

Rinat Valiullov RinatValiullov

👷‍♂️
Looking for a job
View GitHub Profile
@Raynos
Raynos / a.md
Created January 23, 2012 19:48
Shim status of ES6

ES6 what can be shimmed and what not.

Currently only lists things that can be shimmed or are experimentally implemented

Note that for any kind of decent ES6 support we need an ES6 transpiler. A few projects are attempting this [Reference SO question][3]

  • [traceur][4]
  • [Caja][5]
  • [ES transpiler][6]
@Jarred-Sumner
Jarred-Sumner / Stylefile.yml
Last active January 3, 2019 01:49
Customizations for news.ycombinator.com via StyleURL.
---
version: 1.0
domains:
- news.ycombinator.com
url_patterns:
- news.ycombinator.com/*
timestamp: '2018-07-11T06:39:04Z'
id: 3TMk
redirect_url: https://news.ycombinator.com/
shared_via: StyleURL – import and export CSS changes from Chrome Inspector to a Gist
@obenjiro
obenjiro / css-methodologies-from-o-to-b.md
Last active February 5, 2019 11:36
CSS Методологии, от О до Б
@rauschma
rauschma / execAll.js
Last active April 7, 2019 12:09
A version of RegExp.prototype.exec() that returns an iterable
console.log(extractQuotedTextES5('“a” and “b” or “c”')); // [ 'a', 'b', 'c' ]
// If exec() is invoked on a regular expression whose flag /g is set
// then the regular expression is abused as an iterator:
// Its property `lastIndex` tracks how far along the iteration is
// and must be reset. It also means that the regular expression can’t be frozen.
var regexES5 = /“(.*?)”/g;
function extractQuotedTextES5(str) {
regexES5.lastIndex = 0; // to be safe
var results = [];
@eligrey
eligrey / outerHTML.js
Created June 24, 2011 02:56
Efficient outerHTML polyfill that doesn't use cloneNode(true)
/*
* outerHTML.js
* Cross-browser full HTMLElement.outerHTML implementation.
*
* 2011-11-14
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@tgtmpaccount
tgtmpaccount / foo.txt
Created February 10, 2019 04:09
Vimium Configuration for DevTools
unmapAll
map j scrollDown
map k scrollUp
map q removeTab
map Q restoreTab
map h previousTab
map l nextTab
map r reload
map R reload hard
map l- goToRoot
@adactio
adactio / timestampComparison.js
Last active July 30, 2019 14:51
Compare server and client timestamps
// Generate a timestamp (in seconds) on the server. This won't change if the page is served from a cache.
var serverTimestamp = <?php echo time(); ?>;
// Create a new Date object from the local date and time on the client.
var localDate = new Date();
// Convert the local date and time to Universal Time (same as the server).
var localUTCString = localDate.toUTCString();
// Create a new Date object from the UTC date and time on the client.
var UTCDate = new Date(localUTCString);
// Generate a timestamp (in seconds) from the UTC date and time on the client.
var clientTimestamp = UTCDate.getTime() / 1000;
@rolandinsh
rolandinsh / gist:3510701
Created August 29, 2012 11:04
Do Not Track (DNT) detect with PHP code
function get_smc_dnt() {
/*
* Do Not Track for privacy.
* When this feature is enabled, webpage should exclude all tracking tools,
* like Google Analytic and advertising networks
*/
// returns TRUE if DNT is on and is equal to 1,
// returns FALSE if DNT is unset OR not equal to 1
return (isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] == 1);
}

Summary: .global (/g) and .sticky (/y)

/g /y /yg
.exec() at .lI or later at .lI same as /y
.test() at .lI or later at .lI same as /y
.replace() ignores & resets .lI at .lI /g w/o gaps
.replaceAll() ignores .lI TypeError /g w/o gaps
.search() no effect no effect no effect
.match() Array of group 0 captures like .exec() /g w/o gaps
@fta2012
fta2012 / ReplicatedRandomChrome.js
Last active January 15, 2020 05:44
EDIT: This code no longer works on chrome but still works for legacy versions of node. Updated code moved to https://github.com/fta2012/ReplicatedRandom/tree/master/node.
var rngstate;
function MathRandom() {
// Our own implementation of Math.random().
// Source code was copied from https://github.com/v8/v8/blob/4.6.85/src/math.js#L131
// You need to initialize rngstate with `solve` before this can be used.
// If using node.js, you have to s/18030/18273/g here and in `solve` since they implement it slightly differently: https://github.com/nodejs/node-v0.x-archive/blob/d13d7f74d794340ac5e126cfb4ce507fe0f803d5/deps/v8/src/math.js#L146
console.assert(rngstate, "You need to set the global variable `rngstate` first. For example: `rngstate = solve(Math.random(), Math.random());`");
if (!rngstate) return;
var r0 = (Math.imul(18030, rngstate[0] & 0xFFFF) + (rngstate[0] >>> 16)) | 0;
rngstate[0] = r0;