Skip to content

Instantly share code, notes, and snippets.


Justen Walker justenwalker

View GitHub Profile
justenwalker /
Created Aug 30, 2014
Ansible Dynamic Inventory script for etcd

etcd dynamic inventory script

Generarates inventory for ansible from etcd using python-etcd library.

The script assumes etcd.ini to be present alongside it. To choose a different path, set the ETCD_INI_PATH environment variable:

export ETCD_INI_PATH=/path/to/etcd.ini
justenwalker /
Created Jan 9, 2014
Cassandra unsafe assassinate - removing a dead node from the cluster

Unsafe Node Assassinate

On Cassandra 1.1.x, nodetool removetoken on a dead node hangs. The only way to reliably remove the node from the cluster is to use an undocumented JMX command to force the remove of the node from gossip.

Upgrading to 1.2.x and above should obviate these steps in favor of nodetool removenode - See 1.2 Docs

It's probably also a good idea to run a nodetool repair after this operation - See wiki


justenwalker / string_convert_windows.go
Last active Jul 31, 2020
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]
View boxstarter.ps1
# Based off
$gistContent = ""
#--- Function Library ---#
# New-RegistryKey creates the specified registry key if it does not exist
# It will recursively create any parent keys
function New-RegistryKey
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 / 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 (
var (
iphlpapiDLL = syscall.NewLazyDLL("iphlpapi.dll")
procGetExtendedTcpTable = iphlpapiDLL.NewProc("GetExtendedTcpTable")
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 / 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"
View damon-example.ps1
$env:DAMON_CPU_LIMIT="2048" # MHz
# Run my.exe inside a job object
& damon.exe my.exe
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