Skip to content

Instantly share code, notes, and snippets.

# Parallel convert using ImageMagick and xargs
ls IMG_* |xargs -n1 -IX -P8 sh -c 'echo X; convert X -resize 1952x1080 1080/X'
# More ffmpeg commands:
# http://processors.wiki.ti.com/index.php/Open_Source_Video_Processing_Tools_-_MPlayer,_FFMpeg,_AviSynth,_MKVToolnix,_MP4Box
# Encode numbered images using ffmpeg
ffmpeg -start_number 100 -vframes 10 -i IMG_%03d.jpg -pix_fmt yuv420p output.mp4
# Encode numbered images using ffmpeg - creates REC.601(8bit) output
ffmpeg -i input.mp4 -pix_fmt yuv420p output.mp4
# Encode numbered images using ffmpeg - creates REC.709(10bit) output
# Multi-threaded, verbose and debug output enabled - output has prefix "stab"
OMP_NUM_THREADS=8 align_image_stack -a stab IMG_* -v -p debug.pto
#!/bin/bash
cd $(dirname "$0")
# Date 16:05 hours ago
DATE=$(date -d '965 minutes ago' +'%Y-%m-%d')
PID_FILE="grep_platform_logs.pids"
FILE_PATTERN="platform.2018-03-06.log$"
SEARCH_OPTS="-Ei "recovery""
# Sample ip route examples
sudo ip route # List route
sudo ip route add 52.0.0.0/8 via 192.168.1.1 dev wlp2s0 proto static metric 40
sudo ip route change 52.0.0.0/8 via 192.168.1.1 dev wlp2s0 proto static metric 40
sudo ip route del 52.0.0.0/8 via 192.168.1.1 dev wlp2s0 proto static metric 40
@csghone
csghone / ldap.sh
Last active June 27, 2018 06:31
LDAP Utils examples
# No auth, no SSL search
ldapsearch -vvv -x -H ldap://ldap.mydomain.com:389 -b "cn=accounts,dc=mydomain,dc=com" uid=csghone
# AUTH + SSL search
LDAPTLS_CACERT=ldap.crt ldapsearch -vvv -Z -H ldaps://ldap.mydomain.com:636 \
-b "cn=accounts,dc=mydomain,dc=com" \
-D "uid=dummy_user_for_bind,cn=users,cn=accounts,dc=mydomain,dc=com" \
-w <password_for_dummy_user_for_bind> \
uid=csghone
@csghone
csghone / rsync_test.sh
Created July 10, 2018 11:13
rsync_test.sh
#!/bin/bash
HOST="192.168.1.4"
TEMP_IN="i1"
TEMP_OUT="o1"
delete_temp_files() {
rm $TEMP_IN
ssh $HOST rm $TEMP_OUT
#!/bin/bash
# Source this in your script to use these functions
function bash_check_int {
if [ "$1" -eq "$1" ] 2>/dev/null; then
return 0
fi
echo "$2 must be an integer"
return -1
}
@csghone
csghone / aws_batch_setup.md
Last active September 14, 2020 05:22
Parallel Jobs using AWS Batch

Summary

  • This page outlines how to configure AWS Batch to create a LSF/Slurm like setup for running several jobs in parallel on spot instances
  • Components
    • Create a custom AmazonECS AMI (controls available diskspace)
    • Create a custom Docker Image in Amazon ECR (Contains all needed software - we use Ubuntu as starting point)
      • This contains a generic /run_job.sh which will be our entry point
    • Create a EFS instance (This provides space for input/output data for your jobs)

VPC Setup

  • Enable DNS hostname and DNS resolution on your VPC
#!/usr/bin/env python3
"""
eg:
./send_to_slack.py -u csghone '#testingbots' -m hello -e heavy_check_mark
./send_to_slack.py -u csghone '#testingbots' -a send_file -f /path/to/myfile -e heavy_check_mark -m hello
"""
from __future__ import print_function
import os