Skip to content

Instantly share code, notes, and snippets.

🚀

Dan dantheman213

🚀
Block or report user

Report or block dantheman213

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View windows10-hyperv.txt
# hyper-v on/off in windows 10
bcdedit /set hypervisorlaunchtype off
bcdedit /set hypervisorlaunchtype on
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
View GetCommandResult.go
// https://www.reddit.com/r/golang/comments/1hvvnn/any_better_way_to_do_a_crossplatform_exec_and/
func GetCommandResult(cmd *exec.Cmd) ([]byte, int, error) {
output, err := cmd.CombinedOutput()
if err != nil {
if e2, ok := err.(*exec.ExitError); ok {
if status, ok := e2.Sys().(syscall.WaitStatus); ok && runtime.GOOS == "windows" {
s := reflect.ValueOf(&status).Elem()
for i := 0; i < s.NumField(); i++ {
if s.Type().Field(i).Name == "ExitCode" {
View gist:13156335386f04b9f2866257e10aac3c
# Get all log groups
aws2 logs describe-log-groups --page-size 50 --max-items 1000 --profile preprod | jq -r '.logGroups[].logGroupName'
# ---
# Query every log group in the last 30 mins
aws2 logs describe-log-groups --page-size 50 --max-items 1000 --profile preprod | jq -r '.logGroups[].logGroupName' | while read line; do echo $line; aws2 logs start-query --profile preprod --log-group-name $line --query-string 'filter @message like /(?i)(mongoerror|staging1)/| fields @timestamp, @message | sort @timestamp desc' --start-time $(expr 1578699670 - 1800) --end-time 1578699670 | jq -r '.queryId' >> queryIds.txt; echo $line >> link.txt; tail -1 queryIds.txt >> link.txt; done
# Get results from every query ID generated in previous command
cat queryIds.txt | while read line; do echo $line; echo $line >> results.txt ; aws2 logs get-query-results --profile preprod --query-id $line >> results.txt; done
View golang_binary_tree.go
package main
import "fmt"
func main() {
fmt.Println("Welcome to B-Tree test")
btree := makeBTree()
fmt.Println("In-order b-tree traversal")
traverse(&btree)
fmt.Println("Exit B-Tree test")
@dantheman213
dantheman213 / aws-ssm
Last active Jan 10, 2020
Find list of SSM params with a keyword or phrase
View aws-ssm
# Get all SSM keys and values as JSON object per SSM key:
aws ssm describe-parameters --profile ${TARGET_ENV} | jq '{NextToken,Parameters:[ .Parameters | map(.Name) [] ] }' | jq -r '.Parameters | join("\n")' | while read line; do aws ssm get-parameter --name $line --profile ${TARGET_ENV} | jq -c '{Name: .Parameter.Name, Value: .Parameter.Value}'; done
# Get Keys by themselves per line raw
aws ssm describe-parameters | jq '{NextToken,Parameters:[ .Parameters | map(.Name) [] ] }' | jq -r '.Parameters | join("\n")'
# Do something in a bash for loop
aws ssm describe-parameters --profile preprod | jq '{NextToken,Parameters:[ .Parameters | map(.Name) [] ] }' | jq -r '.Parameters | join("\n")' | while read line; do aws ssm get-parameter --profile preprod --name $line; done
@dantheman213
dantheman213 / aws-ssm-find-param
Last active Aug 19, 2019
Quickly find AWS SSM params by partial search, use custom AWS profiles, get an interactive result to query, and get a AWS URL to view and edit target
View aws-ssm-find-param
#!/usr/bin/env node
//
// Quickly find AWS SSM params by partial search, use custom AWS profiles, get an interactive
// result to query, and get a AWS URL to view and edit target.
//
// Requires AWS CLI, NodeJS v10+ and Python 2/3
//
// Before running for first time do:
// npm install inquirer
@dantheman213
dantheman213 / reset.sh
Last active May 22, 2019
Reset home permissions
View reset.sh
chmod -v 700 ~/
chmod -v 700 ~/.ssh
chmod -Rv 600 ~/.ssh/*
chmod -v 644 ~/.ssh/authorized_keys
chmod -v 644 ~/.ssh/*.pub
View uninstall_docker.md

To completely uninstall Docker:

Step 1

dpkg -l | grep -i docker To identify what installed package you have:

Step 2

sudo apt-get purge -y docker-engine docker docker.io docker-ce

@dantheman213
dantheman213 / generate-ssh-key.sh
Created Apr 18, 2019 — forked from grenade/generate-ssh-key.sh
Correct file permissions for ssh keys and config.
View generate-ssh-key.sh
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa
@dantheman213
dantheman213 / Dockerfile
Last active Sep 28, 2018
Go Dockerfile Example
View Dockerfile
# Dockerfile for basic Go application example
#
# Assumptions
# - There is a project dir
# - Inside the project dir, there is the path src/main
# - The project's *.go files are located in src/main
# - The project's name is "myapp"
FROM golang:1.11.0-stretch AS packager
You can’t perform that action at this time.