Skip to content

Instantly share code, notes, and snippets.

Avatar

Christoph Wiechert psi-4ward

View GitHub Profile
@psi-4ward
psi-4ward / db-migrate.ts
Created May 13, 2020
sequelize-typescript database migration
View db-migrate.ts
/**
* 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 Jun 22, 2018
Linux window activation by hotkey
View .xbindkeysrc
# 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 Jun 26, 2020
Feathers.js simple changePassword Service
View auth.changePassword.js
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 Dec 8, 2017
feathersjs schema validation based on Ajv with switch and $async support
View validateSchema.js
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 Jan 26, 2018
Hexo related posts by tags
View list-related-posts.js
@psi-4ward
psi-4ward / docker-compose.yml
Created Jan 29, 2017
Icinga2 Docker-Compose
View docker-compose.yml
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 Jun 5, 2018
Icinga2 Mail Notification Scripts (for Director)
View mail-notification-host.sh
#!/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 Jan 17, 2017
Mailcow Docker-Compose File
View docker-compose.yml
version: '2'
services:
pdns:
image: andryyy/mailcow-dockerized:pdns
volumes:
- ./data/conf/pdns/:/etc/powerdns/
restart: unless-stopped
networks:
mailcow-network:
@psi-4ward
psi-4ward / README.md
Created Dec 13, 2016
Feathers.js multipart/file-data Upload Middleware
View README.md

Feathers.js multipart/file-data Upload middleware

Parses multipart/form-data uploads and stream files to a blob-store.
After uploading the Services receives a json-body with the file references:

{
  "files": [
    {
      "key": "34525ca2-f774-444f-8e7e-7622bef69cb1",
      "filename": "13.jpg",
View feathers-socket.js
import feathersClient from '../../../be/node_modules/feathers/client';
import socketioClient from '../../../be/node_modules/feathers-socketio/client';
import ioClient from '../../../be/node_modules/socket.io-client';
import authentication from '../../../be/node_modules/feathers-authentication/client';
import hooks from '../../../be/node_modules/feathers-hooks';
import findIndex from 'lodash/findIndex';
import find from 'lodash/find';
import Vue from 'vue';
export const errorHandlers = [];