Skip to content

Instantly share code, notes, and snippets.

View vanchelo's full-sized avatar
💭
Life is good

Brezhniev Ivan vanchelo

💭
Life is good
View GitHub Profile
@umputun
umputun / safari-summary.sh
Last active May 21, 2024 07:06
Raycast script for Safari's page summary
#!/bin/sh
# @raycast.schemaVersion 1
# @raycast.title Summarize Safari page
# @raycast.mode fullOutput
#
# Optional parameters:
# @raycast.icon ✨
#
# @raycast.packageName Things
@jfet97
jfet97 / DFS.js
Last active August 26, 2023 10:02
Simple Depth First Search in JavaScript
function isObject(entity) {
return typeof entity === "object" && entity !== null;
}
function getAdjacentNodes(obj) {
return (
Object.entries(obj)
.filter(([, v]) => isObject(v))
)
}
@joshuabradley012
joshuabradley012 / Object collisions with canvas
Last active January 26, 2024 07:56
An example of 2D collisions using JavaScript Canvas
class State {
constructor(display, actors) {
this.display = display;
this.actors = actors;
}
update(time) {
/**
* provide an update ID to let actors update other actors only once
@Kurzdor
Kurzdor / README.md
Last active February 10, 2021 20:07
@scarf/scarf mock

I created a gist which can patch Scarf Analytics (@scarf/scarf on npm) with this Gist that replaces this lib on postinstall because NPM/Yarn gives you an ability to install any gist or repository like any package to node_modules folder.

Before you install it, delete @scarf/scarf folder in your local project node_modules folder if present (probably you are using some of this packages) or if you are going to install any of those packages in your current project.

Install mock version from Gist instead of local project version which sends your data with this commands depending of what package manager you use:

npm install --save-dev gist:bd5c18861b76eb34f068bf2ed7de903e
yarn add gist:bd5c18861b76eb34f068bf2ed7de903e --dev
pnpm install --save-dev gist:bd5c18861b76eb34f068bf2ed7de903e
@MarsiBarsi
MarsiBarsi / mark-control-and-update.ts
Created June 11, 2020 10:54
Mark control and update validity function
import {AbstractControl, FormArray, FormGroup} from '@angular/forms';
export function markControlAsTouchedAndValidate(control: AbstractControl) {
if (control instanceof FormArray) {
control.controls.forEach(nestedControl => {
markControlAsTouchedAndValidate(nestedControl);
});
return;
}
export const h=(t,p,...c)=>({t,p,c,k:p&&p.key})
export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=>
// arrays
e.map?e.map((e,p)=>render(e,d,t.o&&t.o[p])):
// components
e.t.call?(e.i=render((render.c=e).t(Object.assign({children:e.c},e.p),e.s=t.s||{},t=>
render(Object.assign(e.s,t)&&e,d,e)),t.i||d,t&&t.i||{}),d.t=t=e):(
// create notes
m=t.d||(e.t?document.createElement(e.t):new Text(e.p)),
// diff props
@irustm
irustm / AngularVsReact.md
Last active April 8, 2024 09:47
Angular vs React

На случай важных переговоров

[11.01.18 18:47] [Forwarded from Алексей Охрименко]

  1. Google, Microsoft
  2. Typescript из коробки
  3. Единственный вреймворк с Dependency Injection из коробки
  4. Не нужно ничего React-ить и AngularJS-ифаить. Больше никаких оберток. jQuery плагины и D3 можно использовать на прямую
  5. Более современный фреймворк
@gaearon
gaearon / uselayouteffect-ssr.md
Last active May 16, 2024 14:13
useLayoutEffect and server rendering

If you use server rendering, keep in mind that neither useLayoutEffect nor useEffect can run until the JavaScript is downloaded.

You might see a warning if you try to useLayoutEffect on the server. Here's two common ways to fix it.

Option 1: Convert to useEffect

If this effect isn't important for first render (i.e. if the UI still looks valid before it runs), then useEffect instead.

function MyComponent() {
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.
@monochromer
monochromer / promise-patterns.js
Last active August 19, 2022 09:56
Паттерны использования promise (Promise Patterns)
/*
conf: Falsy Values 2015
author: Kornel Lesinski
theme: And .then() what? Promise programming patterns
link: https://www.youtube.com/watch?v=KrhQE8K2I7Q
*/
// 1 waterfall. Использование результатов предыдущих промисов
doFirst()
.then(firstResult => {