next.js, nginx, reverse-proxy, ssl
$ sudo apt-get update
$ sudo apt-get install nginx letsencrypt| package main | |
| import "fmt" | |
| func main() { | |
| fmt.Println("hello world") | |
| } |
| map $http_origin $allow_origin { | |
| default ""; | |
| "~^https?://(?:[^/]*\.)?(stevebuzonas\.(?:com|local))(?::[0-9]+)?$" "$http_origin"; | |
| } | |
| map $request_method $cors_method { | |
| default "allowed"; | |
| "OPTIONS" "preflight"; | |
| } |
| #!/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 |
| # 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 |
| /*** 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" }); |
| /** | |
| * 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)] ]; | |
| } |