Skip to content

Instantly share code, notes, and snippets.

@hexagr
hexagr / toast-start-lnk.ps
Created May 29, 2025 18:12
Toast Notifications on Windows 11
$ShortcutPath = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\MyToastApp.lnk"
$TargetPath = "C:\Path\To\YourApp.exe"
$AppUserModelID = "Your.App.ID"
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
[ComImport]
@hexagr
hexagr / elfCheck.asm
Created February 20, 2025 08:34
Searching for ELF magic with assembly
section .data
elf_magic db 0x7F, 'E', 'L', 'F' ; ELF magic number
msg db "[+] ELF magic detected", 10 ; msg to print
msg_len equ $ - msg
usage_msg db "Usage: ./elf_check <filename>", 10
usage_msg_len equ $ - usage_msg
error_msg db "Error opening file. Please supply a valid file path.", 10
error_msg_len equ $ - error_msg
not_elf db "[-] No ELF magic detected", 10
not_elf_len equ $ - not_elf
@hexagr
hexagr / link.sh
Created February 16, 2025 17:07
Distributed backup using rsync
@hexagr
hexagr / preserveCode.js
Created December 30, 2024 23:20
console hack to preserve code formatting when using chrome's translate functionality
// browser console hack to prevent chrome from mucking with code blocks when a page is translated
// e.g. translating a chinese web page to english
document.querySelectorAll('pre, code').forEach(block => {
block.style.whiteSpace = 'pre-wrap';
block.setAttribute('translate', 'no');
});
@hexagr
hexagr / reading2.js
Created October 21, 2024 02:12
reading2.js
document.querySelectorAll('p').forEach(p => {
p.style.textAlign = 'justify';
p.style.padding = '10px';
});
@hexagr
hexagr / reading1.js
Created October 21, 2024 02:12
reading1.js
document.querySelectorAll('p').forEach(p => p.style.textAlign = 'justify');
@hexagr
hexagr / humanReadable.sh
Created October 8, 2024 13:18
humanReadableBytes
cat fd.txt | awk '/bytes each:/ {
if (line) {
split(line, sizes, " ")
size_in_bytes = sizes[1]
print size_in_bytes "\t" line
}
line = $0;
next
}
{ line = line " " $0 }
// js console to dump urls to json
const links = document.querySelectorAll('a');
const matchingUrls = [];
links.forEach(link => {
const url = link.href;
if (url.match(/https:\/\/example\.com\/(path1|path2)\/.*/)) {
matchingUrls.push(url);
}
# I will not write piracy software, I will not write piracy software, I will not write
for file in *.mp3; do tracknum="${file%% *}"; trackname="${file#* }"; trackname="${trackname%.mp3}"; id3v2 -T "$tracknum" -t "$trackname" "$file"; done
@hexagr
hexagr / reflect.go
Created May 26, 2024 10:24
golang reflection
typ := reflect.TypeOf(function.Here{})
for i := 0; i < typ.NumField(); i++ {
field := typ.Field(i)
fmt.Printf("Field: %s, Type: %s\n", field.Name, field.Type)
}
for i := 0; i < typ.NumMethod(); i++ {
method := typ.Method(i)
fmt.Printf("Method: %s\n", method.Name)