Skip to content

Instantly share code, notes, and snippets.

@philroche
philroche / bash-to-zsh-hist.py
Created Jan 17, 2022 — forked from muendelezaji/bash-to-zsh-hist.py
Convert Bash history to Zsh history
View bash-to-zsh-hist.py
#!/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
@philroche
philroche / configure-nodes-for-ssh-access.sh
Last active Oct 21, 2021
Configure SSH for access across nodes - 2021 PTG directord hackfest
View configure-nodes-for-ssh-access.sh
# Get SSH-config for nodes
vagrant ssh-config node0 > node0.ssh-config
vagrant ssh-config node1 > node1.ssh-config
# get teh SSH key path from the ssh-config
node0_ssh_key=$(ssh -F ./node0.ssh-config -G node0 | grep -m1 -oP "(?<=identityfile ).*")
echo ${node0_ssh_key}
node1_ssh_key=$(ssh -F ./node1.ssh-config -G node1 | grep -m1 -oP "(?<=identityfile ).*")
echo ${node1_ssh_key}
@philroche
philroche / healthchecks.sh
Created May 14, 2021 — forked from rcj4747/healthchecks.sh
Run a command and report status to https://healthchecks.io
View healthchecks.sh
#!/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
@philroche
philroche / oscap-manifest.txt
Created Mar 30, 2021 — forked from ThinGuy/oscap-manifest.txt
OpenSCAP OVAL Scanning Ubuntu Manifest Files
View oscap-manifest.txt
#!/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.
@philroche
philroche / aws_ec2_describeInstanceTypes.py
Created Sep 2, 2020 — forked from rcj4747/aws_ec2_describeInstanceTypes.py
Play with AWS EC2 describe_instance_types
View aws_ec2_describeInstanceTypes.py
"""
Play with AWS EC2 describe_instance_types
"""
from boto3.session import Session
sess = Session()
ec2c = sess.client('ec2')
resp = ec2c.describe_instance_types()
@philroche
philroche / img-convert
Created Apr 2, 2020 — forked from smoser/img-convert
Utility for converting a disk image in raw format or some format qcow understands into VHD format.
View img-convert
#!/bin/bash
VERBOSITY=0
TEMP_D=""
FORMATS=(
qcow2
qcow2-compressed
raw
azure
azure-dynamic
azure-fixed
@philroche
philroche / README.md
Created Jan 31, 2020 — forked from smoser/README.md
backdoor-image
View README.md

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.

@philroche
philroche / cloneawsinstance
Created Nov 29, 2019
cloneawsinstance function to clone an aws instance in the same region as the source instance
View cloneawsinstance
function cloneinstance {
awsinstanceid=$1
region=${2:-us-east-1}
awsprofile=${3:-seg}
export AWS_DEFAULT_REGION=$region
dt=$(date '+%Y%m%d%H%M%S')
ami=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].ImageId' --output=text)
privatekey=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].KeyName' --output=text)
securitygroup=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].NetworkInterfaces[].Groups[].GroupId' --output=text)
instancetype=$(aws --profile=${awsprofile} ec2 describe-instances --instance-ids $awsinstanceid --query 'Reservations[].Instances[].InstanceType' --output=text)
@philroche
philroche / transmission-openvpn.syno.json
Created Nov 7, 2019
Docker config for Synology NAS for docker-transmission-openvpn docker image by haugene (https://github.com/haugene/docker-transmission-openvpn). This config is for Private Internet Access. Also see https://haugene.github.io/docker-transmission-openvpn/synology-nas/ for full guide.
View transmission-openvpn.syno.json
{
"cap_add" : null,
"cap_drop" : null,
"cmd" : "dumb-init /etc/openvpn/start.sh",
"cpu_priority" : 50,
"devices" : null,
"enable_publish_all_ports" : false,
"enable_restart_policy" : false,
"enabled" : false,
"env_variables" : [
View Get the URL to the RTE player video.bookmarklet
javascript:(function()%7Bfunction%20callback()%7B(function(%24)%7Bvar%20jQuery%3D%24%3Bfunction%20callback()%7Bfunction%20getParameterByName(name%2C%20url)%20%7Bif%20(!url)%20url%20%3D%20window.location.href%3Bname%20%3D%20name.replace(%2F%5B%5C%5B%5C%5D%5D%2Fg%2C%20'%5C%5C%24%26')%3Bvar%20regex%20%3D%20new%20RegExp('%5B%3F%26%5D'%20%2B%20name%20%2B%20'(%3D(%5B%5E%26%23%5D*)%7C%26%7C%23%7C%24)')%2Cresults%20%3D%20regex.exec(url)%3Bif%20(!results)%20return%20null%3Bif%20(!results%5B2%5D)%20return%20''%3Breturn%20decodeURIComponent(results%5B2%5D.replace(%2F%5C%2B%2Fg%2C%20'%20'))%3B%7Dvar%20video_embed_url%20%3D%20getParameterByName(%22pid%22%2C%20%24(%22%23playerpdk%22).attr(%22src%22))%3Bvar%20auth_cookie%20%3D%20Cookies.get('mpx_token')%3Bvar%20auth_video_embed_url%20%3D%20video_embed_url%20%2B%20'%3Fauth%3D'%20%2B%20auth_cookie%20%2B'%26formats%3Dmpeg-dash%26format%3DSMIL%26embedded%3Dtrue%26tracking%3Dtrue'%3Bconsole.log(auth_video_embed_url)%3Bprompt(%22Video%20embed%20URL%20for%20use%20with%20https%3A%2