This file contains hidden or 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
# generate package import graph of golang module with python graphviz. | |
# script should be run in the directory where main.go is located. | |
import os | |
import graphviz | |
import subprocess | |
import json | |
import time | |
describe_tag = subprocess.check_output(["git", "describe", "--tags"]).decode("utf-8").strip() |
This file contains hidden or 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
// This script calculates the average cpu usage percent of the last second (of a given pid, in this case the script itself). | |
// (*process.Process).CPUPercent() from "github.com/shirou/gopsutil/process" returns the average cpu usage percent since the process was started. | |
// If you call cpuPercent(p) every 10 seconds then the average cpu usage percent of the last 10 seconds is returned. | |
// | |
// cpuPercent first call returns the average cpu percent usage since the start of the process. | |
// | |
// Remember that if the process you are analyzing changes pid you have to update `pTracker` with the new pid (+new info) and remove the old pid. | |
// (not the case for this example though) | |
package main |
This file contains hidden or 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
// This is a script to suspend the child processes in a process tree | |
// Tn this example a minecraft process is used as example | |
// (windows specific) | |
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os/exec" |
This file contains hidden or 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
// This is a script to retrieve the child processes pids of a process (retrieve the complete process tree) | |
// Tn this example the process identified by pid 7400 is used | |
// (please to run the test chose a process pid that has at least 1 child process) | |
// (tested on windows) | |
package main | |
import ( | |
"fmt" | |
"syscall" |
This file contains hidden or 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
// this script can be use to execute entire functions with a locked mutex. | |
// It is especially useful when a if statement needs to read from a mutex sensible variable. | |
// withLock accepts either a "func()" or a "func() interface{}" | |
// in the first case, it executes the function returining <nil> | |
// in the second case, it returns the value of the function as an interface{} | |
package main | |
import ( |