Skip to content

Instantly share code, notes, and snippets.

View slutske22's full-sized avatar
🎯
Focusing

Seth Lutske slutske22

🎯
Focusing
View GitHub Profile
@slutske22
slutske22 / setup.ts
Created March 20, 2024 21:24
Setup script using the keycloak admin REST api
/* eslint no-console: 0 */
const axios = require("axios");
const chalk = require("chalk");
const KEYCLOAK_BASE_URL = process.env.DEMO
? "http://keycloak_iam:9090"
: "http://localhost:9090";
const CLIENT_NAME = "sva";
const CLIENT_ROLES = ["ROLE_DEP_ADMIN", "ROLE_DEP_GENERAL"];
@slutske22
slutske22 / profiler.sh
Last active December 26, 2021 21:34
profiler.sh
# Set environment variables
export PORT=4000
export PROFILER=true
export OUTPUT_DIR="profiles/$(date +%s)"
# Leverage pm2 to start server on specific port:
pm2 start npm --name server-profiler -- start
# Wait for server to start and then ping with post request to run campaign
npx wait-on http://localhost:4000
@slutske22
slutske22 / package.json
Created December 24, 2021 23:27
package.json with profiler
{
"scripts": {
"start": "node ./src/index.js",
"profile": "sh ./scripts/profile.sh"
}
}
@slutske22
slutske22 / index.js
Last active December 26, 2021 21:26
Simple express app, with profiler
import express from 'express';
import { ... } from './utils'
import Profiler from './Profiler'
// Create a profiler
const profiler = new Profiler({
active: !!process.env.PROFILER,
title: new Date.getTime(),
outputDir: process.env.OUTPUT_DIR
});
@slutske22
slutske22 / profiler.js
Last active December 26, 2021 21:25
Profiler class
import fs from 'fs';
import v8profiler from 'v8-profiler-next';
export class Profiler {
constructor(options) {
const { title, active, outputDir } = options;
this.title = title;
this.active = active;
this.outputDir = outputDir;
}
@slutske22
slutske22 / package.json
Created December 24, 2021 22:27
package.json
{
"scripts": {
"start": "node ./src/index.js"
}
}
@slutske22
slutske22 / index.js
Last active December 24, 2021 22:24
Simple express server
import express from 'express';
import {
simpleCalculation,
complexCalculation
} from './utils'
// Set up app
const app = express();
const port = process.env.PORT ?? 8080;
@slutske22
slutske22 / Jenkinsfile
Last active March 25, 2022 17:56
sorry-cypress-jenkinsfile
stage ('Cypress'){
parallel {
stage('Cypress 1') {
agent {
node {
label 'agent-1'
}
}
steps {
sh 'npm install --silent'