Skip to content

Instantly share code, notes, and snippets.

View kapooostin's full-sized avatar

Vladimir Kapustin kapooostin

View GitHub Profile
@slikts
slikts / advanced-memo.md
Last active September 12, 2024 18:33
Advanced memoization and effects in React

nelabs.dev

Advanced memoization and effects in React

Memoization is a somewhat fraught topic in the React world, meaning that it's easy to go wrong with it, for example, by [making memo() do nothing][memo-pitfall] by passing in children to a component. The general advice is to avoid memoization until the profiler tells you to optimize, but not all use cases are general, and even in the general use case you can find tricky nuances.

Discussing this topic requires some groundwork about the technical terms, and I'm placing these in once place so that it's easy to skim and skip over:

  • Memoization means caching the output based on the input; in the case of functions, it means caching the return value based on the arguments.
  • Values and references are unfortunately overloaded terms that can refer to the low-level implementation details of assignments in a language like C++, for example, or to memory
@tylearymf
tylearymf / Photoshop_charID_stringID_List
Created January 17, 2020 03:27
Photoshop charID List
test

Challenge

Write a function of type String -> Integer. The input may or may not be a valid JSON string. If it is valid, the resulting JavaScript value is expected to be an object, but may not be. If it is an object, it is expected to have a foo property whose value is expected to be an object, but may not be. This value is expected to have a bar property which is expected to be an object with a baz property whose value is expected to be an array of strings. Each of these strings is expected to be a hex representation of an integer (e.g. 0xFF). If every element of the array meets this expectation, the

@AgentOak
AgentOak / youtube_formats.md
Last active September 11, 2024 20:20
Youtube Format IDs

Last updated: April 2021

Also known as itag or format codes and way back they could be specified with the fmt parameter (e.g. &fmt=22). Depending on the age and/or popularity of the video, not all formats will be available.

DASH video

Resolution AV1 HFR High AV1 HFR AV1 VP9.2 HDR HFR VP9 HFR VP9 H.264 HFR H.264
MP4 MP4 MP4 WebM WebM WebM MP4 MP4
@adleroliveira
adleroliveira / recur.js
Created January 19, 2017 20:45 — forked from CreaturePhil/recur.js
A Million Ways to Fold in JS Notes
// from http://forwardjs.com/university/a-million-ways-to-fold-in-js
'use strict'
const first = (xs) => xs[0]
const rest = (xs) => xs.slice(1)
const concat = (xs1, xs2) => xs1.concat(xs2)
// recursion
const sum = (xs) => {
@i-am-tom
i-am-tom / Main.elm
Created December 11, 2016 12:36
The Orrery
-- ## An Elm-entary visualisation
-- by _Tom Harding_
module Main exposing (..)
-- This project uses a few dependencies. To anyone who's written any
-- amount of Elm before, the only stranger is `AnimationFrame`, from
-- the `elm-lang/animation-frame` package. This lets us subscribe to
-- the browser's RAF API. Everything else should be fairly obvious:
-- `Html` / `Svg` for our view, `Http` / `Json.Decode` for the AJAX
@Shutik
Shutik / gist:908b8ce4ce432540e14bd8927e2edeb1
Created October 26, 2016 03:34
Cумма прописью, js
Number.prototype.toPhrase=function(c)
// сумма прописью для чисел от 0 до 999 триллионов
// можно передать параметр "валюта": RUB,USD,EUR (по умолчанию RUB)
{
var x=this.roundTo(2);
if (x<0 || x>999999999999999.99) return false;
var currency='RUB';
if (typeof(c)=='string')
currency=c.trimAll().toUpperCase();
@jonathantneal
jonathantneal / README.md
Last active August 25, 2022 04:10
CSS Modules in PHP

CSS Modules lets you write and use simple class names rather than remembering and maintaining long unique class names for every component. CSS Modules mutates all of your classnames from each partials into new, completely unique classnames that will not conflict when they are bundled together into your main CSS file. Then, a JSON file is generated that maps the happy classnames from each file to the unique classname in the combined file. You load this map in PHP, and begin using the easy-to-remember classnames as you wish.

@jonphipps
jonphipps / whoops.base.css
Created January 30, 2016 22:38
Small fix to whoops 2.0 css
.frame-file .editor-link {
color: #67B3FF;
text-decoration: underline;
}
@jonphipps
jonphipps / .env
Last active February 7, 2016 21:23
Modified .env
LOCAL_HOME=/Users/joeblough
SERVER_HOME=/home/vagrant
...
DB_CONNECTION=mysql
...