Skip to content

Instantly share code, notes, and snippets.

View crashGoBoom's full-sized avatar

Christopher Mundus crashGoBoom

View GitHub Profile
@crashGoBoom
crashGoBoom / ffmpeg_batch_examples.txt
Last active January 10, 2019 20:06
ffmpeg batch conversion
# Convert 4:3 aspect ratio files to 16:9 with black bars. For each m4v file convert and encode using crf 18.
for i in *.m4v; do ffmpeg -i "$i" -vf "scale=960x720,setsar=1,pad=1280:720:160:0" -crf 18 "${i%.m4v}.mp4"; done
# For normal conversion to mp4.
for i in *.m4v; do ffmpeg -i "$i" "${i%.m4v}.mp4"; done
# For mov to mp4 conversion with some compression.
for i in *.mov; do ffmpeg -i "$i" -crf 23 -vcodec libx264 -acodec aac "${i%.mov}.mp4"; done
@crashGoBoom
crashGoBoom / installingLaravelMac
Last active January 26, 2018 22:41
Installing Laravel - Mac
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
# to fix this error "file_put_contents(./composer.json): failed to open stream: Permission denied"
# take ownership of the .composer folder.
sudo chown -R $USER ~/.composer
# next install laravel
composer global require "laravel/installer"

Keybase proof

I hereby claim:

  • I am crashgoboom on github.
  • I am chriskindlyops (https://keybase.io/chriskindlyops) on keybase.
  • I have a public key ASAdlzW_WEQVZ-2rQwqnnypvIWObjnNO3SbnQYEY_lE5kQo

To claim this, I am signing this object:

@crashGoBoom
crashGoBoom / example_get_opts.sh
Created January 17, 2019 21:45
Example of parsing sub commands in a function with getopts
function get_help() {
cat <<help_message
--- script subcommand -------------------------------------------------------------
Commands related to this script
USAGE:
script command shell [FLAGS] [SUBCOMMAND]
@crashGoBoom
crashGoBoom / video_from_text.sh
Last active January 27, 2019 19:01
Create video from text
# This will create a 5 second long mp4 file using the provided font, text and image with a fade in and out effect.
_dur=5
_framerate=30
_fontfile='/tmp/somefont.ttf'
_fontsize=30
_fontcolor='white'
_text='Sample Bumper Video'
_background_color='black'
_drawtext="fontfile=${_fontfile}:fontsize=${_fontsize}"
_fade="fade=in:0:25,fade=out:50:60"
@crashGoBoom
crashGoBoom / aws-iam-simulate.sh
Last active September 16, 2022 03:46
Use AWS IAM Policy Simulator with the CLI
# The action we want to test
_action="s3:GetObject"
# The JSON you want to convert to a string
_json_to_convert='{ "Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": "*","Resource": "*"}]}'
# Your resource arn goes here
_resource_arn="arn:aws:s3:::${_some_s3_bucket}/${_some_prefix}/*"
# This command will format the json policy as a string for the cli to use
# echo ${_json_to_convert} | jq '[.|tostring]'
# But we will send it to a fifo with '<()' instead of creating a json file every time
@crashGoBoom
crashGoBoom / jq_functions.sh
Created May 9, 2019 13:04
Simple handy jq functions.
declare -r SOME_JSON_FILE="/path/to/json/file.json"
# Read a key from a file.
# Usage: _key_value=$(_read_json_key "key")
function _read_json_key() {
local -r _key="${1}"
jq --arg key "${_key}" -r '.[$key]' "${SOME_JSON_FILE}"
}
# Writes a json key into an existing file without overwriting.
@crashGoBoom
crashGoBoom / vid2gif.sh
Created August 27, 2019 18:55
Create a gif from mov file using FFMPEG
_video_file="${1}"
ffmpeg -i $_video_file -vf palettegen pal.png
ffmpeg -i $_video_file -i pal.png -lavfi paletteuse=bayer_scale=4:dither=bayer -r 18 video.gif
@crashGoBoom
crashGoBoom / ssm_local.sh
Last active July 1, 2020 19:58
Local Port Forwarding with AWS SSM
#!/bin/bash
# Usage: ./ssm_local.sh i-xxxxxxxxxx 80
_instance_id="${1}"
_instance_port="${2}"
aws ssm start-session --target "${_instance_id}" \
--document-name AWS-StartPortForwardingSession \
--parameters "{\"portNumber\":[\"${_instance_port}\"],\"localPortNumber\":[\"9000\"]}"
@crashGoBoom
crashGoBoom / get_bucket_by_prefix.sh
Created September 30, 2020 16:43
aws s3 get bucket by name prefix
#!/bin/bash
# Usage: ./get_bucket_byprefix.sh "someprefix"
_prefix="${1}"
aws s3api list-buckets --query "Buckets[?starts_with(Name,'${_prefix}')].Name