Skip to content

Instantly share code, notes, and snippets.

Avatar
🏁

Mattias Appelgren Mattias-

🏁
View GitHub Profile
@Mattias-
Mattias- / 1_simple.go
Created Feb 24, 2022 — forked from sosedoff/1_simple.go
Golang Custom Struct Tags Example
View 1_simple.go
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"
View aws-unsubscribe-email.sh
#!/bin/bash
# This is a script that unsubscribes an email address from AWS junk mail.
# If the script breaks it might be the magic numbers that needs to change.
# Send the form while tracing the request in your browser to find the new values.
# https://pages.awscloud.com/communication-preferences
unsubscribe_aws_email() {
curl "https://pages.awscloud.com/index.php/leadCapture/save2" \
-H "Accept: application/json" \
@Mattias-
Mattias- / crash.log
Created Aug 13, 2020
tf-vault-crash-1
View crash.log
panic: runtime error: invalid memory address or nil pointer dereference
2020-08-13T08:39:11.963Z [DEBUG] plugin.terraform-provider-vault_v2.11.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x1024770]
2020-08-13T08:39:11.963Z [DEBUG] plugin.terraform-provider-vault_v2.11.0_x4:
2020-08-13T08:39:11.963Z [DEBUG] plugin.terraform-provider-vault_v2.11.0_x4: goroutine 41 [running]:
2020-08-13T08:39:11.963Z [DEBUG] plugin.terraform-provider-vault_v2.11.0_x4: github.com/terraform-providers/terraform-provider-vault/vault.identityEntityCreate(0xc000262460, 0x13a1ac0, 0xc0001443f0, 0x2, 0x1fe4640)
2020-08-13T08:39:11.963Z [DEBUG] plugin.terraform-provider-vault_v2.11.0_x4: /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-vault/vault/resource_identity_entity.go:110 +0x2e0
2020-08-13T08:39:11.963Z [DEBUG] plugin.terraform-provider-vault_v2.11.0_x4: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc000132f00, 0xc000098c80, 0xc
View es_index_to_file.sh
#!/bin/bash
es_url="localhost:9200"
index="logstash-123"
response=$(curl -s -H 'Content-Type: application/json' "$es_url/$index/_search?scroll=5m&size=10000")
scroll_id=$(jq -r '._scroll_id' <<<"$response")
hits_count=$(jq -r '.hits.hits | length' <<<"$response")
hits_so_far=hits_count
echo "Got initial response with $hits_count hits and scroll ID $scroll_id"
View create_reproducable_repo.sh
#!/bin/bash
set -eu
git init "$1"
export GIT_AUTHOR_DATE='2000-01-01 00:00:00 +0000'
export GIT_AUTHOR_NAME='a'
export GIT_AUTHOR_EMAIL='a'
export GIT_COMMITTER_DATE="${GIT_AUTHOR_DATE}"
export GIT_COMMITTER_NAME="${GIT_AUTHOR_NAME}"
export GIT_COMMITTER_EMAIL="${GIT_AUTHOR_EMAIL}"
git -C "$1" commit --allow-empty -m "Initial commit" -m "Randomly constructed message:
View cloud_aws_ebs_nvme_id
#!/usr/bin/env bash
# Copyright (c) 2018 The CoreOS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
usage() {
echo "Usage: $0 [-d|-n|-h] <device>" 1>&2
}
View ubuntu_docker.sh
#!/bin/bash
set -e
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update -y
apt-get upgrade -y
apt-get install -y \
apt-transport-https \
ca-certificates \
View msort
def test(fun):
lists = [
[],
[0],
[1],
[-1],
[3, 3],
[1, 2],
View resize vm
cd ~/VirtualBox\ VMs/vm_name
VBoxManage clonehd box-disk1.vmdk tmp-disk.vdi --format vdi
VBoxManage modifyhd tmp-disk.vdi --resize 61440
VBoxManage clonehd tmp-disk.vdi resized-disk.vmdk --format vmdk
rm tmp-disk.vdi box-disk1.vmdk
mv resized-disk.vmdk box-disk1.vmdk
View parallel_processes.py
#!/usr/bin/env python
from __future__ import print_function
import collections
import subprocess
import time
ProcTuple = collections.namedtuple('ProcTuple', ['process', 'command',
'start_time'])