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:44 (UTC +08:00)
View GitHub Profile
@crashmax-dev
crashmax-dev / box.tsx
Created November 10, 2021 12:59 — forked from domosedov/box.tsx
React TailwindCSS component example
import type { FC, HTMLAttributes } from "react";
type BoxProps = {
as?: keyof JSX.IntrinsicElements;
} & HTMLAttributes<HTMLOrSVGElement>;
export const Box: FC<BoxProps> = ({ as: Component = "div", ...props }) => {
return <Component {...props} />;
};
@crashmax-dev
crashmax-dev / react-use-pagination.mjs
Created November 21, 2021 12:35
react-use-pagination.mjs
// src/getPaginationMeta.ts
var getPreviousEnabled = (currentPage) => currentPage > 0;
var getNextEnabled = (currentPage, totalPages) => currentPage + 1 < totalPages;
var getTotalPages = (totalItems, pageSize) => Math.ceil(totalItems / pageSize);
var getStartIndex = (pageSize, currentPage) => pageSize * currentPage;
var getEndIndex = (pageSize, currentPage, totalItems) => {
const lastPageEndIndex = pageSize * (currentPage + 1);
if (lastPageEndIndex > totalItems) {
return totalItems - 1;
}
@crashmax-dev
crashmax-dev / index.html
Created January 13, 2022 11:06
simulate KeyboardEvent
<!DOCTYPE html>
<html>
<head>
<title>KeyboardEvent</title>
<meta charset="UTF-8" />
<script>
document.addEventListener("keydown", function (evt) {
if (evt.keyCode === 65 && evt.shiftKey) {
alert("SHIFT + A pressed");
@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
@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]
const date = new Intl.DateTimeFormat('en', {
year: 'numeric',
hour: 'numeric',
minute: 'numeric',
second: 'numeric',
day: '2-digit',
month: '2-digit',
hour12: false
})
.visually-hidden {
border: 0px;
clip: rect(0px, 0px, 0px, 0px);
height: 1px;
width: 1px;
margin: -1px;
padding: 0px;
overflow: hidden;
white-space: nowrap;
position: absolute;
/**
* Use like this:
*
* pluralize(2)`package${['s']}`
* // packages
*
* pluralize(1)`package${['s']}`
* // package
*
* pluralize(2)`agenc${['ies', 'y']}`
function cakes(recipe, available) {
return Object
.keys(recipe)
.reduce((acc, ingredient) => {
const cakes = Math.floor(
available[ingredient] /
recipe[ingredient] || 0
)
return Math.min(cakes, acc)
export default async function fetcher<T = unknown>(
input: RequestInfo,
init?: RequestInit
): Promise<T> {
const response = await fetch(input, init)
const data = await response.json() as T
if (response.ok) {
return data
}