Skip to content

Instantly share code, notes, and snippets.

Justen Walker justenwalker

View GitHub Profile
@justenwalker
justenwalker / boxstarter.ps1
Last active Mar 18, 2019
Boxstarter Script
View boxstarter.ps1
# Based off https://gist.github.com/jessfraz/7c319b046daa101a4aaef937a20ff41f
# Temporary
Disable-UAC
#--- Windows Settings ---
Disable-BingSearch
Disable-GameBarTips
Set-TaskbarOptions -Size Small -Lock -Dock Bottom -Combine Always
Set-TaskbarOptions -AlwaysShowIconsOff
@justenwalker
justenwalker / raw_tcp_table_iterate_windows.go
Last active Jan 10, 2019
Iterate through each array entry using unsafe.Pointer arithmetic
View raw_tcp_table_iterate_windows.go
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])
))
}
@justenwalker
justenwalker / get_extended_tcp_table_windows.go
Last active Jan 10, 2019
Call Windows API for GetExtendedTcpTable and return a Byte Buffer containing the result.
View get_extended_tcp_table_windows.go
package win32
import (
"syscall"
"unsafe"
)
var (
iphlpapiDLL = syscall.NewLazyDLL("iphlpapi.dll")
procGetExtendedTcpTable = iphlpapiDLL.NewProc("GetExtendedTcpTable")
@justenwalker
justenwalker / string_convert_windows.go
Last active Jan 10, 2019
Convert Go strings to C-compatible strings for Windows API Calls
View string_convert_windows.go
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]
}
@justenwalker
justenwalker / call-windows.go
Last active Jan 10, 2019
Calling Windows API from Go
View call-windows.go
package win32
import "syscall"
import "unsafe"
var (
kernel32DLL = syscall.NewLazyDLL("kernel32.dll")
procCreateJobObjectA = kernel32DLL.NewProc("CreateJobObjectA")
)
@justenwalker
justenwalker / damon-metrics-config-example.hcl
Last active Nov 8, 2018
Damon prometheus metrics example
View damon-metrics-config-example.hcl
# 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"
}
@justenwalker
justenwalker / damon-example-snip.hcl
Created Nov 8, 2018
Damon example raw_exec config section
View damon-example-snip.hcl
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
}
View damon-example.ps1
#!powershell
$env:DAMON_CPU_LIMIT="2048" # MHz
$env:DAMON_MEMORY_LIMIT="2048" # MB
# Run my.exe inside a job object
& damon.exe my.exe
View keybase.md

Keybase proof

I hereby claim:

  • I am justenwalker on github.
  • I am justenwalker (https://keybase.io/justenwalker) on keybase.
  • I have a public key whose fingerprint is DF04 3245 AE35 DBE3 0890 1D49 6AA4 DD62 7E5E 24EE

To claim this, I am signing this object:

@justenwalker
justenwalker / docker
Created Nov 12, 2014
boot2docker shim
View docker
#! /bin/bash
if [ "running" = `boot2docker status` ]; then
IP=`boot2docker ip 2>/dev/null`
export DOCKER_CERT_PATH="$HOME/.boot2docker/certs/boot2docker-vm"
export DOCKER_TLS_VERIFY=1
export DOCKER_HOST="tcp://$IP:2376"
/usr/local/bin/docker "$@"
else
echo "boot2docker is not running"
You can’t perform that action at this time.