Skip to content

Instantly share code, notes, and snippets.

View stibi's full-sized avatar

Martin Stiborský stibi

  • Ostrava, Czech Republic
  • X @stibi
View GitHub Profile
@stibi
stibi / slack_lambda.py
Created September 1, 2020 19:18
barebone code for posting slack messages with AWS Lambda
#!/usr/bin/env python3.7
import os
import json
import logging
from botocore.vendored import requests
import ec2
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@stibi
stibi / gist:20b0a5d496bdbd5073dde50662fa9b25
Created December 28, 2018 10:45
Open VPN connection, read oauth token from yubikey
#!/usr/bin/expect
set username "mstiborsky\r"
set config "/etc/openvpn/client/zonky.conf"
set vpn_oauth_token [exec ykman oath code -s vpn]
spawn openvpn --config $config --auth-user-pass
expect "Enter Auth Username:"
send $username
expect "Enter Auth Password:"
@stibi
stibi / cmd.md
Last active January 13, 2019 21:08

Find biggest dirs on ...

du -Sh | sort -rh | head -5

Number sequence loop

for i in $(seq 1 $END); do echo $i; done
@stibi
stibi / lvm.md
Last active December 28, 2018 11:01

LVM

Volné místo

pvs nebo vgs ukáže, jestli na physical volume nebo volume grupě je nějaké volné místo

Zvětšit logical volume

Mám srv_data_postgresql logical volume a chci mu přidat 50G.

@stibi
stibi / test.tf
Last active September 14, 2018 12:30
I'm testing something…
module "test-sg" {
source = "../../modules/terraform-aws-security-group"
name = "${var.name}-test"
vpc_id = "${module.vpc.vpc_id}"
ingress_with_cidr_blocks = [
{
rule = "ssh-tcp"
description = "test01"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#/bin/bash
set -euo pipefail
instance_profile=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/)
aws_access_key_id=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep AccessKeyId | cut -d':' -f2 | sed 's/[^0-9A-Z]*//g')
aws_secret_access_key=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | grep SecretAccessKey | cut -d':' -f2 | sed 's/[^0-9A-Za-z/+=]*//g')
token=$(curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/${instance_profile} | sed -n '/Token/{p;}' | cut -f4 -d'"')
export AWS_ACCESS_KEY_ID=${aws_access_key_id}
spec:
template:
spec:
containers:
volumeMounts:
- mountPath: /var/www/html
name: www
spec:
template:
@stibi
stibi / gist:3297c4ad3f773b63690490a7d6b76ec6
Created August 15, 2017 08:32
List pods not in "Running" state
kubectl get pod -o jsonpath='{.items[?(@.status.phase!="Running")].metadata.name}'
Archive: staging-deploy-lambda-0c0442e9.zip
Length Date Time Name
--------- ---------- ----- ----
112 2017-08-03 18:07 Makefile
0 2017-08-03 18:07 requests/
453 2017-08-03 18:07 requests/certs.py
18208 2017-08-03 18:07 requests/cookies.py
542 2017-08-03 18:07 requests/packages.py
3323 2017-08-03 18:07 requests/status_codes.py
20836 2017-08-03 18:07 requests/adapters.py