Skip to content

Instantly share code, notes, and snippets.

View tazarov's full-sized avatar
🦖
Tell me and I forget. Teach me and I remember. Involve me and I learn.

Trayan Azarov tazarov

🦖
Tell me and I forget. Teach me and I remember. Involve me and I learn.
View GitHub Profile
@tazarov
tazarov / string-utils.js
Created October 12, 2017 15:55 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str){
return str.toLowerCase();
@tazarov
tazarov / app.py
Created January 12, 2022 11:34
FastAPI with React App
import logging
from fastapi import FastAPI
from starlette.responses import RedirectResponse
from starlette.staticfiles import StaticFiles
app = FastAPI()
@app.get("/")
@tazarov
tazarov / GeneratePythonSQLModel.groovy
Last active January 26, 2022 21:11
Convert Schema Table To Python SQLModel classes
import com.intellij.database.model.DasTable
import com.intellij.database.util.Case
import com.intellij.database.util.DasUtil
/*
* Available context bindings:
* SELECTION Iterable<DasObject>
* PROJECT project
* FILES files helper
*/
@tazarov
tazarov / http-to-https-location-post.lua
Last active June 17, 2022 12:53
Kong pre/post-function collection
-- Problem: sometimes the remote server will return a http:// url and browser gets redirected to a non-https url even though it is accessing https endpoint
-- This post-function snippet in Kong helps you overwrite the http part in Location header.
if kong.response.get_status() == 302 and kong.response.get_header("location") ~= "^http" then
local new_loc = kong.response.get_header("Location"):gsub("http","https")
kong.response.set_header("Location",new_loc)
end
@tazarov
tazarov / ngrok-selfhosting-setup.md
Created January 4, 2023 11:55 — forked from lyoshenka/ngrok-selfhosting-setup.md
How to setup Ngrok with a self-signed SSL cert

Intro

The plan is to create a pair of executables (ngrok and ngrokd) that are connected with a self-signed SSL cert. Since the client and server executables are paired, you won't be able to use any other ngrok to connect to this ngrokd, and vice versa.

DNS

Add two DNS records: one for the base domain and one for the wildcard domain. For example, if your base domain is domain.com, you'll need a record for that and for *.domain.com.

Different Operating Systems

@tazarov
tazarov / gen-ssl.sh
Created January 5, 2023 09:41 — forked from thbkrkr/gen-ssl.sh
Generate Self-Signed SSL Certificate without prompt
# Generate a passphrase
openssl rand -base64 48 > passphrase.txt
# Generate a Private Key
openssl genrsa -aes128 -passout file:passphrase.txt -out server.key 2048
# Generate a CSR (Certificate Signing Request)
openssl req -new -passin file:passphrase.txt -key server.key -out server.csr \
-subj "/C=FR/O=krkr/OU=Domain Control Validated/CN=*.krkr.io"
@tazarov
tazarov / kubernetes_service_session_affinity.md
Created January 20, 2023 17:15 — forked from fjudith/kubernetes_service_session_affinity.md
Enable Session Affinity (a.k.a Sticky Session) to Kubernetes service
@tazarov
tazarov / test_email.py
Last active January 25, 2023 21:19
Send email using AWS SES
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def test_send_mail():
# Replace sender@example.com with your "From" address.
# This address must be verified with Amazon SES.
SENDER = "admin@org"
@tazarov
tazarov / my-admin-checker-mapper.js
Created February 23, 2023 15:27 — forked from Videl/my-admin-checker-mapper.js
JS for script mapper in Keycloak
// https://stackoverflow.com/questions/52518298/how-to-create-a-script-mapper-in-keycloak
// https://stackoverflow.com/questions/48199539/best-way-to-test-debug-javascript-mappers-policies-in-keycloak
// https://docs.oracle.com/javase/10/nashorn/nashorn-java-api.htm#JSNUG119
var client = keycloakSession.getContext().getClient();
var forEach = Array.prototype.forEach;
// print(user.getRealmRoleMappings());
var isAdmin = false;

Installation

Check release in https://github.com/WireGuard/wireguard-vyatta-ubnt/releases

#https://github.com/WireGuard/wireguard-vyatta-ubnt/releases/download/1.0.20220627-1/ugw4-v1-v1.0.20220627-v1.0.20210914.deb

curl -OL https://github.com/WireGuard/wireguard-vyatta-ubnt/releases/download/1.0.20220627-1/ugw4-v1-v1.0.20220627-v1.0.20210914.deb