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 / customize-grml.md
Last active December 2, 2023 06:41
Customize Grml LiveCD (remaster)

Customize Grml LiveCD (remaster)

This little bash script helps you to build your own customized grml.iso

Features

  • Include your .ssh/*.pub files into authorized_keys
  • Inject Grml Cheats
  • Auto download all necessary files (the ISO and grml2usb)
@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 / README.md
Created December 13, 2016 19:40
Feathers.js multipart/file-data Upload Middleware

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",
@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 / GridStream.js
Created October 22, 2013 11:28
NodeJS MongoDB-GridFS Video range stream example Lets your browser seek/jump wihin the video-playback.
var app = require('express')();
var GridStore = require('mongodb').GridStore;
var ObjectID = require('mongodb').ObjectID;
var MongoClient = require('mongodb').MongoClient;
var Server = require('mongodb').Server;
var dbConnection;
MongoClient.connect("mongodb://localhost:27017/ersatz?auto_reconnect", {journal: true}, function(err, db) {
dbConnection = db;
app.listen(3000);
@psi-4ward
psi-4ward / LoginController.js
Created January 12, 2015 16:09
Sails.JS JWT Auth
// controllers/LoginController.js
module.exports = {
index: function(req, res) {
var email = req.param('email');
var password = req.param('password');
// delay everthing to prevent bruteforce, dos and timing attacks
setTimeout(function() {
@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 / 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 / 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