Skip to content

Instantly share code, notes, and snippets.

Bengt Brodersen qoomon

View GitHub Profile
@qoomon
qoomon / aws-cloudformation-await.sh
Last active Mar 15, 2019
CloudFormation await final state. Follow cfs event stream. See first comment for extended version.
View aws-cloudformation-await.sh
#!/usr/bin/env sh -euo pipefail
############################## Usage ################################
#
# aws_cloudformation_await --stack 'ANY_STACK_NAME'
#
#####################################################################
while [ $# -gt 0 ]; do
case $1 in
@qoomon
qoomon / ChromeRemoveAllDomainSearchEngins.js
Last active Mar 11, 2019
[Google Chrome] Remove all domain search engines #cleanup
View ChromeRemoveAllDomainSearchEngins.js
// open chrome://settings/searchEngines and run following script in browser console
// will remove every 'other' search engine wich contains a '.' in its keyword
settings.SearchEnginesBrowserProxyImpl.prototype.getSearchEnginesList()
.then(engines => engines.others.forEach(engine => {
if(engine.keyword.includes(".")){
console.log("remove: " + engine.displayName + " - " + engine.keyword)
settings.SearchEnginesBrowserProxyImpl.prototype.removeSearchEngine(engine.modelIndex);
}
}));
@qoomon
qoomon / escapeHTML.js
Created Feb 28, 2019
JS Function to escape HTML text
View escapeHTML.js
function escapeHTML(text) {
let element = document.createElement('_');
element.innerText = text;
return element.innerHTML;
}
@qoomon
qoomon / check-pwned-passwords.sh
Last active Feb 1, 2019
check-pwned-passwords.sh
View check-pwned-passwords.sh
#!/bin/bash
set -e
set -o pipefail
##############################################################################
##############################################################################
#
###### prerequisites
#
# install ripgrep
@qoomon
qoomon / entrypoint.sh
Created Jan 15, 2019
docker container run forever
View entrypoint.sh
#!/bin/sh
# do some configuration
# Ah, ha, ha, ha, stayin' alive...
while true; do :; done &
kill -STOP $!
wait $!
@qoomon
qoomon / conventional_commit_messages.md
Last active Feb 4, 2019
Conventional Commit Messages
View conventional_commit_messages.md
@qoomon
qoomon / dind_example.md
Created Dec 17, 2018
Docker in Docker (dind)
View dind_example.md

docker network solution

BUILD_TAG="Dummy Job #$RANDOM"

echo "Create job network '$BUILD_TAG'"
job_network_id=$(docker network create "$BUILD_TAG" | tee $TTY)

echo "Start service container 'dind'"
docker run -d --privileged --net=${job_network_id} --network-alias dind docker:dind
@qoomon
qoomon / gist:ef4b91f5c304dafbd0688a415afeaf46
Last active Aug 27, 2018
DataDog Log Pipeline for Lambda Logs - Grok Parser
View gist:ef4b91f5c304dafbd0688a415afeaf46
#### JSON Rules
#2018-08-22T11:05:02.637Z 4d8b3785-079a-5f47-9b09-647242079aed {"level": "INFO", "message": "that's an interesting message", "user": "john"}
log_json_rule %{date("yyyy-MM-dd'T'HH:mm:ss.SSSZ"):timestamp}\s+%{notSpace:lambda.request_id}\s+%{regex("\\{.*\\}")::json}
#### Plain Text Rules
#2018-08-22T11:05:02.637Z 4d8b3785-079a-5f47-9b09-647242079aed INFO: that's an interesting message
log_level_msg_rule %{date("yyyy-MM-dd'T'HH:mm:ss.SSSZ"):timestamp}\s+%{notSpace:lambda.request_id}\s+%{regex("/(?i)ERROR|WARN|INFO|DEBUG|TRACE/"):level}:?\s+%{data:message}
@qoomon
qoomon / .gitlab-ci.yaml
Last active Jul 20, 2018
GitLab CI - Environment Specific Variables - Community Edition
View .gitlab-ci.yaml
# assume you've set following environment variables
# AWS_ACCESS_KEY__production="111111"
# AWS_ACCESS_KEY__sandbox="222222"
before_script:
# declares environment spesific variables
- ENV_VAR_SUFFIX="__${CI_ENVIRONMENT_NAME}"; for var in $(compgen -e | grep "${ENV_VAR_SUFFIX}$"); do declare -xg ${var%${ENV_VAR_SUFFIX}}="${!var}"; done
job:
environment: sandbox
@qoomon
qoomon / pathAccess.js
Last active May 16, 2018
Set and get JSON values by path string.
View pathAccess.js
const splitPath = (path)=> {
return path
.replace(/\[([\d]+)\]/g, '.$1') // replace [0] with .0
.replace(/\['([\w]+)'\]/g, '.$1') // replace ['x'] with .x
.replace(/\["([\w]+)"\]/g, '.$1') // replace ["x"] with .x
.split('.');
};
const getPathValue = (object, path) => {
const pathSegments = splitPath(path);
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.