Skip to content

Instantly share code, notes, and snippets.

View spirinvladimir's full-sized avatar
💭
💯

Spirin Vladimir spirinvladimir

💭
💯
View GitHub Profile
@spirinvladimir
spirinvladimir / monkeytype_zen_export.js
Created July 1, 2025 06:25
Export text from Monkeytype Zen mode
console.log([...document.getElementsByTagName('letter')].reduce(
(text, $) => text + $.textContent,
''
))
@spirinvladimir
spirinvladimir / pool2pair.js
Created June 13, 2025 15:51
Get a pairs by pool addresses using Etherscan.io
make_url = a => `https://etherscan.io/address/${a}#notes`
a = new Set()
Object.keys(state.exchanges.uniswap_v3).forEach(t0 => {
Object.keys(state.exchanges.uniswap_v3[t0]).forEach(t1 => {
a.add(state.exchanges.uniswap_v3[t0][t1])
})
})
var m = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
]
const N = [].concat(
function insert (node, x) {
if (x < node.value) {
if (node.left) {
if (x < node.left.value) {
insert(node.left, x)
} else {
node.left = {value: x, left: node.left}
}
} else {
node.left = {value: x}
@spirinvladimir
spirinvladimir / replace_without_case_sensitive.js
Created February 20, 2020 10:23
function should replace in string A to B without case sensitive between A and B
function replace_without_case_sensitive (where, from, to) {
return where.toLowerCase().split(from.toLowerCase()).reduce(
(acc, _) =>
[
acc[0] + _.length + from.length,
acc[1].concat(where.substring(acc[0], acc[0] + _.length))
],
[0, []]
)[1].join(to)
}
@spirinvladimir
spirinvladimir / 1.js
Last active November 6, 2019 09:26
Amazon - Online Assessment
function cellCompete(states, days) {
if (days === 0) return states
const a = new Array(states.length)
states.push(0)
states.unshift(0)
for (var i = 1; i < states.length - 1; i++)
a[i - 1] = states[i - 1] === states[i + 1]
? 0
: 1
return cellCompete(a, days - 1)
var deferred = require('deferred');
var assert = require('assert');
describe('deferred', function () {
it('map', function (done) {
var def1 = deferred();
var def2 = deferred();
setTimeout(function () {
def1.resolve(1);
@spirinvladimir
spirinvladimir / promise_redis.js
Created April 9, 2019 20:41
Node.js callback -> Promises , PS: many thanks Redis
new Promise((y, n) => redis((e, db) => e ? n(e) : y(db)))
@spirinvladimir
spirinvladimir / max_malloc.js
Created February 12, 2019 06:31
Max memory allocation at browser
var i = 0;
var bigest = (bytes) => {
console.log(i++, bytes);
try {
return new ArrayBuffer(bytes)
} catch (e) {
return bigest(bytes / 2)
}
}
@spirinvladimir
spirinvladimir / 100.js
Last active October 31, 2018 08:31
Solution for task "Sum 100" by https://www.diginex.com
/*Question 1: Sum to 100
Write a function that, given a string of digits, build an expression such that the digits will sum to 100 by inserting +, - anywhere between the digits.
For example, given the input 123456789, one such expression is 1 + 23 - 4 + 5 + 6 + 78 - 9 = 100
Your function should return all possible combinations.
*/
var results = {};
function calc(n, s, part) {
if (n === 0 && s === '' && part[0] !== '-') return results[part.substring(1)] = null