Skip to content

Instantly share code, notes, and snippets.

View technoscavenger's full-sized avatar

technoscavenger

  • Austin, TX
View GitHub Profile
@technoscavenger
technoscavenger / GetIpSubnetGatewayDns.ps1
Created May 15, 2024 02:56
Get IP address, subnet, gateway and DNS server using PowerShell
# Get all network adapters that are configured to use IP
$adapters = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled = True"
# Display the IP address, subnet mask, default gateway, and DNS servers for each adapter
foreach ($adapter in $adapters) {
Write-Host "Description: $($adapter.Description)"
Write-Host "IP Address(es): $($adapter.IPAddress)"
Write-Host "Subnet Mask(s): $($adapter.IPSubnet)"
Write-Host "Default Gateway(s): $($adapter.DefaultIPGateway)"
Write-Host "DNS Server(s): $($adapter.DNSServerSearchOrder)"
@technoscavenger
technoscavenger / ReadConsoleInputW.zig
Created May 14, 2024 04:31
Calling ReadConsoleInputW in Zig
const std = @import("std");
const c = @cImport({
@cInclude("windows.h");
});
const KEY_EVENT = 0x0001;
pub fn main() !void {
_ = std.os.windows.kernel32.SetConsoleOutputCP(65001);
const stdin = c.GetStdHandle(c.STD_INPUT_HANDLE);
@technoscavenger
technoscavenger / messageboxw.zig
Created May 3, 2024 02:54
MessageBoxW in Zig
const std = @import("std");
const c = @cImport({
@cInclude("windows.h");
});
pub fn main() !void {
const message = "Hello, World!";
const title = "Zig MessageBox";
// Buffer for UTF-16 strings
@technoscavenger
technoscavenger / messagebox.zig
Created May 2, 2024 01:52
Zig Windows MessageBox
const win = @import("std").os.windows;
extern "user32" fn MessageBoxA(?win.HWND, [*:0]const u8, [*:0]const u8, u32) callconv(win.WINAPI) i32;
pub fn main() !void {
_ = MessageBoxA(null, "world!", "Hello", 0);
}
use windows::{core::Result, Win32::System::Threading::*};
static COUNTER: std::sync::RwLock<i32> = std::sync::RwLock::new(0);
fn main() -> Result<()>{
unsafe {
let work = CreateThreadpoolWork(Some(callback), None, None)?;
for _ in 0..10 {
SubmitThreadpoolWork(work);
[package]
name = "thread_pool_work"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies.windows]
version = "0.52"
features = [
@technoscavenger
technoscavenger / ReadXml.ps1
Last active January 2, 2024 04:33
Read XML configuration
$xmlFile = "C:\Users\u1\Documents\sample_nodes.xml"
$xmlDoc = [xml](Get-Content $xmlFile)
$xmlDoc.nodes.node.ip
@technoscavenger
technoscavenger / sample_nodes.xml
Created January 2, 2024 04:29
Sample XML data set
<?xml version="1.0"?>
<nodes>
<node>
<name>machine1</name>
<ip>1.2.3.4</ip>
</node>
</nodes>
@technoscavenger
technoscavenger / Project4.dpr
Created December 29, 2023 07:39
Delphi: Waiting for ESCAPE key before continuing
program Project4;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Winapi.Windows;
@technoscavenger
technoscavenger / Project1.dpr
Last active December 29, 2023 07:28
Initialize COM Delphi console application
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
ActiveX,
ComObj,
System.SysUtils,