Skip to content

Instantly share code, notes, and snippets.

@philroche
philroche / bash-to-zsh-hist.py
Created January 17, 2022 08:58 — forked from muendelezaji/bash-to-zsh-hist.py
Convert Bash history to Zsh history
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This is how I used it:
# $ cat ~/.bash_history | python bash-to-zsh-hist.py >> ~/.zsh_history
import sys
import time
@rcj4747
rcj4747 / healthchecks.sh
Last active May 14, 2021 14:43
Run a command and report status to https://healthchecks.io
#!/bin/bash -eu
set -o pipefail
# Run a command and report status to https://healthchecks.io
usage() {
echo "Usage: $0 <healthchecks.io UUID> <command>"
exit 1
}
trap usage EXIT
@rcj4747
rcj4747 / aws_ec2_describeInstanceTypes.py
Created September 2, 2020 16:44
Play with AWS EC2 describe_instance_types
"""
Play with AWS EC2 describe_instance_types
"""
from boto3.session import Session
sess = Session()
ec2c = sess.client('ec2')
resp = ec2c.describe_instance_types()
@ThinGuy
ThinGuy / oscap-manifest.txt
Last active March 30, 2021 09:58
OpenSCAP OVAL Scanning Ubuntu Manifest Files
#!/bin/bash
##############################################################################
# ossa.sh - Open Source Security Assessment
#
#
# Author(s): Craig Bender <craig.bender@canonical.com>
#
# 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, version 3 of the License.
@calexandre
calexandre / merge-zsh-history.sh
Last active April 3, 2024 14:11
Merge two zsh history files
#!/bin/bash
# Inspired on https://david-kerwick.github.io/2017-01-04-combining-zsh-history-files/
set -e
history1=$1
history2=$2
merged=$3
echo "Merging history files: $history1 + $history2"
test ! -f $history1 && echo "File $history1 not found" && exit 1
@smoser
smoser / README.md
Last active July 11, 2022 20:29
backdoor-image

backdoor-image

Description

backdoor-image can be used to easily add user with passwordless sudo access to a image or a root filesystem.

Operating on an image requires the 'mount-image-callback' tool from cloud-utils. That can be installed on ubuntu via apt-get install -qy cloud-image-utils.

@rcj4747
rcj4747 / s3_presigned_url.py
Last active October 16, 2018 07:16
Generate a presigned URL to download an S3 object
#!/usr/bin/env python3
"""Generate a presigned URL to download an S3 object
<cmd> bucket_name key_name [expiration_days]"""
import sys
import boto3
from botocore.client import Config
@philroche
philroche / azure-sas-url-and-image-test.sh
Created September 28, 2018 11:39
Script for publishing, booting and gathering logs from a locally produced Azure image
#!/bin/bash
## Pass local .tar.gz path as first argument
# Update the following variables
# This will be created if it does not exist
ACCOUNT_NAME="philrocheubuntu"
# This will be created if it does not exist
CONTAINER="philrocheubuntuimages"
# Customize this as all vm resouces with this group will be cleaned up. This will be created if it does not exist
@rcj4747
rcj4747 / clipboard.py
Last active August 7, 2018 15:32
Watch the clipboard for URLs and open them in the browser (on Linux)
#!/usr/bin/env python3
"""
Watch the clipboard for URLs and open them in the browser (on Linux)
"""
import subprocess
import time
import pyperclip # Requires xclip to be apt installed
@rcj4747
rcj4747 / private_ppa_addition.sh
Created January 26, 2018 21:43
Add a package from a private PPA to a chroot and strip references to the private PPA
REPO_LINE="deb https://${LP_USER}:${PPA_PASSWORD}@${PRIVATE_PPA_URL} ${SUITE} main"
REPO_KEY_FINGERPRINT=832749327429CADB77842973ED72947203471037
# Add the private ppa to the system
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-add-repository "${REPO_LINE}"
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-key adv --keyserver keyserver.ubuntu.com --recv ${REPO_KEY_FINGERPRINT}
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get update
# Install from private PPA HERE
env DEBIAN_FRONTEND=noninteractive chroot "${MOUNTPOINT}" apt-get install -qqy awesome_package_but_super_secret