Skip to content

Instantly share code, notes, and snippets.

@Darkbat91
Darkbat91 / main.ts
Created December 4, 2019 15:57
expressjs cache
// Cache layer for expressjs in typescript
// Based on https://medium.com/the-node-js-collection/simple-server-side-cache-for-express-js-with-node-js-45ff296ca0f0
// Caches the headers specifically to resolve CORS Errors i was running into with the implementation above.
var mcache = require('memory-cache');
let cache = (duration: number) => {
return (req: any, res: any, next: any) => {
let key = '__express__' + req.originalUrl || req.url
let headerkey = key + '-header'
let cachedBody = mcache.get(key)
@Darkbat91
Darkbat91 / wififixinstall.sh
Last active August 9, 2019 08:44
Fixes wifi Issues with the OpenWRT Routers with both client mode and AP Mode being active at the same time
#!/bin/sh
# Make the python file
mkdir -p /usr/share/wififix/
cat >/usr/share/wififix/fix.py <<EOL
import subprocess
def updatewireless():
edit = False
needdisable = True
@Darkbat91
Darkbat91 / http-cat-error-pages.conf
Created August 5, 2019 16:59 — forked from mjmeyer/http-cat-error-pages.conf
Http.cat erorr pages for nginx
# ---------- Status Cats Error Pages!!! via: https://http.cat/ ---------
#
# requires that a dns resolver be set for nginx as in: resolver 127.0.0.1;
# typically uses dnsmasq for 127.0.0.1 resolver
#
# Usage:
# place this file somewhere accessible to nginx. /etc/nginx/snippets is a decent choice.
# then inside the server block(s) you want cat themed error status responses do:
# include snippets/http-cat-error-pages.conf
#
<#
Blocks USB devices from being used by registering a WMI event, Not entirely secure as base64 encoded secret is stored in WMI
Approved devices are by default stored in the root of the C drive should be moved to another directory or registry?
#>
function Get-Base64 {
param($string)
$Bytes = [System.Text.Encoding]::Unicode.GetBytes($string)
function Set-SCCMClientBusinessHours
{
<#
.SYNOPSIS
Sets the Business Hours of the SCCM client
.DESCRIPTION
Sets the flag for rebooting inside or outside of business Hours, The Working Days, And the Start end end time in 24 hour format
.PARAMETER ComputerName
Name of computer to set the configuration on - Default is Localhost
.PARAMETER RebootOutsideBusinessHours
# http://boxstarter.org/launch/Boxstarter.WebLaunch.Application?noreboot=1&package=https://gist.githubusercontent.com/Darkbat91/89c26989ef6526960306d032ce9a4d7f/raw/
#https://tinyurl.com/WCRYFix
<#
The MIT License (MIT)
Copyright (c) 2016 Warren F.
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
function Get-UnobfuscatedData
{
param($string)
$data = Replacehex -string $string
return [System.Text.Encoding]::UTF8.GetString(([System.Convert]::FromBase64String($data)|?{$_}))
}
function Replacehex {
param($string)
[regex]$regex ='(\%[A-Fa-f0-9]{2})'
<#
.SYNOPSIS
Audits weak service permissions
.DESCRIPTION
Views Services on computer and return all weak permissions that are present
.NOTES
Author: Micah
Creation Date: 20170329
Last Modified: 20170329
Version: 0.0.1