Skip to content

Instantly share code, notes, and snippets.

@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'
@ibraheem4
ibraheem4 / postgres-brew.md
Last active May 30, 2024 04:53 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@mgoellnitz
mgoellnitz / bucketsnip.sh
Last active January 23, 2023 15:02
Bitbucket Snippet Command Line Tool
#!/bin/bash
#
# Copyright 2017-2021 Martin Goellnitz
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@Breta01
Breta01 / Multiple TF Graph Class.py
Last active July 20, 2020 09:19
Class for importing multiple TensorFlow graphs.
import tensorflow as tf
class ImportGraph():
""" Importing and running isolated TF graph """
def __init__(self, loc):
# Create local graph and use it in the session
self.graph = tf.Graph()
self.sess = tf.Session(graph=self.graph)
with self.graph.as_default():
# Import saved model from location 'loc' into local graph
@michaelconnor00
michaelconnor00 / put_archive.py
Last active October 22, 2022 21:42 — forked from zbyte64/sample.py
Docker Python put_archive example
import tarfile
import time
import json
from io import BytesIO
import docker
src_code = """
if __name__ == "__main__":
print('Hello World, From Alpine!!!!!!!!!')
"""
@BretFisher
BretFisher / docker-for-mac.md
Last active May 23, 2024 22:25
Getting a Shell in the Docker Desktop Mac VM

2021 Update: Easiest option is Justin's repo and image

Just run this from your Mac terminal and it'll drop you in a container with full permissions on the Docker VM. This also works for Docker for Windows for getting in Moby Linux VM (doesn't work for Windows Containers).

docker run -it --rm --privileged --pid=host justincormack/nsenter1

more info: https://github.com/justincormack/nsenter1


@catichenor
catichenor / csv_check.py
Last active September 6, 2023 17:39
Check CSV file for a header row, and detect the dialect.
import csv
input_csv_file = '/path/to/test_csvfile.csv'
with open(input_csv_file, 'rb') as csvfile: #`with open(input_csv_file, 'r') as csvfile:` for Python 3
csv_test_bytes = csvfile.read(1024) # Grab a sample of the CSV for format detection.
csvfile.seek(0) # Rewind
has_header = csv.Sniffer().has_header(csv_test_bytes) # Check to see if there's a header in the file.
dialect = csv.Sniffer().sniff(csv_test_bytes) # Check what kind of csv/tsv file we have.
inputreader = csv.reader(csvfile, dialect)
@lukeplausin
lukeplausin / bash_aws_jq_cheatsheet.sh
Last active January 29, 2024 10:00
AWS, JQ and bash command cheat sheet. How to query, cut and munge things in JSON generally.
# Count total EBS based storage in AWS
aws ec2 describe-volumes | jq "[.Volumes[].Size] | add"
# Count total EBS storage with a tag filter
aws ec2 describe-volumes --filters "Name=tag:Name,Values=CloudEndure Volume qjenc" | jq "[.Volumes[].Size] | add"
# Describe instances concisely
aws ec2 describe-instances | jq '[.Reservations | .[] | .Instances | .[] | {InstanceId: .InstanceId, State: .State, SubnetId: .SubnetId, VpcId: .VpcId, Name: (.Tags[]|select(.Key=="Name")|.Value)}]'
# Wait until $instance_id is running and then immediately stop it again
aws ec2 wait instance-running --instance-id $instance_id && aws ec2 stop-instances --instance-id $instance_id
# Get 10th instance in the account
@hervenicol
hervenicol / run.tpl
Last active May 12, 2023 14:20 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
--name={{.Name}} \
{{range $e := .Config.Env}}--env={{printf "%q" $e}} \
{{end}}{{range $p, $conf := .NetworkSettings.Ports}}{{with $conf}}-p {{(index $conf 0).HostIp}}:{{(index $conf 0).HostPort}}:{{$p}} \
{{end}}{{end}}{{range $n, $conf := .NetworkSettings.Networks}}{{with $conf}}--network {{printf "%q" $n}} \
{{range $conf.Aliases}}--network-alias {{printf "%q" .}} {{end}} \
{{end}}{{end}}{{range $v := .HostConfig.VolumesFrom}}--volumes-from={{printf "%q" .}} \
{{end}}{{range $v := .HostConfig.Binds}}--volume={{printf "%q" .}} \
{{end}}{{range $l, $v := .Config.Labels}}--label {{printf "%q" $l}}={{printf "%q" $v}} \
{{end}}{{range $v := .HostConfig.CapAdd}}--cap-add {{printf "%q" .}} \