Skip to content

Instantly share code, notes, and snippets.

View digitalmio's full-sized avatar

Maciej Ziehlke digitalmio

View GitHub Profile
# =====================
# PgCat Configuration
# =====================
[general]
host = "0.0.0.0" # Bind to all interfaces
port = 6432 # PgCat listens on this port
connect_timeout = 5000 # in ms
idle_timeout = 30000 # in ms
server_lifetime = 86400000 # in ms (1 day)
@digitalmio
digitalmio / Leet49.ts
Last active September 24, 2024 17:02
const test = (strs: string[]) =>
Object.values(
strs.reduce((acc, el) => {
const key = el.split("").sort().join("");
acc[key] = [...(acc[key] || []), el].sort();
return acc;
}, {} as Record<string, string[]>)
).sort((a, b) => a.length - b.length);
// ========================
@digitalmio
digitalmio / gcpToCountry.ts
Last active November 21, 2023 22:31
Deno GCP to country mapper
// Deno deploy provides region via env variable DENO_REGION: https://docs.deno.com/deploy/manual/environment-variables#preset-variables
// you can access it via: `Deno.env.get("DENO_REGION")`
export const denoRegionToAws = (
denoRegion: keyof typeof denoDeployCountry,
desiredRegions: AwsRegions[] = []
) => {
const regions = desiredRegions.length ? desiredRegions : awsRegions;
const country = denoDeployCountry[denoRegion]?.country;

Prerequisites

  • Debian-like server (Debian, Ubuntu, etc)
  • Node and NPM installed.
  • Next.js app running on port 3000 (default). I highly recommend you to use PM2 for process management (restarts etc).

Install Caddy

This will add 3rd party Deb repo and install Caddy 2.

apt install -y debian-keyring debian-archive-keyring apt-transport-https
@digitalmio
digitalmio / next_js_caddy.md
Created July 17, 2021 22:41
Next JS with Caddy server

Install Caddy

This will add 3rd party Deb repo and install Caddy 2.

apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | apt-key add -
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
apt update
apt install caddy
<form name="addForm" novalidate>
<div>
<label for="firstname">Donor First Name</label>
<input type="text" id="firstname" ng-model="firstname" name="firstname" required />
<div ng-if="addForm.firstname.$pristine == false || addForm.firstname.$untouched == false" ng-messages="addForm.firstname.$error" ng-messages-include="error-messages"></div>
</div>
<button ng-disabled="addForm.$valid == false" ng-click="action(addForm)">Save and go to overview</button>
</form>