Skip to content

Instantly share code, notes, and snippets.

View dmitriypereverza's full-sized avatar
💻

Dmitriy Pereverza dmitriypereverza

💻
View GitHub Profile
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
position: relative;
background: gray;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bitmap Visualization</title>
<style>
body {
display: flex;
flex-direction: column;
@dmitriypereverza
dmitriypereverza / DDA.visual.html
Last active December 5, 2024 12:59
Raycasting DDA (walls and doors)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DDA Visualization</title>
<style>
canvas {
border: 1px solid black;
display: block;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
position: relative;
background: gray;
@dmitriypereverza
dmitriypereverza / PathsInRecord.ts
Created May 7, 2023 13:09
Type for obtain recursive paths in record
const data = {
env: {
name: "",
payload: {
price: 0,
size: 0,
},
},
};
@dmitriypereverza
dmitriypereverza / compareDeps.tsx
Created October 27, 2022 08:36
Debug deps in react
import { isEqual } from 'lodash';
function getObjectDiff(obj1: any, obj2: any) {
return Object.keys(obj1).reduce((result, key) => {
if (!obj2.hasOwnProperty(key)) {
result.push(key);
} else if (isEqual(obj1[key], obj2[key])) {
const resultKeyIndex = result.indexOf(key);
result.splice(resultKeyIndex, 1);
}
@dmitriypereverza
dmitriypereverza / composeSubComponents.tsx
Created October 29, 2021 06:45
composeSubComponents func (with types)
function composeSubComponents<
BASE extends React.ComponentType<any>,
SUBCOMPONENTS extends Record<string, React.ComponentType<any>>,
>(baseCmp: BASE, subComponents: SUBCOMPONENTS) {
return Object.assign(baseCmp, subComponents);
}
const DefaultCmp = composeSubComponents(React.memo(FlyCard), {
Layout,
@dmitriypereverza
dmitriypereverza / Kosaraju.js
Created October 4, 2021 17:03
Kosaraju algorithm
function createGraph(nodes, edges) {
const result = nodes.reduce((acc, el) => {
acc[el] = [];
return acc;
}, {});
for (let edge of edges) {
result[edge[0]].push(edge[1]);
}
return result;
}
@dmitriypereverza
dmitriypereverza / vueMpa.js
Created May 30, 2021 11:46
Vue mpa integration
import Vue from "vue";
Vue.config.productionTip = false;
function getProps(cmpNode) {
return Object.keys(cmpNode.dataset)
.filter((propKey) => propKey.startsWith("prop"))
.reduce((acc, propKey) => {
const propName = propKey.slice(4).toLowerCase();
return {
const path = require("path");
const Git = require("nodegit");
const pathToRepo = path.resolve("./.git");
async function main({ otherBranch }) {
const res = await getGitDiffsFromCurrent({ otherBranch });
console.log(JSON.stringify(res));
}