Skip to content

Instantly share code, notes, and snippets.

View herrri's full-sized avatar

Henri Pajala herrri

View GitHub Profile
@herrri
herrri / main.tf
Last active May 5, 2021 11:58
Terraform map ENV variables, not using workspaces
resource "azurerm_app_service" "my_service_staging" {
...
site_config {
...
}
app_settings = {
VAR_ONE = lookup(var.env_staging, "VAR_ONE", "default_val")
VAR_TWO = var.env_staging["VAR_TWO"]
VAR_THREE = var.env_staging["VAR_THREE"]
@herrri
herrri / CypressLogin.tsx
Last active September 23, 2020 11:25
Cypress login with the new universal lock - circumvent CSP (Used together with auth0 auth0-spa-js)
import Auth0Lock from 'auth0-lock';
const REDIRECT_URL = 'https://localhost:3000/';
const AUTH0_CLIENT_ID = 'XXX';
const AUTH0_DOMAIN = 'XXX';
const current = {
appState: { targetUrl: '/' },
scope: 'openid profile email',
audience: 'default',
@herrri
herrri / pg-pubsub-beat.js
Created April 3, 2020 10:46
Use heartbeats to select a leader node.
const PGPubsub = require("pg-pubsub");
const randInt = max => Math.floor(Math.random() * max);
const now = () => Math.floor(Date.now());
const isMyTurn = () => Math.max(...beats.map(b => b.node)) === node;
// node value
// might cause collisions,
// but let's keep it simple
const node = randInt(Number.MAX_SAFE_INTEGER);
@herrri
herrri / remove_auth0_users_cli.py
Last active April 3, 2020 11:02
How to remove users form auth0 using python API
#
# pip install auth0-python python-dotenv
# also configure your auth0 and set the .env
#
import os
import sys
import time
from auth0.v3.authentication import GetToken

Keybase proof

I hereby claim:

  • I am herrri on github.
  • I am herri (https://keybase.io/herri) on keybase.
  • I have a public key ASBslxXrdfGqFud4xgnTRUD2f929PQOw5-yjCI4HsZ8ueQo

To claim this, I am signing this object: