Skip to content

Instantly share code, notes, and snippets.

@thomasbad
thomasbad / MyCourses-BulkDownload.js
Created July 16, 2024 02:32
Adding a button to bulk download all the lecture slides of each course (Use Tampermonkey).
// ==UserScript==
// @name MyCourses-BulkDownload
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://mycourses.ict.mahidol.ac.th/course/view.php?id=*
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jszip-utils/0.0.2/jszip-utils.min.js
// @require https://fastcdn.org/FileSaver.js/1.1.20151003/FileSaver.min.js
@thomasbad
thomasbad / Ai.ipynb
Created February 25, 2023 18:06
AI.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasbad
thomasbad / faceswap-trainer-work.ipynb
Created February 7, 2023 08:52
faceswap-trainer-work.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasbad
thomasbad / colab-textgen-gpu.ipynb
Created February 7, 2023 07:58
Colab-TextGen-GPU.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasbad
thomasbad / gpu.ipynb
Created February 7, 2023 07:55
GPU.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasbad
thomasbad / wifipassword.ps1
Created October 11, 2022 12:57
Retrieve all saved Wi-Fi password from PowerShell in Windows 10/11
(netsh wlan show profiles) | Select-String "\:(.+)$" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)} | Select-String "Key Content\W+\:(.+)$" | %{$pass=$_.Matches.Groups[1].Value.Trim(); $_} | %{[PSCustomObject]@{ PROFILE_NAME=$name;PASSWORD=$pass }} | Format-Table -AutoSize
pause
@thomasbad
thomasbad / admin2.ps1
Created August 24, 2022 01:34
Ask if run the script in admin with powershell
$ErrorActionPreference = 'SilentlyContinue'
$Button = [System.Windows.MessageBoxButton]::YesNoCancel
$ErrorIco = [System.Windows.MessageBoxImage]::Error
$Ask = 'Do you want to run this as an Administrator?
Select "Yes" to Run as an Administrator
Select "No" to not run this as an Administrator
Select "Cancel" to stop the script.'
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
@thomasbad
thomasbad / sample.ps1
Created August 16, 2022 01:38
Sanitize input from user in PowerShell
#Sample 1
$str = '< > : " / \ | ? *'
$strFixed = $str.Replace('<','_').Replace('>','_').Replace(':','_').Replace('"','_').Replace('/','_').Replace('\','_').Replace('|','_').Replace('?','_').Replace('*','_')
$strFixed
#Sample 2
$strFixed2 = $str -replace '[<>:"/\\|?*]','_'
@thomasbad
thomasbad / Auto.ps1
Created August 9, 2022 09:06
Given PowerShell script a title and run as admin automatically
# Ask if the script have run as admin, if not, run as admin
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" +$myinvocation.mycommand.definition + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
# PowerShell Window Title
$host.UI.RawUI.WindowTitle = "PS Title"
@thomasbad
thomasbad / auto_admin.bat
Last active July 11, 2022 10:14
Batch script to ask the batch auto run as admin or output error and ask user to run as admin manually
@echo off
:: Ensure admin privileges
fltmc >nul 2>&1 || (
echo Administrator privileges are required.
PowerShell Start -Verb RunAs '%0' 2> nul || (
echo Right-click on the script and select "Run as administrator".
pause & exit 1
)
exit 0
)