Skip to content

Instantly share code, notes, and snippets.

@SCP002
SCP002 / terminal_darwin.go
Last active October 25, 2025 04:01
Golang: Write a message to any console's input on POSIX.
//go:build darwin
package main
import (
"fmt"
"path/filepath"
"golang.org/x/sys/unix"
)
@SCP002
SCP002 / disable-windows-10-updates.reg
Last active June 19, 2021 18:58
Windows Registry: Disable Windows 10 updates.
Windows Registry Editor Version 5.00
; Disable Windows 10 updates.
; To enable it back, delete these values.
; Tested with Windows 10 Pro 20H2, build 19042.1052
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate]
"DoNotConnectToWindowsUpdateInternetLocations"=dword:00000001
@SCP002
SCP002 / get_process_tree.go
Last active January 11, 2025 09:05
Golang: Get all descendants of the specified process.
// Used in https://github.com/SCP002/terminator.
package main
import (
"errors"
"fmt"
"github.com/shirou/gopsutil/v4/process"
)
@SCP002
SCP002 / init_console_handlers_windows.go
Last active August 25, 2025 19:54
Golang: Initialize console handlers after AttachConsole or AllocConsole on Windows.
// Used in https://github.com/SCP002/terminator.
package main
import (
"errors"
"os"
"golang.org/x/sys/windows"
)
@SCP002
SCP002 / write_to_stdin_windows.go
Last active January 11, 2025 09:28
Golang: Write a message to the current (see comments for a method for any console) console's input on Windows.
//go:build windows
// Used in https://github.com/SCP002/terminator.
// For POSIX, see: https://gist.github.com/SCP002/c7c3bf4aafd3e32e0dc0aa65dda2bf14.
package main
import (
"errors"
"os"
@SCP002
SCP002 / send_wm_close_windows.go
Last active January 11, 2025 09:20
Golang: Close main window of the process with the specified PID for graceful termination of processes on Windows.
//go:build windows
// Used in https://github.com/SCP002/terminator.
package main
import (
"fmt"
"unsafe"
@SCP002
SCP002 / configure-ps1-context-menu.reg
Last active October 19, 2024 08:53
Windows Registry: Run .ps1 scripts with double click using pwsh (PowerShell 7). Including tweaks of context menu. See coments for description.
Windows Registry Editor Version 5.00
; WARNING:
; Uses "%ProgramFiles%\PowerShell\7\pwsh.exe" as powershell path.
; You might want to change it to your own with default file path, like:
;
; @="\"C:\\ProgramFiles\\Powershell\\8\\pwsh.exe\" \"%1\""
;