Skip to content

Instantly share code, notes, and snippets.

View vsemozhetbyt's full-sized avatar

Vse Mozhe Buty vsemozhetbyt

View GitHub Profile
'use strict';
const { writeFileSync } = require('fs');
const LAST_CODE_POINT = 0x10FFFF;
const RegExps = [/./u, /^(?!.)/, /\w/u, /\W/u, /\d/u, /\D/u, /\s/u, /\S/u, /\b/u, /\B/u];
let codePoint = 0;
let str;
let data = '';
@vsemozhetbyt
vsemozhetbyt / node-tests-cwd.js
Last active May 3, 2017 15:32
Find cwd-dependent Node.js tests
/******************************************************************************/
'use strict';
/******************************************************************************/
const cp = require('child_process');
const fs = require('fs');
const path = require('path');
/******************************************************************************/
const rootPath = 'j:/temp/node-master';
const nodePath = `${rootPath}/Release/node.exe`;
const overPath = path.resolve(rootPath, '..');
const Word = 'Word'; // In the beginning was the Word,
const God = {
get [Word]() { // and the Word was with God,
return this; // and the Word was God.
},
};
console.log(God.Word === God); // The same was in the beginning with God.
@vsemozhetbyt
vsemozhetbyt / node-check-collaborators.js
Last active May 11, 2017 15:07
Check if comment authors in PRs are Node.js collaborators
javascript: {
getCollaboratorsUsernames();
function getCollaboratorsUsernames() {
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://github.com/nodejs/node/blob/master/README.md', true);
xhr.responseType = 'document';
xhr.withCredentials = true;
xhr.onload = markAuthorsLinks;
xhr.ontimeout = xhr.onerror = (evt) => { console.log(evt); };
@vsemozhetbyt
vsemozhetbyt / node-check-commit-messages.js
Last active April 8, 2017 16:30
Check commit messages in PRs for Node.js repository
javascript: {
const validPathname = /^\/nodejs\/node\/pull\/\d+(?:\/commits)?$/;
const TITLE_MAX_LENGTH = 50;
const LINE_MAX_LENGTH = 72;
const titleFormat = /^([\d_a-z ,-]+)\b: ([a-z'-]+\b)?/;
const lineWithURLFormat = /^(Fixes|Refs?): (https?:)?/;
const LOG_DELIMITER_LENGTH = 20;
@vsemozhetbyt
vsemozhetbyt / gist:353a8e0bcd8eae912b06fafa2960bb83
Created March 15, 2017 18:52
str.split vs spread: unicodewise
'use strict';
const str = '\ud83d\udc0e'.repeat(1e4); // 🐎
const re = new RegExp('', 'u'); // or /[^]{0}/u
let symbols;
let i;
console.time('RegExp');
for (i = 0; i < 1e4; i++) symbols = str.split(re);
@vsemozhetbyt
vsemozhetbyt / gist:248ce22a42fe1b0e21a17a00eb5f02ae
Last active March 15, 2017 14:53
Ignition + TurboFan: Node.js benchmarks: buffers
improvement confidence p.value
buffers\\buffer-base64-decode.js n=32 -0.03 % 6.813796e-01
buffers\\buffer-base64-encode.js n=32 len=67108864 0.10 % 7.395115e-02
buffers\\buffer-bytelength.js n=5000000 len=1 encoding="base64" 16.14 % *** 5.629742e-46
buffers\\buffer-bytelength.js n=5000000 len=1 encoding="utf8" -36.00 % *** 2.712131e-60
buffers\\buffer-bytelength.js n=5000000 len=16 encoding="base64"
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
@vsemozhetbyt
vsemozhetbyt / test-polymorphic-apply.js
Last active January 26, 2017 10:34
Deoptimization due to polymorphic `func.apply(context, arguments)`
function functionToCheckMonomorphic(functionToApplyMonomorphic) {
functionToApplyMonomorphic.apply(null, arguments);
}
function functionToCheckPolymorphic(functionToApplyPolymorphic) {
functionToApplyPolymorphic.apply(null, arguments);
}
const functionToApplyCommon1 = function () {};
const functionToApplyCommon2 = function () {};
@vsemozhetbyt
vsemozhetbyt / pbt.js
Last active January 20, 2017 18:21
pbt.js
/******************************************************************************/
'use strict';
/******************************************************************************/
// title progress bar as a module
module.exports = function pbt(edge = 0) {
const savedTitle = process.title;
const DEFAULT_FREQ = 500;
const HUNDRED_PERCENT = 100;