Skip to content

Instantly share code, notes, and snippets.

View Connormiha's full-sized avatar

Mikhail Connormiha

  • Cyprus
View GitHub Profile
@Connormiha
Connormiha / spread vs unshift.js
Created July 18, 2024 14:13
spread vs unshift
// spread.js
let a = [];
console.time('1');
for (let i = 0; i < 100; i++) {
const res = [];
for (let j = 0;j<5;j++) {
res.push(j);
}
a = [...res, ...a];
@Connormiha
Connormiha / array_set_number
Created January 31, 2023 21:26
Array<number> vs Set<number> includes vs has
const ids = Array.from({ length: 50000 }).map((_, i) => i).sort();
const s = new Set(ids);
let a;
let b;
console.time('set');
a = s.has(25000);
console.timeEnd('set');
(function(rootId) {
var appStates = []
var reactRoot = document.querySelector('#' + rootId);
var base
var downloadBlock = document.createElement('a');
downloadBlock.style = 'position:fixed;left: 49%; top: 0;z-index: 10000;background:rgba(255,255,255,0.7);color:#000;padding:10px';
downloadBlock.innerHTML = 'Download store';
downloadBlock.download = 'store.txt';
downloadBlock.target = '_blank';
document.body.appendChild(downloadBlock);
(function(){
const block = document.createElement('div');
block.style = `
z-index:1000;position:fixed;right:0;top:0;background:rgba(255,255,255,0.8);color:#000;padding:20px;white-space:pre;
overflow: auto;
width: 700px;
max-width: vw;
font-size: 13px;
`.replace(/\s/g, '');
block.ondblclick = () => {

Какое наименьшее целое значение k необходимо подать на вход программы, чтобы в результате её выполнения напечаталось число 12?

k = int(input())
s = 10
while s < k:
    s += 1
    k -= s
print(s)
(function() {
const block = document.createElement('div');
document.body.appendChild(block);
block.setAttribute(
'style',
'position:fixed;top:0;right:0;z-index:99999;background:rgba(255,255,255,.8);color:#000;max-width:100%;width:400px;padding:10px;'
);
block.ondblclick = () => {
if (block.style.right !== 'auto') {
block.style.right = 'auto';
(function(rootId) {
var appStates = []
var reactRoot = document.querySelector('#' + rootId);
var base
try {
base = reactRoot._reactRootContainer._internalRoot.current
} catch (e) {
console.log('Could not get internal root information from reactRoot element')
}
@Connormiha
Connormiha / process.platform.js
Created April 21, 2019 13:26
Get for checing process.platform in Node
'use strict';
function testWithoutCache() {
let count = 0;
for (let i = 0; i < 100000; i++) {
if (process.platform === 'win32') {
count++;
}
}
# Remove all your local git branches but keep master
git branch | grep -v "master" | xargs git branch -D
var deps = [];
for (var i = 0; i < 1000; i++) {
deps.push('foo_' + i + Math.random());
deps.push( i % 3 ? null : 'foo');
}
function compact(array) {
const result = [];
for (let i = 0; i < array.length; ++i) {