Skip to content

Instantly share code, notes, and snippets.

View madchap's full-sized avatar

Fred Blaise madchap

  • Vaud, Switzerland
View GitHub Profile
@madchap
madchap / vars_check.sh
Created November 18, 2019 11:05
bash vars checks
function check_var_empty() {
# make sure the variables hold some value
for var in "${vars_to_check[@]}"; do
[[ "x${!var}" == "x" ]] && echo "The variable $var is empty, and should not. Will abort." && VAR_EMPTY=1
done
[[ ! -z $VAR_EMPTY ]] && exit -1
}
function sanitize() {
# only allow the characters we want/need
curl -s -H 'Accept: application/vnd.github.v3+json' https://api.github.com/repos/REPO_ORG/REPO_NAME/releases |jq -r '.[0].tag_name'
@startuml
!pragma teoz true
== Release ==
participant "Dev branch" as devbranch order 10 #LightBlue
participant "RC branch" as rcbranch order 20 #YellowGreen
participant "Master branch" as master order 30 #99FF99
participant "Hotfix branch" as hotbranch order 40 #DarkSalmon
{startrc} devbranch -> rcbranch ++ #YellowGreen: Start release
@madchap
madchap / keybase.md
Created March 17, 2020 17:05
keybase.md

Keybase proof

I hereby claim:

  • I am madchap on github.
  • I am madchap (https://keybase.io/madchap) on keybase.
  • I have a public key ASAlthwCTKnzy30GgGsAMvJaascIGYaSb2CgFQSJQwV7tgo

To claim this, I am signing this object:

@madchap
madchap / graphql_github_pr_query.sh
Last active June 19, 2020 20:16
GitHub graphQL PR query
#!/usr/bin/env bash
set -e
set -o pipefail
OUTPUT=$(curl -s --location --request POST 'https://api.github.com/graphql' \
--header "Authorization: Bearer $GH_TOKEN" \
--header 'Content-Type: application/json' \
--data-raw '{"query":"{\n search(first: 50, query: \"repo:DefectDojo/django-DefectDojo is:pr is:merged created:2020-03-12..2020-04-11\", type: ISSUE) {\n nodes {\n ... on PullRequest {\n number\n title\n url\n author { login }\n }\n }\n }\n}","variables":{}}')
echo "$OUTPUT" | jq -r '.data.search.nodes[] | [.number, .author.login, .title, .url] |@csv' | tr -d \" | awk -v FS="," 'BEGIN{OFS="\n";}{printf "- %s @%s [#%i](%s)\n",$3,$2,$1,$4}'
@madchap
madchap / cancel_queued_builds.groovy
Created April 30, 2020 08:10
Cancel all Jenkins queued builds
import hudson.model.*
import jenkins.model.Jenkins
def q = Jenkins.instance.queue
q.items.findAll { it.task.name.startsWith('your_job_name') }.each { q.cancel(it.task) }
[uwsgi]
socket = 0.0.0.0:3031
protocol = uwsgi
module = dojo.wsgi:application
py-autoreload = 1
lazy-apps
honour-stdin
threaded-logger
buffer-size = 4096
; log-encoder = json {"unix":${unix}, "msg":"${msgln}", "date":"${strftime:%%d/%%m/%%Y %%H:%%M:%%S}"}
@madchap
madchap / JIRA field to screen checkbox.js
Created December 24, 2020 10:46
JIRA field to screen checkbox
document.querySelectorAll("input[name=associatedScreens]").forEach(input => input.checked = true)
@madchap
madchap / Dockerfile
Created November 15, 2021 20:28
Hello gRPC server
FROM golang:1.17 AS builder
RUN apt-get update && apt-get install -y --no-install-recommends git; \
rm -rf /var/lib/apt/lists/*
WORKDIR $GOPATH/src/helloworld
RUN git clone -b v1.41.0 https://github.com/grpc/grpc-go
WORKDIR grpc-go/examples/helloworld/greeter_server
RUN go mod init
RUN go get -d -v
RUN CGO_ENABLED=0 go build -o /go/bin/greeter_server
@madchap
madchap / maven_dependency_version_enforcer.xml
Created December 16, 2021 15:38
maven dependency version enforcer
<!-- plug-in configuration to put into your parent POM for avoiding any usages of outdated log4j2 versions,
some of which are subject to the RCE CVE-2021-44228 ("Log4Shell") and CVE-2021-45046 -->
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>ban-bad-log4j-versions</id>