Skip to content

Instantly share code, notes, and snippets.

View jweyrich's full-sized avatar
:octocat:
Making some lives easier and happier!

Jardel Weyrich jweyrich

:octocat:
Making some lives easier and happier!
View GitHub Profile
@jweyrich
jweyrich / haproxy.cfg
Last active March 26, 2024 19:06
HAproxy forwarding to https backend
#
# This is just a snippet of HAProxy config.
# Please replace ENTRY_DOMAIN_HERE and TARGET_DOMAIN_HERE accordingly.
#
frontend front_http
log global
bind :80
use_backend back_target if { hdr(host) -i ENTRY_DOMAIN_HERE }
default_backend back_healthcheck
@jweyrich
jweyrich / jest.config.js
Last active February 4, 2023 00:57
Example of Jest config with support for Path Mapping
const { pathsToModuleNameMapper } = require('ts-jest/utils');
// In the following statement, replace `./tsconfig` with the path to your `tsconfig` file
// which contains the path mapping (ie the `compilerOptions.paths` option):
const { compilerOptions } = require('./tsconfig');
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/tst/**/*.test.ts'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' }),
@jweyrich
jweyrich / dotenv-exec
Last active December 26, 2022 16:30
Load environment variables from a dotenv file before running an executable
#!/bin/sh
#
# Load environment variables from a dotenv file before running an executable
# Usage: dotenv-exec <.env> <executable> [executable-parameters]
#
usage() {
echo "Usage: $(basename "$0") <.env> <executable> [executable-parameters]" 1>&2
exit 1
@jweyrich
jweyrich / interval_string_to_seconds.py
Last active August 12, 2022 13:56
Python function to convert an interval string to seconds
#
# Author: Jardel Weyrich <jweyrich at gmail dot com>
#
import re
def interval_string_to_seconds(input: str) -> int:
SUFFIX_MAP = {
'y': 'y',
'year': 'y',
@jweyrich
jweyrich / aws-lambda-update-variables.py
Created June 15, 2022 13:55
Script that visits all deployed Lambda functions in an AWS account & region and updates all environment variables matching a specified substring.
#!/usr/bin/env python3
#
# Author: Jardel Weyrich <jweyrich at gmail dot com>
#
# How to run:
# aws-vault exec <profile> -- python3 aws-lambda-update-variables.py
#
import logging
import os
from pprint import pformat
@jweyrich
jweyrich / jenkins_dump_credentials.groovy
Created March 11, 2022 19:51
Jenkins - Dump credentials
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
Jenkins.instance,
null,
null
)
for(c in creds) {
if(c instanceof com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey){
println(String.format("id=%s desc=%s key=%s\n", c.id, c.description, c.privateKeySource.getPrivateKeys()))
@jweyrich
jweyrich / jenkins_list_installed_plugins.groovy
Created March 11, 2022 19:50
Jenkins - List all installed plugins and their versions
def plugins = jenkins.model.Jenkins.instance.getPluginManager().getPlugins()
plugins.each {println “${it.getShortName()}:${it.getVersion()}“}
println “Total number of plugins: ${plugins.size()}”
@jweyrich
jweyrich / aws-apigw-list-endpoints.py
Last active June 16, 2022 01:20
Python3 script to list all API and their endpoints that are currently deployed to the AWS API Gateway
#!/usr/bin/env python3
#
# Author: Jardel Weyrich <jweyrich at gmail dot com>
#
# How to run:
# aws-vault exec <profile> -- python3 aws-apigw-list-endpoints.py
#
import boto3
import os
@jweyrich
jweyrich / aws-ssm-export-all-parameters.py
Last active June 16, 2022 01:20
Python3 script to export all parameters stored in the AWS Systems Manager Parameter Store
#!/usr/bin/env python3
#
# Author: Jardel Weyrich <jweyrich at gmail dot com>
#
# How to run:
# aws-vault exec <profile> -- python3 aws-ssm-export-all-parameters.py > result.json
#
import boto3
import os
import sys
@jweyrich
jweyrich / mssql_blocking_tree.sql
Created September 16, 2021 17:57
MSSQL Blocking Tree Script
/*
* Original code from https://blog.sqlauthority.com/2020/04/20/sql-server-blocking-tree-identifying-blocking-chain-using-sql-scripts/
*/
IF OBJECT_ID('tempdb..#Blocks') IS NOT NULL
DROP TABLE #Blocks
SELECT spid
,blocked
,REPLACE (REPLACE (st.TEXT, CHAR(10), ' '), CHAR (13), ' ' ) AS batch
INTO #Blocks
FROM sys.sysprocesses spr