Skip to content

Instantly share code, notes, and snippets.

View alexerisov's full-sized avatar
🏃
Running to the future

Alexey alexerisov

🏃
Running to the future
View GitHub Profile
@alexerisov
alexerisov / middleware.md
Last active August 11, 2023 02:13
NExtJs middleware wiith Next-auth

Variant 1

Use built-in next-auth middleware. Login page redirect should be handled in getServerSideProps

import type { JWT } from "next-auth/jwt";
import { withAuth } from "next-auth/middleware";
import { NextResponse } from "next/server";

export default withAuth(
  // `withAuth` augments your `Request` with the user's token.
@alexerisov
alexerisov / !Nginx-config-NextJs.md
Last active July 9, 2023 11:12
Nginx conf for nextjs

Nginx.conf file for NextJs App. Created by merge Werf Config and Habr Post

Also it can be used in ConfigMap

@alexerisov
alexerisov / YAML-to-ENV.md
Last active May 11, 2023 15:35
Convert .yaml to .env with yq

Download and install yq

Check yq repo

wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq &&\
    chmod +x /usr/bin/yq

Converting

@alexerisov
alexerisov / colorize.md
Last active May 4, 2023 02:49
Colorize kubectl

Create file

nano colorize.sh

paste into content below

#!/bin/bash
@alexerisov
alexerisov / .bash_aliases.sh
Last active May 17, 2023 05:06
Bash aliases
alias gs='git status '
alias ga='git add '
alias gaa='git add --a'
alias gb='git branch '
alias gc='git commit -m'
alias gcamend='git commit --amend -m'
alias gd='git diff'
alias gco='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
@alexerisov
alexerisov / Deckhouse.md
Last active May 2, 2023 14:39
Kubernetes commands

Clear deckhouse node

Instructions according the docs Check doc

systemctl stop kubernetes-api-proxy.service kubernetes-api-proxy-configurator.service kubernetes-api-proxy-configurator.timer
systemctl stop bashible.service bashible.timer
systemctl stop kubelet.service
systemctl stop containerd
systemctl list-units --full --all | grep -q docker.service && systemctl stop docker
@alexerisov
alexerisov / WithData.tsx
Created April 26, 2023 08:04
Typed WithData HOC
import React, { ReactElement, ReactNode } from "react";
import isEmpty from "lodash/isEmpty";
import { EmptyDataPlaceholder } from "~components/shared/EmptyDataPlaceholder/EmptyDataPlaceholder";
import { ErrorPlaceholder } from "~components/shared/ErrorPlaceholder/ErrorPlacehorder";
import { LoadingSpinner } from "~components/shared/LoadingSpinner/LoadingSpinner";
interface WithDataProps<TData> {
data: TData;
loading: boolean;
@alexerisov
alexerisov / lodash.d.ts
Created April 26, 2023 08:04
Type extensions for lodash
declare module "lodash/isEmpty" {
import _isEmpty from "lodash/isEmpty";
// eslint-disable-next-line prettier/prettier
const isEmpty = <T>(value: T): value is undefined | null => {
return _isEmpty(value);
};
export default isEmpty;
}
@alexerisov
alexerisov / LiveTemplate.md
Last active April 7, 2023 08:42
React logging live template for IDEA

MainCode

{/*DEV do not forget to remove logging block */}
{createPortal(
  <pre
    style={{
      position: "absolute",
      zIndex: "10000",
 overflow: "auto",
@alexerisov
alexerisov / openapitools.json
Last active June 14, 2023 11:07
Openapi Generator config
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "6.5.0",
"generators":{
"main": {
"generatorName": "typescript-axios",
"globalProperty": "apis,models,supportingFiles=\"api.ts:base.ts:common.ts:configuration.ts:index.ts\"",
"output": "./src/shared/api/main",