This file contains 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
# removes direnv allow entries which point to nonexistent .envrc files | |
# or where the hash of the envrc does not match | |
direnv_prune () { | |
for entry in ~/.local/share/direnv/allow/* | |
do | |
local file=$(cat $entry) | |
if [ ! -f $file ] | |
then | |
rm $entry | |
else |
This file contains 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
#!/bin/bash | |
# Usage: gpg-gen.sh | |
# | |
# Generates a new ECC GPG Key with a random passphrase | |
# It will output the resulting keys to ~/gpg-keys/ | |
# You should save these somewhere safe like 1Password | |
set -euo pipefail | |
PRIMARY_KEY_EXPIRATION=3y |
This file contains 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
# Based off https://gist.github.com/jessfraz/7c319b046daa101a4aaef937a20ff41f | |
$gistContent = "https://gist.githubusercontent.com/justenwalker/25211c0fa10ddd705a3f6077e2b7694c" | |
#--- Function Library ---# | |
# New-RegistryKey creates the specified registry key if it does not exist | |
# It will recursively create any parent keys | |
function New-RegistryKey | |
{ |
This file contains 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
rows := make([]_MIB_TCPROW_OWNER_PID,int(pTable.dwNumEntries)) | |
for i := 0; i < int(pTable.dwNumEntries); i++ { | |
rows[i] = *(*_MIB_TCPROW_OWNER_PID)(unsafe.Pointer( | |
uintptr(unsafe.Pointer(&pTable.table[0])) + | |
uintptr(i) * unsafe.Sizeof(pTable.table[0]) | |
)) | |
} |
This file contains 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
package win32 | |
import ( | |
"syscall" | |
"unsafe" | |
) | |
var ( | |
iphlpapiDLL = syscall.NewLazyDLL("iphlpapi.dll") | |
procGetExtendedTcpTable = iphlpapiDLL.NewProc("GetExtendedTcpTable") |
This file contains 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
package win32 | |
import "unicode/utf16" | |
// StringToCharPtr converts a Go string into pointer to a null-terminated cstring. | |
// This assumes the go string is already ANSI encoded. | |
func StringToCharPtr(str string) *uint8 { | |
chars := append([]byte(str), 0) // null terminated | |
return &chars[0] | |
} |
This file contains 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
package win32 | |
import "syscall" | |
import "unsafe" | |
var ( | |
kernel32DLL = syscall.NewLazyDLL("kernel32.dll") | |
procCreateJobObjectA = kernel32DLL.NewProc("CreateJobObjectA") | |
) |
This file contains 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
# Ask for a port on which Damon can serve Prometheus metrics | |
network { | |
port "damon" {} | |
} | |
# Advertise damon as a service | |
service { | |
port = "damon" | |
name = "${NOMAD_TASK_NAME}-damon" | |
} |
This file contains 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
driver = "raw_exec" | |
config { | |
command = "damon.exe" # Damon is the new task entry-point (it should be on the PATH) | |
args = ["my.exe","arg1","arg2"] # Your command + Args here | |
} |
This file contains 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
#!powershell | |
$env:DAMON_CPU_LIMIT="2048" # MHz | |
$env:DAMON_MEMORY_LIMIT="2048" # MB | |
# Run my.exe inside a job object | |
& damon.exe my.exe |
NewerOlder