Skip to content

Instantly share code, notes, and snippets.

View QNimbus's full-sized avatar
🎯
Focusing

Bas QNimbus

🎯
Focusing
  • The Netherlands
View GitHub Profile
@QNimbus
QNimbus / avg_time
Created January 22, 2022 19:24
Benchmark function that display average runtime for a command
avg_time() {
#
# usage: avg_time n command ...
#
n=$1; shift
(($# > 0)) || return # bail if no command given
for ((i = 0; i < n; i++)); do
{ time -p "$@" &>/dev/null; } 2>&1 # ignore the output of the command
# but collect time's output in stdout
done | awk '
#!/usr/bin/env bash
##
## Title: deploy_homeassistant.sh
## Description: Script to deploy uploaded certificates for use with Home Assistant
## Author: B. van wetten
## Created date: 28-12-2020
## Updated date: 28-12-2020
## Version: 0.1
## GitHub Gist: https://gist.github.com/cb7a61d4be538f80ccac7186a84e5ed4
##
@QNimbus
QNimbus / motion_light_smart.yaml
Last active December 16, 2020 11:45
Turn on a light when motion is detected
blueprint:
name: Motion-activated Light
description: Turn on a light when motion is detected...
domain: automation
source_url: https://gist.github.com/d7384358e6078e9d3add226d1c54ed87
input:
motion_entity:
name: Motion Sensor
selector:
entity:
@QNimbus
QNimbus / customDevices.json
Last active November 24, 2020 15:06
zwave2mqtt custom devices
{
"271-4096-258": [
{
"type": "light",
"object_id": "dimmer",
"values": [
"38-1-0"
],
"discovery_payload": {
"schema": "template",
# In addition to the material design icons - Home Assistant has some builtin icons as well
hass:account
hass:alert
hass:alert-circle
hass:altimeter
hass:apple-safari
hass:apps
hass:arrow-bottom-left
hass:arrow-down
@QNimbus
QNimbus / ensure-ssh-password-not-expired.yml
Last active March 8, 2021 09:14
Ansible playbook to run if provisioning hosts that enforce the user to enter a new password (due to expired password after initial setup/installation e.g. Ubuntu 20.04 LTS Server ARM64 for Raspberry Pi). This play will attempt to login to the hosts and update the password and thereby resetting the password expiry.
---
- hosts: all:!localhost
gather_facts: no
# This play attempts to establish an SSH connection with inventory hosts
# and when it encounters an expired password it will change and reset the password
# so other playbooks and roles can normally execute without failing because of expired password.
# Tested with:
# - Ubuntu
@QNimbus
QNimbus / create_docker_certs.sh
Last active July 7, 2020 03:32
Short script to generate Docker server and client certificates to enable TLS communication
#!/usr/bin/env bash
##
## Title: create_docker_certs.sh
## Description: Short script to generate Docker server and client certificates to enable TLS communication
## Author: B. van wetten
## Created date: 25-05-2020
## Updated date: 25-05-2020
## Version: 0.0.1
## GitHub Gist: https://gist.github.com/QNimbus/19a53ce305e43b12434ddcac740e7bfe
##
@QNimbus
QNimbus / settings.json
Last active March 25, 2025 11:55
Windows Terminal Settings #windows
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
#!/usr/bin/env bash
##
## Title: deploy_adguard.sh
## Description: Script to deploy uploaded certificates for use with AdGuard Home DNS Server
## Author: B. van wetten
## Created date: 13-05-2020
## Updated date: 13-05-2020
## Version: 0.1
## GitHub Gist:
##

Source: electron/electron#9920 (comment)

I hope that this comment get noticed, because a lot of people are asking about importing fs or ipcRenderer in your apps. It's a common-need for electron apps but I found not many people have got it right, and are using outdated patterns. tl;dr - there is a security vulnerability if you don't import your node module (ie. fs) or electron module (ie. ipcRenderer) in the correct way. If you are using your app for only yourself you are probably safe, but if you ever want to share or sell your app you should read ahead.

Our goal

Before I go into the solution, it's important to understand why we are doing this in the first place. Electron apps allow us to include node modules in our apps, which gives them amazing power, but security concerns. We want to allow our app to use native-os (ie. node) features, but we don't want them to be abused.

> As brough