This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number} year | |
* @return {Date} | |
*/ | |
function getBlackFridayDate(year) { | |
const date = new Date(year, 10, 1); // first day of November | |
const day = date.getDay(); | |
if (day < 4) { | |
date.setDate(date.getDate() + (4 - day)); // first Thusday of November | |
} else if (day > 4) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseData(data) { | |
return data | |
.split("\n") | |
.filter(Boolean) | |
.map(function (row) { return Number.parseInt(row); }) | |
.map(function (capacity, index) { return ({ id: index + 1, capacity: capacity }); }); | |
} | |
function getTotalCapacity(batteries) { | |
return batteries | |
.map(function (_a) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function isNginxRouteSPA(route) { | |
const url = new URL(route, window.location.origin); | |
url.searchParams.set('_timestamp', Date.now().toString(16)); | |
const response = (await fetch(url.toString(), { "method": "GET", "credentials": "include" })); | |
return response.headers.get('x-app-type') === 'SPA'; | |
} | |
export function isCurrentPageSPA() { | |
return Array.from(document.getElementsByTagName('meta')) | |
.some(el => el.name === 'version'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs'); | |
const readline = require('readline'); | |
const dictioary = []; | |
const classes = ['indefinite article', 'determiner', 'v', 'n', 'adj', 'prep', 'adv', 'conj', 'predeterminer', 'pron', 'interjection', 'auxiliary', 'modal', 'number', 'definite article']; | |
const frequencies = ['S1', 'S2', 'S3', 'W1', 'W2', 'W3']; | |
const rl = readline.createInterface({ | |
input: fs.createReadStream('longman_communication_3000.txt'), | |
crlfDelay: Infinity, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TextMask.maskInput({ | |
inputElement: document.querySelector("input[name = cadastral_number]"), | |
mask: function(rawValue) { | |
var mask = [/\d/, /\d/, ":", /\d/, /\d/, ":"]; | |
var chunks = rawValue.replace(/\_/g, "").split(":"); | |
var i; | |
for (i = 0; (!chunks[2] || i < chunks[2].length) && i < 7; i++) { | |
mask.push(/\d/); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function array_intersect_key_recursive(array $array, array ...$arrays) | |
{ | |
$array = array_intersect_key($array, ...$arrays); | |
foreach (array_keys($array) as $key) { | |
if (is_array($array[$key])) { | |
$array[$key] = array_intersect_key_recursive( | |
$array[$key], | |
...array_map( |