Skip to content

Instantly share code, notes, and snippets.

View Mattias-'s full-sized avatar

Mattias Appelgren Mattias-

View GitHub Profile
@Mattias-
Mattias- / 1_simple.go
Created February 24, 2022 20:48 — forked from sosedoff/1_simple.go
Golang Custom Struct Tags Example
package main
import (
"fmt"
"reflect"
)
// Name of the struct tag used in examples
const tagName = "validate"
#!/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 August 13, 2020 08:59
tf-vault-crash-1
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
#!/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"
@Mattias-
Mattias- / create_reproducable_repo.sh
Created October 5, 2019 14:04
Reproducable repo
#!/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:
#!/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
}
#!/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 \
def test(fun):
lists = [
[],
[0],
[1],
[-1],
[3, 3],
[1, 2],
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
#!/usr/bin/env python
from __future__ import print_function
import collections
import subprocess
import time
ProcTuple = collections.namedtuple('ProcTuple', ['process', 'command',
'start_time'])