Skip to content

Instantly share code, notes, and snippets.

# Credits: https://squirrelistic.com/blog/how_to_download_older_version_of_google_chrome
$ChromeVersion = '123'
$requestId = ([String][Guid]::NewGuid()).ToUpper()
$sessionId = ([String][Guid]::NewGuid()).ToUpper()
$xml = @"
<?xml version="1.0" encoding="UTF-8"?>
<request protocol="3.0" updater="Omaha" sessionid="{$sessionId}"
#!/bin/bash
temp_threshold_low=40
temp_threshold_mid=50
temp_threshold_high=60
temp_threshold_max=70
power_threshold_low=180
power_threshold_mid=300
power_threshold_high=500
power_threshold_max=800
@changbowen
changbowen / CycleWallpaperWithDate.ps1
Last active November 17, 2023 14:22
PowerShell script to be used with bginfo.exe that cycles wallpaper based on date
param(
# The folder containing the images
[Parameter()][string]$imgPath = $env:imgPath,
[Parameter()][string]$bgiPath = $env:bgiPath
)
if ([string]::IsNullOrEmpty($imgPath) -or [string]::IsNullOrEmpty($bgiPath)) {
throw "You need to set imgPath and bgiPath environment variables or pass them in."
}
#region function definitions
@changbowen
changbowen / ObservableKeyedCollection.cs
Last active November 14, 2023 06:05
Observable KeyedCollection with support for data binding and key updating
//KeyedCollection keeps an internal lookup dictionary for better performance.
//With normal implementations of an observable KeyedCollection, when used for
//data bindings in WPF, once the key of the item is changed with bindings, the
//corresponding key internal dictionary is not changed, which leads to hidden
//problems when the dictionary is used.
//Below is a custom implementation of KeyedCollection to solve that problem.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@changbowen
changbowen / dns.ps1
Created August 4, 2023 14:41
DNS query PowerShell script that saves you from typing
param (
[string]$Address,
[string]$Server
)
function FormatDnsRecords {
[CmdletBinding()]
param(
[parameter(ValueFromPipeline, Mandatory)]
[Microsoft.DnsClient.Commands.DnsRecord]$Record
@changbowen
changbowen / auto_default_gateway_metric.ps1
Last active November 7, 2022 16:40
PowerShell script that monitors for IP changes and updates route metric according to internet reachability
function ipChangeHandler {
Write-Host "Detected an IP change..."
Write-Host "Collecting connections information..."
$connObjs = New-Object System.Collections.ArrayList
$ints = Get-NetIPAddress -AddressFamily IPv4 -PrefixOrigin Dhcp -AddressState Preferred
foreach ($int in $ints) {
$_alias = $int.InterfaceAlias
$_index = $int.InterfaceIndex
$_ipaddr = $int.IPAddress
$intCfg = $int | Get-NetIPConfiguration
@changbowen
changbowen / youtube-downloader.py
Created August 17, 2022 13:30
download youtube chaptered videos into separate files, without downloading chapters that already exist based on checking on the names
import os, sys
from pathlib import Path
import yt_dlp
url = sys.argv[1] if len(sys.argv) > 1 else None
download_root = sys.argv[2] if (len(sys.argv) > 2) else None
proxy = sys.argv[3] if (len(sys.argv) > 3) else None
if (None in [url, download_root, proxy]):
raise RuntimeError('Missing arguments.')
@changbowen
changbowen / Test-RPC.ps1
Created October 11, 2019 09:05
modified version of the Test-RPC from Ryan Ries
# Author: Ryan Ries [MSFT]
# Origianl date: 15 Feb. 2014
#Requires -Version 3
Function Test-RPC {
[CmdletBinding(SupportsShouldProcess = $True)]
Param(
[Parameter(ValueFromPipeline = $True)][String[]]$ComputerName = 'localhost',
[int[]]$Ports = $null
)
BEGIN {
@changbowen
changbowen / openwrt-lede-on-wd-mbl.sh
Created January 17, 2022 12:38 — forked from braian87b/openwrt-lede-on-wd-mbl.sh
Install OpenWRT or LEDE on WD MBL Western Digital MyBookLive
# Instructions to Install OpenWRT or LEDE on WD MBL Western Digital MyBookLive (Tested on Single, but it should work on Duo too)
# Recommended to use a Linux / Debian box with wget, dd, gunzip, lsblk
# Using a Debian box (it could be a VM) with the harddrive connected (it could be a minimal net-install Debian)
See ip with:
ip addr show
# connect remotely using:
user@outside:~/# ssh user@10.211.55.6
# We elevate permissions or even better install and config sudo
user@debian8vm:~/# su
@changbowen
changbowen / remove_dameware.ps1
Created August 20, 2019 03:46
remove devices leftover from a dameware uninstall
################################
# Script created by Carl Chang #
################################
$devcon = 'path\to\devcon_x64.exe'
# uninstall dameware products
wmic product where "name like '%%dameware%%'" call uninstall
# remove left-over devices