Skip to content

Instantly share code, notes, and snippets.

View qoomon's full-sized avatar
🌳
Go for it.

Bengt Brodersen qoomon

🌳
Go for it.
View GitHub Profile
@qoomon
qoomon / ElastisearchIngestExample.md
Last active May 8, 2018 09:31
Elasticsearch auto generated timestamps

PUT _ingest/pipeline/timestamp

{
    "description": "Adds a timestamp field at the current time",
    "processors": [
        {
            "set": {
                "field": "@timestamp",
                "value": "{{_ingest.timestamp}}",
 "override": false
@qoomon
qoomon / config
Last active September 4, 2017 10:16
~/.ssh/config
Host *.compute.amazonaws.com
User ec2-user
IdentityFile ~/.ssh/aws.pem
Host *.compute.internal
User ec2-user
IdentityFile ~/.ssh/aws.pem
Host *
IdentityFile ~/.ssh/id_rsa
@qoomon
qoomon / docker-compose
Created September 4, 2017 11:50
docker-compose as docker container alias
alias docker-compose='docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v "${PWD}":"${PWD}" --workdir="$(pwd)" docker/compose'
@qoomon
qoomon / aws_ec2_userdata_builder.sh
Last active September 5, 2017 09:06
Build Directory Based AWS EC2 Userdata
#!/bin/sh
userdata=$(cat <<END
#!/bin/sh
echo '$(tar -cv userdata |gzip --best |base64)' |base64 -d |gzip -d |tar -xv
cd userdata
chmod u+x init.sh
./init.sh
END
)
@qoomon
qoomon / TravisGitHub.md
Last active August 6, 2023 04:59
Setup GitHub Deploy Keys For Travis
@qoomon
qoomon / git_create_orphan_branch.sh
Last active September 12, 2017 10:36
Create Git Orphan Branch
#!/bin/bash
BRANCH_NAME=$1
git checkout --orphan $BRANCH_NAME
git rm -rf .
rm -f '.gitignore'
echo "#$BRANCH_NAME" > README.md
git add README.md
git commit -a -m "Initial Commit"
@qoomon
qoomon / docker-compose.yaml
Created November 17, 2017 12:19
Docker Logging Tag
---
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}",
@qoomon
qoomon / .gitlab-ci.yml
Last active July 20, 2022 23:18
GitLab CI - build and push docker image to GitLab registry
stages:
- pack
### Pack ######################################################################
docker:
stage: pack
environment: production
image: docker:18
script:
@qoomon
qoomon / ExceptionUtils.java
Last active July 20, 2018 11:09
Java - Throw checked exceptions as a unchecked exceptions see https://github.com/qoomon/unchecked-exceptions-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;
}
@qoomon
qoomon / pathAccess.js
Last active May 16, 2018 15:04
Set and get JSON values by path string.
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);