Skip to content

Instantly share code, notes, and snippets.

View iamakulov's full-sized avatar

Ivan Akulov iamakulov

View GitHub Profile

deepCompare performs a deep comparison of two objects. It automatically unwraps JS Maps, Sets, and ImmutableJS objects.

Example

deepCompare(left, right)

// Will output:
// {
// isEqual: false,
@iamakulov
iamakulov / index.md
Last active February 17, 2024 03:32
What you should (and shouldn’t) enable in Cloudflare for web performance

What you should (and shouldn’t) enable in Cloudflare for web performance

Cloudflare is a web-performance-and-security-as-a-service company.

To configure your web app to run faster, you need to:

  • sign up for Cloudflare
  • connect it to your site (by moving DNS records and setting up proxying)
  • enable a few toggles in the settings.
@iamakulov
iamakulov / index.md
Last active October 8, 2023 20:15
Imports and webpack contexts
// A copy-pasteable useWhyDidYouUpdate hook, adopted from the old & good usehooks.com (http://web.archive.org/web/20230203011511/https://usehooks.com/useWhyDidYouUpdate/).
//
// This hook will log whenever a component rerenders – and will print the props (or any other values
// you passed into it) that have changed between the rerenders.
//
// Usage:
//
// function MyComponent(props) {
// useWhyDidYouUpdate('MyComponent', props)
//
@iamakulov
iamakulov / index.md
Created July 21, 2022 17:03
Proxying api.my-app.com under my-app.com/api, using CloudFront or Cloudflare

Here’s how to make api.my-app.com available under my-app.com/api, using CloudFront or Cloudflare.

CloudFront

If both my-app.com and api.my-app.com are hosted in AWS, you can route requests to these instances using the CloudFront CDN.

Here’s what you’ll need to do:

  1. Create a CloudFront distribution
@iamakulov
iamakulov / passive-true-analysis.md
Last active March 3, 2022 23:27
Analysis of passive: true

Analysis of passive: true

In 2017, Chrome, Firefox and Safari added support for passive event listeners. They help to make scrolling work smoother and are enabled by passing {passive: true} into addEventListener().

The explainer mentions that passive: true works for wheel and touch events. I practically analyzed when passive: true actually helps:

Event Works better with passive: true Is passive by default
wheel¹ Yes (Chrome), No (Firefox) No (Chrome), No (Firefox)
touchstart Yes (Chrome), ?² (Firefox) Yes (Chrome), ?² (Firefox)
@iamakulov
iamakulov / index.js
Last active August 14, 2021 06:14
Webpack’s externals work with local paths too
// my-app/webpack.config.js
{
externals: {
'jquery': 'jQuery',
/* ↑ With this line, Webpack will replace every
* import $ from 'jquery';
*
* in your code with approximately
* const $ = window.jQuery;
*
@iamakulov
iamakulov / index.md
Last active September 3, 2020 04:31
Webpack’s ContextReplacementPlugin examples
@iamakulov
iamakulov / index.md
Last active May 22, 2020 15:28
Fixing babel-plugin-add-module-exports in Webpack 2

babel-plugin-add-module-exports generates an incorrect bundle if you use ES modules in the latest versions of Webpack 2 (at least in 2.1.0-beta.27 and .28). Here’s what to do.

1. Remove the plugin:

{
  "plugins": [
-   "add-module-exports"
  ]
}
@iamakulov
iamakulov / index.md
Last active July 13, 2018 19:29
Куда инвестировать валюту в Беларуси

(Для канала про бизнес: @iamakulov_learning_biz)

1. Депозиты

Депозиты. Доходность на февраль 2018 года — 1...2% годовых. Это примерно равно или ниже инфляции доллара. Вклады чаще неотзывные (то есть забрать просто так не получится). На короткие вклады процент меньше, плюс нужно платить подоходный налог (если вклад до двух лет).

2. Облигации Беларуси в иностранной валюте

На примере выпуска №244: