Instantly share code, notes, and snippets.

View check-pwned-passwords.sh
#!/bin/bash
set -e
set -o pipefail
##############################################################################
##############################################################################
#
###### prerequisites
#
# install ripgrep
View entrypoint.sh
#!/bin/sh
# do some configuration
# Ah, ha, ha, ha, stayin' alive...
while true; do :; done &
kill -STOP $!
wait $!
View conventional_commit_messages.md

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference.

Format

<type>(<scope>): <subject>
empty separator line
<body>

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
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}
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
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);
View ExceptionUtils.java
public class ExceptionUtils {
/**
* Throws {@code t} as a unchecked exception.
*/
@SuppressWarnings("unchecked")
public static <T extends Throwable> void throwUnchecked(Throwable t) throws T {
throw (T) t;
}
View .gitlab-ci.yml
stages:
- pack
### Pack ######################################################################
docker:
stage: pack
environment: production
image: docker:18
script:
View docker-compose.yaml
---
version: '2.3'
x-logging: &logging
driver: fluentd
options:
fluentd-address: localhost:24224
fluentd-async-connect: 'true'
tag: 'docker.{{if (index .ContainerLabels "logging-tag") }}{{index .ContainerLabels "logging-tag"}}.{{end}}{
"service_name": "${COMPOSE_PROJECT_NAME}",