Skip to content

Instantly share code, notes, and snippets.

View ivansky's full-sized avatar
😊
Wubba lubba dub dub!

Ivan Martianov ivansky

😊
Wubba lubba dub dub!
  • Armenia, Yerevan
View GitHub Profile
@ivansky
ivansky / example.jsx
Created April 26, 2019 13:33
React how to attach scroll event and measure DOM elements
import throttle from 'lodash/throttle';
class Component {
someSectionRef = null;
componentDidMount() {
// check window object existing, to not listen events in SSR
if(window) {
window.addEventListener('scroll', this.onScroll);
}
@ivansky
ivansky / pathfinder.js
Created September 27, 2020 18:00
Pathfinder Calculation
const original = [1, 0, 0, 0, 1, 1, 0];
const relations = {
1: [1, 2, 6],
2: [1, 2],
3: [3, 5],
4: [4, 5, 6],
5: [3, 4, 5],
6: [1, 4, 6],
};
@ivansky
ivansky / Catalog.tsx
Created May 10, 2022 14:03
Catalog.tsx
import React, { useEffect, useState } from "react";
import { render } from "react-dom";
import generateRandomWord from "random-words";
interface Data {
id: string;
data: string;
}
const DATA_CHUNK = 10;
@ivansky
ivansky / download_telegram_cache_video.js
Created November 19, 2023 14:02
web telegram save cached video
// web telegram stream video from cache
// it probably uses shared/webworkers to save bytes chunks into cache storage
// so once video is fully cached it could be saved from cache to device
// browser could ask to allow parallel files downloads from web telegram domain, just allow it
(async function downloadCachedVideos() {
// global downloaded set is to prevent downloading videos were alreadt downloaded
window.downloaded = window.downloaded || new Set([])
function saveVideo(outname, dataArray) {
console.log(`Start downloading ${outname} with ${dataArray.length} chunks`)