Skip to content

Instantly share code, notes, and snippets.

@d3vAdv3ntur3s
d3vAdv3ntur3s / Backup and view Slack workspace conversation history
Created May 14, 2019 19:14
Instructions for how to backup and view Slack workspace chat history
Login to slack workspace -> https://api.slack.com/custom-integrations/legacy-tokens -> select generate token
* Dependencies required:
** `pip install slacker` # https://github.com/os/slacker
** `pip install pick` # https://github.com/wong2/pick
** Download Slack export tool: `https://github.com/zach-snell/slack-export/archive/master.zip`
** `pip install slack-export-viewer` # https://github.com/hfaran/slack-export-viewer
* Run instructions:
** `python slack_export.py --token xoxp-2474487112... --directMessages --publicChannels myTeam inccidents` # creates timestamped folder e.g. <yyyymmdd>-<hhmmss>-slack_export
@d3vAdv3ntur3s
d3vAdv3ntur3s / db_init.sh
Created March 14, 2021 14:33
Example docker-compose with initialise script mount, network, healthcheck and volume
#!/usr/bin/env bash
# Exit immediately, do not continue running commands after error
set -o errexit
##################################### NOTE ############################################
# Anything copied into the /docker-entrypoint-initdb.d will be executed automatically #
# in alphanumeric order, can be useful 1_setup.sql, 2_data.sql #
# This script will work for dockerised or system installed Postgres #
#######################################################################################
@d3vAdv3ntur3s
d3vAdv3ntur3s / build.gradle
Last active March 14, 2021 14:39 — forked from jahe/gradle-cheatsheet.gradle
Gradle Cheatsheet
//Gradle `>=6.8` example build file, resolve versions from `./gradle/gradle.properties`
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE' //BOM dependency management and exclusions
id 'org.openapi.generator' version '5.0.1'
id 'java'
id 'maven-publish'
id "com.google.osdetector" version "1.7.0"
id 'signing'
@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
@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 / 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)'

Keybase proof

I hereby claim:

  • I am d3vadv3ntur3s on github.
  • I am devadventures (https://keybase.io/devadventures) on keybase.
  • I have a public key ASC0KBgXCd4-4OT3HZe2t7DP6JnhoDoMolrx9Mx-K2TOZQo To claim this, I am signing this object:
{
  "body": {
    "key": {
@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 / 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 / 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.