Skip to content

Instantly share code, notes, and snippets.

View psi-4ward's full-sized avatar

Christoph Wiechert psi-4ward

View GitHub Profile
@psi-4ward
psi-4ward / cfg.yaml
Created January 16, 2024 20:10
room-sensor esphome v1
substitutions:
devicename: room-sensor
esphome:
name: $devicename
platform: ESP32
board: esp32-c3-devkitm-1
wifi:
ssid: !secret wifi_ssid
@psi-4ward
psi-4ward / oc-log-view.ts
Created September 1, 2022 13:42
OC Log Prettifier
// deno run --allow-read json-log-view.ts log.txt
import { red, bold } from "https://deno.land/std@0.145.0/fmt/colors.ts";
const text = await Deno.readTextFile(Deno.args[0]);
const lines = text.split(/\r?\n/).filter(l => l.length > 0);
const objs = lines.map(l => {
const res = JSON.parse(l);
if (res.message.includes('{\"Exception\"')) {
res.message = JSON.parse(res.message.replace(/^[^{]+/, ''));
@psi-4ward
psi-4ward / db-migrate.ts
Created May 13, 2020 19:23
sequelize-typescript database migration
/**
* Database migration helper using Umzug
* supports TypeScript (ts-node) and JS
*
* Usage:
* * With ts-node: npx ts-node src/db-migrate.ts
* * or after transpile: node src/db-migrate.js
*
* Params:
* * down: Downgrade the last migration
@psi-4ward
psi-4ward / .xbindkeysrc
Last active March 19, 2023 21:59
Linux window activation by hotkey
# Meta c brings Chrom(e|ium) to foreground
"~/.dotfiles/window-activator.sh -a Chrom"
Mod4+c
# Meta k brings Konsole to foreground
"~/.dotfiles/window-activator.sh -a Konsole"
Mod4+k
# Meta k brings WebStorm to foreground
"~/.dotfiles/window-activator.sh -a WebStorm"
@psi-4ward
psi-4ward / auth.changePassword.js
Last active June 26, 2020 09:56
Feathers.js simple changePassword Service
const auth = require('@feathersjs/authentication');
const errors = require('@feathersjs/errors');
const bcrypt = require('bcryptjs');
const comparePasswords = (oldPassword, password) => new Promise((resolve, reject) => {
bcrypt.compare(oldPassword, password, (err, data1) => {
if(err || !data1) return reject();
return resolve();
});
});
@psi-4ward
psi-4ward / validateSchema.js
Created December 8, 2017 18:51
feathersjs schema validation based on Ajv with switch and $async support
const Ajv = require('ajv');
const ajvKeywords = require('ajv-keywords');
const ajvAsync = require('ajv-async');
const errors = require('@feathersjs/errors');
const app = require('../app');
module.exports = function validateSchemaHookFactory(schema, options) {
const patch = options && options.patch;
if(options) delete options.patch;
@psi-4ward
psi-4ward / list-related-posts.js
Last active January 26, 2018 09:39
Hexo related posts by tags
@psi-4ward
psi-4ward / docker-compose.yml
Created January 29, 2017 21:12
Icinga2 Docker-Compose
version: '2'
services:
mysql:
image: mariadb
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_PASS}
volumes:
- "./mysql:/var/lib/mysql"
@psi-4ward
psi-4ward / mail-notification-host.sh
Last active June 2, 2021 14:38
Icinga2 Mail Notification Scripts (for Director)
#!/bin/sh
# Mail Notification Script for Icinga2 Hosts
# Uses swaks for mail delivery: http://www.jetmore.org/john/code/swaks/
# Date: 2017-01-19
# Author: Christoph Wiechert <wio@psitrax.de>
VERSION=1.0.0
usage() {
echo "Mail Notifications for Icinga2 Host Alerts"
@psi-4ward
psi-4ward / docker-compose.yml
Created January 17, 2017 12:49
Mailcow Docker-Compose File
version: '2'
services:
pdns:
image: andryyy/mailcow-dockerized:pdns
volumes:
- ./data/conf/pdns/:/etc/powerdns/
restart: unless-stopped
networks:
mailcow-network: