Skip to content

Instantly share code, notes, and snippets.

@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
@philroche
philroche / s3_presigned_url.py
Created October 16, 2018 07:16 — forked from rcj4747/s3_presigned_url.py
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 / recursive-m4v-convert.sh
Last active November 8, 2018 17:42
Recursively convert all files using HandbrakeCLI and save to new folder.
#!/bin/bash
#
# Change this to specify a different handbrake preset. You can list them by running: "HandBrakeCLI --preset-list"
#
#set -ux
set +e
PRESET="Very Fast 720p30" # or Fast 720p30 or Fast 1080p30
if [ -z "$1" ] ; then
TRANSCODEDIR="."
else
@philroche
philroche / keybase.md
Last active February 6, 2019 18:55
keybase.md

Keybase proof

I hereby claim:

  • I am philroche on github.
  • I am philroche (https://keybase.io/philroche) on keybase.
  • I have a public key whose fingerprint is 77BB A519 ABC5 FDE7 ED9D 30AA 50DC BC7C 3339 F00F

To claim this, I am signing this object:

@philroche
philroche / Get the URL to the RTE player video.bookmarklet
Last active May 13, 2019 15:01
Get the URL to the RTE player video
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
#!/bin/bash -e
## Launch the latest daily Ubuntu in AWS, optionally with user-data
## provided in a file and tagged with a name
function usage() {
echo "$0: [-r region] [-V ubuntu_version] [-i instance_type] \\"
echo " [-u user_data_file] [-n instance_name] [-d disk_size] \\"
echo " [-D] to disable termination via the API"
echo " [-I] iam instance profile [-a AMI ID]"
echo " [-P profile] aws cli profile"
@philroche
philroche / transmission-openvpn.syno.json
Created November 7, 2019 11:10
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.
{
"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" : [
@philroche
philroche / cloneawsinstance
Created November 29, 2019 16:44
cloneawsinstance function to clone an aws instance in the same region as the source instance
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 / img-convert
Created April 2, 2020 13:08 — forked from smoser/img-convert
Utility for converting a disk image in raw format or some format qcow understands into VHD format.
#!/bin/bash
VERBOSITY=0
TEMP_D=""
FORMATS=(
qcow2
qcow2-compressed
raw
azure
azure-dynamic
azure-fixed
@philroche
philroche / aws_ec2_describeInstanceTypes.py
Created September 2, 2020 16:50 — forked from rcj4747/aws_ec2_describeInstanceTypes.py
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()