Skip to content

Instantly share code, notes, and snippets.

@ValeryVerkhoturov
ValeryVerkhoturov / nextjs-deploy.md
Created March 6, 2023 21:31 — forked from jjcodes78/nextjs-deploy.md
Deploying NEXTJS site with nginx + pm2

How to setup next.js app on nginx with letsencrypt

next.js, nginx, reverse-proxy, ssl

1. Install nginx and letsencrypt

$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt

Also enable nginx in ufw

@ValeryVerkhoturov
ValeryVerkhoturov / pluralize-ru.js
Created July 13, 2023 21:00 — forked from znechai/pluralize-ru.js
JavaScript - Plural forms for russian words
/**
* Plural forms for russian words
* @param {Integer} count quantity for word
* @param {Array} words Array of words. Example: ['депутат', 'депутата', 'депутатов'], ['коментарий', 'коментария', 'комментариев']
* @return {String} Count + plural form for word
*/
function pluralize(count, words) {
var cases = [2, 0, 1, 1, 1, 2];
return count + ' ' + words[ (count % 100 > 4 && count % 100 < 20) ? 2 : cases[ Math.min(count % 10, 5)] ];
}
@ValeryVerkhoturov
ValeryVerkhoturov / example.api.ts
Created July 17, 2023 07:00 — forked from epicbytes/example.api.ts
NextJS Authorization Files
/*** function that used as middleware ***/
accessToken: async (name) => {
if (typeof document === "undefined") return "";
let token = document.cookie
.split(";")
.filter((cookie) => cookie.startsWith("token"))[0];
if (!token) {
const response = await fetch("/api/refresh", { method: "POST" });
@ValeryVerkhoturov
ValeryVerkhoturov / diff.py
Created January 5, 2024 19:28 — forked from adamnew123456/diff.py
An implementation of the Myers diff algorithm
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
@ValeryVerkhoturov
ValeryVerkhoturov / rmq_passwd_hash.py
Created March 9, 2024 17:44 — forked from anapsix/rmq_passwd_hash.py
generate RabbitMQ compatible SHA256 password hash
#!/usr/bin/env python
# details on rabbitMQ password hashing
# https://www.rabbitmq.com/passwords.html#computing-password-hash
from __future__ import print_function
import base64
import os
import hashlib
import struct
import getpass
@ValeryVerkhoturov
ValeryVerkhoturov / nginx-cors.conf
Created January 19, 2025 15:53 — forked from sbuzonas/nginx-cors.conf
Nginx CORS maps
map $http_origin $allow_origin {
default "";
"~^https?://(?:[^/]*\.)?(stevebuzonas\.(?:com|local))(?::[0-9]+)?$" "$http_origin";
}
map $request_method $cors_method {
default "allowed";
"OPTIONS" "preflight";
}
@ValeryVerkhoturov
ValeryVerkhoturov / hello.go
Created January 30, 2025 16:30 — forked from ereli/hello.go
How to sign macOS and Windows executables using self-signed certificates on a Mac.
package main
import "fmt"
func main() {
fmt.Println("hello world")
}