Skip to content

Instantly share code, notes, and snippets.

View crashmax-dev's full-sized avatar
:octocat:
Meow

Vitalij Ryndin crashmax-dev

:octocat:
Meow
  • Russia
  • 11:41 (UTC +08:00)
View GitHub Profile
@mmazzarolo
mmazzarolo / fill-localstorage.ts
Last active April 2, 2023 14:00
Using JavaScript to fill localStorage to its maximum capacity
/**
* Fill localStorage to its maximum capacity.
*
* First, we find the highest order bit (the bit with the highest place value)
* that fits in localStorage by storing localStorage an increasingly big
* string of length 2, 4, 8, 16, etc. until it won't fill localStorage anymore.
*
* By working in iterations, starting with very long strings, and storing data
* in different items, we can keep a low memory profile and reduce the number of
* writes — making this process pretty fast.
@SergProduction
SergProduction / use-date.ts
Last active June 14, 2022 17:51
date react hook convertation string to Date object
import React, { useState } from 'react'
const Nothing = Symbol()
const normDoubleSymbol = (strOrNumber: string | number) => strOrNumber.toString().length === 1
? `0${strOrNumber}`
: strOrNumber.toString()

Что не так с enum в typescript

Вводная

Я никак не могу обойти тему того чем является тайпскрипт, и чем он должен был быть.

"TypeScript is JavaScript with syntax for types." www.typescriptlang.org

Это именно то что отличает тайпскрипт он кофескриптов, эльмов, ризонов и т.д. Все что нужно чтобы получить javascript - убрать аннотации типов. В вебе, где размер бандла одна из ключевых метрик, это - киллер фича.

@crashmax-dev
crashmax-dev / disable-antizapret.reg
Last active July 24, 2023 09:36
Antizapret (Windows)
Windows Registry Editor Version 5.00
;=== Disable ===
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"AutoConfigURL"=-
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap]
"ProxyBypass"=dword:00000001
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1]
@crashmax-dev
crashmax-dev / extensions.md
Last active November 5, 2022 10:34
VS Code Extensions

How to install

code --install-extension aaron-bond.better-comments
code --install-extension Angular.ng-template
code --install-extension bradlc.vscode-tailwindcss
code --install-extension csstools.postcss
code --install-extension dbaeumer.vscode-eslint
code --install-extension EditorConfig.EditorConfig
code --install-extension esbenp.prettier-vscode
/**
* GlobalsDebugger
*
* Inspect the stack when a global variable is being set on the window object.
* Given a global variable name, it proxies the variable name in the window
* object adding some custom code that will be invoked whenever the variable
* is set. The custom code will log the current stack trace and halt the code
* execution to allow inspecting the stack and context in your browser DevTools.
* You can use the "globalsToInspect" query-parameter to set a comma-separated
* list of names of the variables you want to inspect.
@mmazzarolo
mmazzarolo / runtime-globals-checker.js
Last active June 8, 2023 14:27
Find what JavaScript variables are leaking into the global `window` object at runtime (see: https://mmazzarolo.com/blog/2022-02-14-find-what-javascript-variables-are-leaking-into-the-global-scope/)
/**
* RuntimeGlobalsChecker
*
* You can use this utility to quickly check what variables have been added (or
* leaked) to the global window object at runtime (by JavaScript code).
* By running this code, the globals checker itself is attached as a singleton
* to the window object as "__runtimeGlobalsChecker__".
* You can check the runtime globals programmatically at any time by invoking
* "window.__runtimeGlobalsChecker__.getRuntimeGlobals()".
*
#!/usr/bin/env node
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from "url";
import { unified } from "unified";
import rehypeParse from "rehype-parse";
import { VFile } from "vfile";
import { write } from "to-vfile";
import generate from "@babel/generator";
@crashmax-dev
crashmax-dev / settings.json
Last active March 7, 2023 19:14
VS Code Settings
{
"window.title": "${dirty}${appName} ¯\\_(ツ)_/¯ ${rootName}",
"editor.tabSize": 2,
"terminal.integrated.smoothScrolling": true,
"editor.inlineSuggest.enabled": true,
"editor.cursorSmoothCaretAnimation": "on",
"editor.smoothScrolling": true,
"editor.minimap.enabled": true,
"editor.stickyScroll.enabled": false,
"editor.inlayHints.enabled": "on",
@sindresorhus
sindresorhus / esm-package.md
Last active April 29, 2025 15:28
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.