Skip to content

Instantly share code, notes, and snippets.

View huysentruitw's full-sized avatar
👋
Hi there! I'm using GitHub.

huysentruitw huysentruitw

👋
Hi there! I'm using GitHub.
  • Huysentruit
  • Belgium
View GitHub Profile
@huysentruitw
huysentruitw / sw-registrator.js
Last active December 28, 2022 17:01
sw-registrator.js for medium article about Blazor WASM PWA
window.updateAvailable = new Promise((resolve, reject) => {
if (!('serviceWorker' in navigator)) {
const errorMessage = `This browser doesn't support service workers`;
console.error(errorMessage);
reject(errorMessage);
return;
}
navigator.serviceWorker.register('/service-worker.js')
.then(registration => {
@huysentruitw
huysentruitw / ConfigureWindowsFirewallRulesForUnifi.ps1
Created January 26, 2022 13:46
Configure Windows Firewall Rules for Unifi Network discovery
# Copied from https://community.ui.com/questions/Windows-Firewall-keeps-blocking-APs-in-controller-show-as-disconnected-even-though-operable-/01839bc6-56f6-473a-b9ba-6bbc1d8ec36d#answer/44bdb22f-4174-4e02-a3d3-f1469702e431
New-NetFirewallRule -Name _UniFi-Mgmt-In -DisplayName "_UniFi-Mgmt (TCP-In 8081)" -Description "Allows incoming UniFi management traffic" -Group UniFi -Enabled True -Protocol TCP -LocalPort 8081 -Direction Inbound
New-NetFirewallRule -Name _UniFi-DvcInfrm-In -DisplayName "_UniFi-DvcInfrm (TCP-In 8080)" -Description "Allows incoming UniFi device inform traffic" -Group UniFi -Enabled True -Protocol TCP -LocalPort 8080 -Direction Inbound
New-NetFirewallRule -Name _UniFi-Ctrlr-In -DisplayName "_UniFi-Ctrlr (TCP-In 8443)" -Description "Allows incoming UniFi Controller traffic" -Group UniFi -Enabled True -Protocol TCP -LocalPort 8443 -Direction Inbound
New-NetFirewallRule -Name _UniFi-PrtlRdr-In -DisplayName "_UniFi-PrtlRdr (TCP-In 8880)" -Description "Allows incoming UniFi portal redirect tra
@huysentruitw
huysentruitw / gist:9b77582f66229d3cef4caaa08f52aec4
Created January 20, 2022 14:05
Enable Windows 11 update on unsupported hardware
reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseVersion /t REG_DWORD /d 1
reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseVersionInfo /t REG_SZ /d "21H2"
reg add HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v ProductVersion /t REG_SZ /d "Windows 11"
reg add HKLM\SYSTEM\Setup\MoSetup /v AllowUpgradesWithUnsupportedTPMOrCPU /t REG_DWORD /d 1
Remove the keys again after succesful update:
reg del HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseVersion
reg del HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v TargetReleaseVersionInfo
reg del HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate /v ProductVersion
@huysentruitw
huysentruitw / UpdateAvailableDetector.razor.css
Created November 30, 2021 20:18
UpdateAvailableDetector.razor.css for medium article about Blazor WASM PWA
.floating-update-button {
position: fixed;
right: 2rem;
bottom: 2rem;
padding: 1rem 1.5rem;
animation: fadein 2s ease-out;
}
@huysentruitw
huysentruitw / service-worker.js
Last active November 20, 2021 13:12
service-worker.js for medium article about Blazor WASM PWA
// Caution! Be sure you understand the caveats before publishing an application with
// offline support. See https://aka.ms/blazor-offline-considerations
self.importScripts('./service-worker-assets.js');
self.addEventListener('install', event => event.waitUntil(onInstall(event)));
self.addEventListener('activate', event => event.waitUntil(onActivate(event)));
self.addEventListener('fetch', event => event.respondWith(onFetch(event)));
const cacheNamePrefix = 'offline-cache-';
const cacheName = `${cacheNamePrefix}${self.assetsManifest.version}`;
@huysentruitw
huysentruitw / PasswordHasher.cs
Last active May 26, 2020 08:18
PasswordHasher class for generating and verifying secure password hashes
/*
* Copyright 2016-2020 Wouter Huysentruit
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
@huysentruitw
huysentruitw / chrome-offline-game.js
Created April 6, 2020 19:38
chrome-offline-game
jump = () => {
const space = { bubbles: true, key: 'Space', keyCode: 32, charCode: 0 };
document.activeElement.dispatchEvent(new window.KeyboardEvent('keydown', space));
document.activeElement.dispatchEvent(new window.KeyboardEvent('keyup', space));
};
ctx = document.getElementsByClassName('runner-canvas')[0].getContext('2d');
detect = () => {
const data = ctx.getImageData(105, 125, 1, 1).data;
@huysentruitw
huysentruitw / nested-gql-resolvers.js
Last active February 24, 2020 19:38
Nested graphql resolvers with NodeJS
"use strict";
const express = require('express');
const express_graphql = require('express-graphql');
const { GraphQLSchema, GraphQLObjectType, GraphQLString } = require('graphql');
// GraphQL schema
const songType = new GraphQLObjectType({
name: 'SongType',
fields: {
@huysentruitw
huysentruitw / flash.cmd
Created January 26, 2020 08:18
Flash nanoframework to ESP32
nanoff --update --target ESP32_WROOM_32 --serialport COM3
@huysentruitw
huysentruitw / ESP32 firmware.log
Last active January 26, 2020 08:18
nanoFramework firmware upload
nanoFramework Firmware Flasher v1.2.0+d5d164cfbc
Copyright (C) 2019 nanoFramework project contributors
Connected to ESP32 ESP32D0WDQ6 (revision 1) with MAC address 30AEA42503B8
features WiFi, BT, Dual Core, Coding Scheme None
Flash information: manufacturer 0x200 device 0x16406 size 4MB
Trying to find ESP32_WROOM_32 in developement repository...OK
Downloading firmware package...OK
Updating to 1.4.0-preview.87
Erasing flash...OK