Skip to content

Instantly share code, notes, and snippets.

View Efrat19's full-sized avatar
🐤
Poking around

Efrat Levitan Efrat19

🐤
Poking around
View GitHub Profile
for rsc in $(kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -oname); do
echo $rsc
dir=$(echo $rsc | cut -d'/' -f1)
file=$(echo $rsc | cut -d'/' -f2)
mkdir genereted/$dir
kubectl get $rsc -oyaml > genereted/$dir/$file.yaml
done;
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<link rel="stylesheet" type="text/css"
href="https://demos.aarafacademy.com/fireworks-using-javascript/css/fireworks.css" media="screen" />
<script type="text/javascript"
src="https://demos.aarafacademy.com/fireworks-using-javascript/js/soundmanager2-nodebug-jsmin.js"></script>
<script type="text/javascript" src="https://demos.aarafacademy.com/fireworks-using-javascript/js/fireworks.js"></script>
<div id="fireworks-template">
<div id="fw" class="firework"></div>
@Efrat19
Efrat19 / cp-parameter-group.py
Last active November 23, 2020 07:11 — forked from phill-tornroth/cp-parameter-group.py
Copies an rds parameter group with support for cross-region copying. Quick bashed out script because AWS cli doesn't support.
"""
Copies a parameter group in RDS, particularly useful for doing cross-region copies (which AWS documents,
but doesn't actually support at the time of this writing.
Usage: python cp-parameter-group.py us-west-1:lookerdb-56 us-west-2:lookerdb-56
"""
import boto3
import sys
# memcached default config file
# 2003 - Jay Bonci <jaybonci@debian.org>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.
# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
-d
@Efrat19
Efrat19 / count-interfaces.sh
Last active April 6, 2020 23:29
count-interfaces
declare -a subnets=("subnet-0a5eeeb0cd492af31" "subnet-081a9964b79df659d" "subnet-0a223bb7af793f998")
for subnet in ${subnets[@]}; do
echo "$(aws ec2 describe-network-interfaces --filters "Name=subnet-id,Values=$subnet" --query 'NetworkInterfaces[*].PrivateIpAddress' --output text | wc -w) interfaces are taken at $subnet"
# echo "$(aws ec2 describe-instances --filters "Name=subnet-id,Values=$subnet" --query 'Reservations[*].Instances[*].PrivateIpAddress' --output text | wc -w) ips are taken at $subnet"
done;
@Efrat19
Efrat19 / eks-iam.sh
Created February 27, 2020 22:08
blog snippets
export CLUSTER="$(kubectl config view -ojson | jq -r --arg CTX $(kubectl config current-context) '.contexts | .[] | select(.name == $CTX) | .context.cluster | split("/") | .[length-1]')"
export REGION=$(aws configure get region)
export OIDC=$(aws eks describe-cluster --name ${CLUSTER} --query cluster.identity.oidc | jq -r '.issuer | split("/") | .[length-1]')
export ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
echo "cluster $CLUSTER in region $REGION and account number ${ACCOUNT} has OIDC token: ${OIDC}"
SELECT table_schema AS "Database name", SUM(data_length + index_length) / 1024 / 1024 / 1024 AS "Size (GB)" FROM information_schema.TABLES GROUP BY table_schema;
#!/bin/bash
KEY=dr.newadmin
VALUE=a88dd1213cf1811e9803406c5e12f321-536496363.eu-west-1.elb.amazonaws.com
HOSTED_ZONE_ID=Z2JG04O2LDY5NZ
# Creates route 53 records based on KEY name
aws route53 change-resource-record-sets --hosted-zone-id $HOSTED_ZONE_ID --change-batch '{ "Comment": "Testing creating a record set", "Changes": [ { "Action": "CREATE", "ResourceRecordSet": { "Name": "'"$KEY"'.hosted.zone.com", "Type": "CNAME", "TTL": 120, "ResourceRecords": [ { "Value": "'"$VALUE"'" } ] } } ] }'
@Efrat19
Efrat19 / deletebranch.sh
Last active January 29, 2020 10:15
delete git branches
git branch -r > branch.txt
# delete master branch and "/origin" from branch.txt, and then:
for i in $(cat branch.txt); do sleep 1 && git push origin --delete $i & done
@Efrat19
Efrat19 / get-public-ip
Created December 25, 2019 12:08
get public ip
curl -s http://checkip.dyndns.org/ | cut -d ' ' -f 6 | sed s/"body\|html\|<\|>\|\/"//g