This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $curr = Get-Location | |
| Get-ChildItem -Recurse | Sort-Object LastWriteTime -Descending | ForEach-Object { | |
| Set-Location "$($_.FullName)/../" | |
| if ((Select-String -Path $($_.FullName) -Pattern "\s*public static void main\(String\[\]\s*args\)") -and (Get-Command "javac" -ErrorAction Ignore) -and (Get-Command "java" -ErrorAction Ignore)) { | |
| $compileOutput = &javac $_ 2>&1 | Out-String -Stream | |
| if ($?) { | |
| &"java" "$($_.Name -replace "\..+",'')" | |
| } | |
| foreach ($outMessage in $compileOutput) { | |
| Write-Host $out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Data validation | |
| description: >- | |
| Sets data validation rules on ranges, prompts users to enter valid data, and | |
| displays messages when invalid data is entered. | |
| host: EXCEL | |
| api_set: {} | |
| script: | |
| content: | | |
| $("#setup").click(() => tryCatch(setup)); | |
| $("#positive-number").click(() => tryCatch(addPositiveNumberRequirement)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Get current Wifi SSID | |
| $ssid = $(netsh wlan show interfaces | Select-String -Pattern ".*Profile\s+:\s*(.*?)(?: \d+)?\s*$").Matches.Groups[1].Value | |
| # Get Wifi key and set it to clipboard | |
| $( &netsh.exe @("wlan", "show", "profile", "$ssid", "key=clear") | Select-String -Pattern ".*?key content\s+:\s*(.*)$").Matches.Groups[1].Value | Set-Clipboard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $office = (Get-ChildItem 'HKLM:\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' | where -FilterScript { $_.GetValue("InstallLocation") -ccontains "C:\Program Files\Microsoft Office" } ) | |
| $office.GetValue("DisplayName"); $office.GetValue("DisplayVersion") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Bcolors: | |
| def __init__(self): | |
| self.HEADER = '\033[95m' | |
| self.OKBLUE = '\033[94m' | |
| self.OKGREEN = '\033[92m' | |
| self.WARNING = '\033[93m' | |
| self.FAIL = '\033[91m' | |
| self.ENDC = '\033[0m' | |
| self.BOLD = '\033[1m' | |
| self.UNDERLINE = '\033[4m' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Search | |
| description: Shows basic and advanced search capabilities. | |
| host: WORD | |
| api_set: {} | |
| script: | |
| content: | | |
| $("#setup").click(() => tryCatch(setup)); | |
| $("#basic-search").click(() => tryCatch(basicSearch)); | |
| $("#wildcard-search").click(() => tryCatch(wildcardSearch)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This contains two lines (#4, #7) which will be run as an encoded PowerShell command inside a Visual Basic Script (VBScript) scheduled task below. | |
| # Check if 'updateJDK.vbs' is already running in another process; if so, let's quit and just let that finish the task | |
| Get-Process -Name '*WScript*' | foreach{if($_.CommandLine -imatch 'updateJDK.vbs' -and $_.Id -ne $PID){ exit } } | |
| # We will update the %JAVA_HOME% path upon observing discrepency between the newest available JDK (local directory) and the %JAVA_HOME% | |
| $jdk = Get-ChildItem (Resolve-Path 'C:\Program Files\AdoptOpenJDK\') -Depth 0 -Directory | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 1; if(($null -ne ([System.Environment]::GetEnvironmentVariable('JAVA_HOME'))) -and ($env:JAVA_HOME -ne $jdk)) { [System.Environment]::SetEnvironmentVariable('JAVA_HOME',$($jdk.FullName),[System.EnvironmentVariableTarget]::User) } | |
| # Whenever we change the script (i.e., the above line of PowerShell commands), we generate the new encoded command |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Get-ChildItem -Recurse -File -include @('*.mov','*.mp4','*.mp2')| Where-Object -Property Length -GT 100Mb | foreach{ | |
| $curDuration = 0 | |
| $file = $_ | |
| Push-Location (Resolve-Path $file.PSParentPath -Relative) | |
| $duration = [double](ffprobe -i "$($file.FullName)" -show_entries format=duration -v quiet -of default=noprint_wrappers=1:nokey=1) | |
| for($i=0;$curDuration -lt $duration; $i++) { | |
| $nextFileName = $file.BaseName + "-" + "$i"+$file.Extension | |
| $args = "-ss $curDuration -i $($file.Name) -fs $(100Mb) $nextFileName" | |
| Write-Host "ffmpeg $args"; pause; | |
| Start-Process -FilePath (Resolve-Path (which ffmpeg)) -ArgumentList $args -WorkingDirectory $PWD -NoNewWindow -PassThru -Wait; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $pyExts = @() # Python extensions in VS Code array of strings scoped variable to be accessible outside the foreach context below | |
| # Below, we get the `cmd` for VS Code in a flexible way | |
| # Stable VS Code uses `code.cmd` | |
| # Insider VS Code uses `code-insider.cmd` | |
| # Thus, Stable and Insider editions use the pattern `code*cmd` | |
| Get-Command -Name code*cmd -CommandType Application | ForEach-Object { | |
| $vscode = $_ | |
| # Let's be sure VS Code isn't running | |
| if ($null -ne ($VSCodeProcs = &$vscode --status | Select-String -Pattern '(?<cpu>\d+)\s+(?<mem>\d+)\s+(?<pid>\d+).+main' -AllMatches)){ | |
| # Use `taskkill` to gently request that VS Code terminate gracefully (as opposed to violently killing the process using the `Stop-Process` cmdlet) |