Skip to content

Instantly share code, notes, and snippets.

@d3vAdv3ntur3s
d3vAdv3ntur3s / recording.md
Created May 11, 2022 10:54
github readme recording

Install

  • asciinema: brew install asciinema
  • svg-term-cli: npm install -g svg-term-cli

Run

asciinema rec

When done type exit and save locally ctrl+d

@d3vAdv3ntur3s
d3vAdv3ntur3s / delete_branches.sh
Created January 13, 2022 12:19
Delete local & remote git branches after x months old
#!/bin/sh
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$\|develop$'); do
if ! ( [[ -f "$branch" ]] || [[ -d "$branch" ]] ) && [[ "$(git log $branch --since "6 month ago" | wc -l)" -eq 0 ]]; then
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
git branch -d "${local_branch_name}"
echo "${local_branch_name}"
git push origin --delete "${local_branch_name}"
fi
done
@d3vAdv3ntur3s
d3vAdv3ntur3s / git_early_eof_error.md
Created October 28, 2021 13:11
Git early EOF (Error decoding the received TLS packet, index-pack failed) Issue

Git early EOF (Error decoding the received TLS packet, index-pack failed) Issue

git clone https://github.com/d3vadv3ntur3s/some-cool-repo.git
Cloning into 'some-cool-repo'...

remote: Enumerating objects: 145563, done.
@d3vAdv3ntur3s
d3vAdv3ntur3s / config.yml
Created July 31, 2021 15:15
CircleCI Mono Repo Setup
version: 2.1
# Use CircleCI's dynamic configuration feature
setup: true
# Orbs are built in helpers made by CircleCI & the community
orbs:
# Path iltering is the magic behind checking for file changes and leverages continuation orb to proceed with workflows
path-filtering: circleci/path-filtering@0.0.2
@d3vAdv3ntur3s
d3vAdv3ntur3s / Dockerfile
Created July 31, 2021 13:20
Dockerise React with NGNIX
# Stage 1 - Install dependencies & build react assets
FROM node:14-alpine@sha256:0c80f9449d2690eef49aad35eeb42ed9f9bbe2742cd4e9766a7be3a1aae2a310 AS build
WORKDIR /usr/src/app
ENV NODE_ENV=production
COPY package*.json /usr/src/app/
RUN npm i -g npm@7.20.0
# mount a secret i.e. a custom nprc for private repos to be used for the npm clean install command only
@d3vAdv3ntur3s
d3vAdv3ntur3s / Makefile
Created July 31, 2021 12:41
Example Makefile
SHELL:=/usr/bin/env bash #default shell used
MAKEFLAGS += --silent --jobs 10 #don't echo commands and parallelise
# Default task executed when running with make command only no args
default: help
#src: https://victoria.dev/blog/how-to-create-a-self-documenting-makefile/
help: ## Show this help
@egrep -h '\s##\s' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
@d3vAdv3ntur3s
d3vAdv3ntur3s / README.md
Last active August 4, 2021 16:31
Node Docker Best Practices and mounting secret

Docker Build command

id - this has to match the id from the mount secret command src - path to file locally docker build --no-cache . -t test-backend --secret id=npmrc,src=backend/.npmrc --file backend/dockerfile

## Mount secrets commannd Part of the docker build kit, enabled by default A way of securely mounting secrets The secret will not be in the final image, one to use for example performing the command npm ci.

@d3vAdv3ntur3s
d3vAdv3ntur3s / 1password.sh
Created June 25, 2021 13:05
1password setup + retrieval
# install for mac via brew
$ brew install --cask 1password-cli
# sign in via cmd line
# You will need your secret key generated see 1password website: https://support.1password.com/secret-key/
# followed by password
$ op signin subdomain.1password.com user@domain.com
# alias into bash_profile for ease sake
$ alias 1pws='eval $(op signin subdomain)'
@d3vAdv3ntur3s
d3vAdv3ntur3s / gist:d4c785154844dc1f94b2983ff4df0193
Created April 26, 2021 06:19
Hosted Bitbucket Clone v1 API
Older hosted version of Bitbucket 1.0 api
Using token generated via your user settings instead of username password option.
```
curl -H "Authorization: Bearer GENERATE-TOKEN-HERE" \
"$HOSTED_BITBUCKET_URL/rest/api/1.0/projects/BTT/repos?limit=1000" | \
jq -r '.values[].links.clone[] | select(.name=="http") | .href' | \
xargs -n1 git clone
```
@d3vAdv3ntur3s
d3vAdv3ntur3s / openapi.gradle
Created March 14, 2021 15:50
openapi code generator v5 example via Gradle using open API specification 3 for Spring Boot, generating WebFlux controller interface and DTOs
// openapi code generator using open api 3 specification
// This will generate the model, api (interfaces only)
// Spring-boot Server application using the SpringFox integration.
// Generator Docs: https://openapi-generator.tech/docs/generators/spring/
// Gradle plugin: https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-gradle-plugin
// Gradle plugin example: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle
// templatesDir is to override the generated output, e.g. override method signature: Mono<ResponseEntity<Flux<ContactDTO>>> to Flux<ContactDTO> via mustache templates
openApiGenerate {
// don't try and reuse this variable for sourceSet as reference here is for a directory and generated code will append files to src/main/java under this directory