Skip to content

Instantly share code, notes, and snippets.

@dnno
dnno / vaultwarden.service
Last active August 4, 2021 13:33
Systemd service for Vaultwarden
[Unit]
Description=Vaultwarden
After=docker.service network.target
Requires=docker.service network-online.target
[Service]
RemainAfterExit=true
WorkingDirectory=/home/pi
ExecStartPre=/usr/local/bin/docker-compose pull --quiet
ExecStart=/usr/local/bin/docker-compose up
@dnno
dnno / vaultwarden-backup.timer
Created May 10, 2021 11:16
Systemd timer for Vaultwarden backup
[Unit]
Description=schedule vaultwarden backups
[Timer]
OnCalendar=04:00
Persistent=true
[Install]
WantedBy=multi-user.target
@dnno
dnno / docker-compose.yaml
Created May 10, 2021 11:18
Docker-compose setup for Vaultwarden
version: '3'
services:
bitwarden:
image: vaultwarden/server:latest
container_name: vaultwarden
restart: always
environment:
- WEBSOCKET_ENABLED=true
- SIGNUPS_ALLOWED=false
@dnno
dnno / Caddyfile
Created May 10, 2021 11:19
Configuration for Caddy
{$DOMAIN}:443 {
log {
level INFO
output file {$LOG_FILE} {
roll_size 10MB
roll_keep 10
}
}
# Use the ACME HTTP-01 challenge to get a cert for the configured domain.
@dnno
dnno / git-remove-merged-branches.sh
Last active June 24, 2021 10:54
Remove merged git branches
#!/usr/bin/env bash
git remote prune origin && \
git branch --merged >/tmp/merged-branches && \
vim /tmp/merged-branches && \
xargs git branch -d </tmp/merged-branches && \
rm /tmp/merged-branches
class MockKJUnitRunner(private val testClass: Class<*>) : Runner() {
private val methodDescriptions: MutableMap<Method, Description> = mutableMapOf()
init {
testClass.methods
.map { method ->
val annotation: Annotation? = method.getAnnotation(Test::class.java)
method to annotation
}
@RunWith(MockKJUnitRunner::class)
class MyTest {
@InjectMockKs
lateinit var subject: Subject
@MockK
lateinit var mockedDependency: Dependency
}
@Before
fun setUp() {
MockKAnnotations.init(this, relaxUnitFun = true)
}
@dnno
dnno / pre-request.js
Last active May 24, 2022 09:23
Postman pre-request script
let url_auth = pm.variables.get("keycloak_url")+"/auth/realms/" + pm.variables.get("keycloak_realm") + "/protocol/openid-connect/token";
let params = "client_id=" + pm.variables.get("keycloak_client_id")
+ "&client_secret=" + pm.variables.get("keycloak_client_secret")
+ "&grant_type=client_credentials";
pm.sendRequest(
{
url: url_auth,
method: 'POST',
@dnno
dnno / response-test.js
Last active May 24, 2022 09:43
Postman response test
let jsonData = JSON.parse(responseBody)
pm.test("Cars have been received", () => {
pm.response.to.have.status(200)
pm.expect(jsonData).to.not.be.undefined
pm.expect(jsonData).to.be.an('array')
pm.expect(jsonData).to.not.be.empty
});