Skip to content

Instantly share code, notes, and snippets.

@gene1wood
gene1wood / get_policy_documents_for_role.py
Created July 24, 2019 14:53
Function to return all AWS IAM policy documents (inline and managed) for a given IAM role
import boto3
def get_paginated_results(product, action, key, credentials=None, args=None):
args = {} if args is None else args
credentials = {} if credentials is None else credentials
return [y for sublist in [x[key] for x in boto3.client(
product, **credentials).get_paginator(action).paginate(**args)]
for y in sublist]
@lizthegrey
lizthegrey / attributes.rb
Last active February 24, 2024 14:11
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'
@holly
holly / smaps.py
Created February 11, 2019 15:36
read /proc/$pid/smaps
#!/usr/bin/env python
import sys
def read_smaps(pidlist):
try:
print("PID\tRSS\tSHARED\t\tNONE_SHARED")
mem = lambda t, f: int(f[1]) if f[0] == '%s:' % t else 0.0
for pid in pidlist:
filename = "/proc/%s/smaps" % pid
@i64
i64 / androidManifestDecompress.py
Last active January 10, 2024 18:10
decompress androidmanifest file in python
class AndroidXMLDecompress():
endDocTag = 0x00100101
startTag = 0x00100102
endTag = 0x00100103
def decompressXML(self, xml: bytearray) -> str:
finalXml = str()
numbStrings = self.LEW(xml, 4*4)
@glasslion
glasslion / vtt2text.py
Last active May 31, 2024 18:51
This script convert youtube subtitle file(vtt) to plain text.
"""
Convert YouTube subtitles(vtt) to human readable text.
Download only subtitles from YouTube with youtube-dl:
youtube-dl --skip-download --convert-subs vtt <video_url>
Note that default subtitle format provided by YouTube is ass, which is hard
to process with simple regex. Luckily youtube-dl can convert ass to vtt, which
is easier to process.
@bradwilson
bradwilson / .gitconfig
Last active January 22, 2023 21:51
~/.config/git/config
[user]
name = Brad Wilson
email = dotnetguy@gmail.com
signingkey = 0B7BD15AD1EC5FDE
[alias]
a = add -A
abort = rebase --abort
amend = commit --amend -C HEAD
bclean = "!f() { git switch ${1-main} && git branch --merged ${1-main} | grep -v ${1-main}$ | xargs git branch -d; }; f"
bdone = "!f() { git switch ${1-main} && git up && git bclean ${1-main}; }; f"
@LenarBad
LenarBad / Choose Source for Default Value.groovy
Last active May 18, 2018 14:15
Jenkins dynamic Extended Choice Parameter with service call (Groovy Script)
// host will be passed in the groovy bindings for extended choice plugin.
def getVersion = { host, path ->
try {
def version = new groovy.json.JsonSlurper().parse(new URL("https://${host}${path}")).version
return version
} catch(Exception e) {
return null
}
}
@ekreutz
ekreutz / ansible_variable_precedence.md
Last active April 25, 2024 17:43
Ansible variable precedence (order, hierarchy)
@ohad7
ohad7 / tracker-reshape.py
Last active July 29, 2023 21:48
Convert Keras h5 model to CoreML (reshape input layer)
from keras.models import load_model
from keras.layers import Input, Dense
from tensorflow import Tensor
from keras import backend as K
from keras.engine import InputLayer
model = load_model('MyModel.h5')
for layer in model.layers:
print layer
@gaieges
gaieges / kubernetes-the-hard-way.md
Last active August 12, 2023 12:58
Kubernetes the hardway, concatenated for reading on offline ipad. Copyright kelseyhightower: https://github.com/kelseyhightower/kubernetes-the-hard-way

Kubernetes the hard way © Kelsey Hightower

Prerequisites

Google Cloud Platform

This tutorial leverages the Google Cloud Platform to streamline provisioning of the compute infrastructure required to bootstrap a Kubernetes cluster from the ground up. Sign up for $300 in free credits.

Estimated cost to run this tutorial: $0.22 per hour ($5.39 per day).