Skip to content

Instantly share code, notes, and snippets.

View JohnPreston's full-sized avatar
🏠
Working on AWS' cloud

John Preston JohnPreston

🏠
Working on AWS' cloud
View GitHub Profile
@JohnPreston
JohnPreston / remove_old.py
Last active October 25, 2016 15:43
Very simple script to remove all files in a folder based on expiration timestamp
#!/usr/bin/env python
"""
Script to remove all folders in the given path that are older than 24H
"""
import os
import sys
import argparse
import datetime
#!/usr/bin/env bash
# quick and dirty way to filter out items from JSON file (my use-case: CF template resources)
grep vpc prod-VPC.json | egrep -v '(Ref|DependsOn)' | grep \{ | sed 's/[^0-9a-zA-Z]//g' | uniq
@JohnPreston
JohnPreston / get_filenames.py
Created October 11, 2016 15:42
Recursive function to find all fines full paths
def get_filenames(search_path=None):
"""
List all files under .git
:return:
"""
intab = '\\'
outtab = '/'
transtab = maketrans(intab, outtab)
files_list = []
#!/usr/bin/env bash
cd /var/log ; for i in `ls -l | grep drw | awk '{print $NF}'`; do cd $i; for j in `ls | more` ; do cat /dev/null > $j ; done ; cd - ; done
rm -rfv /etc/udev/rules.d/*
rm -rfv /etc/ssh/ssh_host_*
cd $HOME
rm -rfv .bash_history
rm -rf .ssh/authorized_keys
history -c
#!/usr/bin/env bash
for i in `ls -l | grep drw | awk '{print $NF}'`; do cd $i; for j in `ls | more` ; do cat /dev/null > $j ; done ; cd - ; done
@JohnPreston
JohnPreston / install_ffmpeg_amzn_linux.sh
Last active August 27, 2017 23:37
Script to install FFPMpeg on Amazon Linux - Centos
#!/usr/bin/env bash
if ! [ "$#" -eq 1 ]; then
echo "Usage: install_ffmpeg_amzn_linux.sh build_directory"
exit 1
fi
CPU_THREADS=`cat /proc/cpuinfo | grep processor | tail -1 | awk '{print $NF}'`
ROOT_DIR=$1
SOURCES_DIR=$ROOT_DIR/ffmpeg_sources
# Exemple CEPH.conf file with a bit of tunning around scrubing.
# very short intervals were to prove that scrubbing could be done every hour but isnt happening because of begin and end time of day settings
[global]
fsid = ef66f3c8-2cbe-4195-8fbc-bc2b14ba6d69
public_network = 192.168.100.0/24
cluster_network = 192.168.101.0/24
mon_initial_members = nc-0
mon_host = 192.168.100.3
auth_cluster_required = cephx
#!/usr/bin/env bash
# GNU GENERAL PUBLIC LICENSE
# Version 3, 29 June 2007
# Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
# Everyone is permitted to copy and distribute verbatim copies
# of this license document, but changing it is not allowed.
# Preamble
@JohnPreston
JohnPreston / get_all_group_policies.sh
Created May 26, 2016 17:02
Get all the policies of a group
#!/usr/bin/env bash
for policy in `aws iam list-group-policies --group-name $GROUP_NAME --endpoint-url=$IAM_URL --region euca --output=text | awk '{print $2}'` ; do
aws iam get-group-policy --policy-name "$policy" --group-name $GROUP_NAME --endpoint-url=$IAM_URL --region euca > "$policy".json
done
@JohnPreston
JohnPreston / deploy_ceph_osd.sh
Created May 4, 2016 14:06
Small and simple bash script to deploy ceph-osds
#!/usr/bin/env bash
for host in 02 03 04; do
journal=1
for osd_disk in b c d e; do
echo "host node-$host disk sd$osd_disk journal sdf$journal"
# echo osd prepare node-"$host":/dev/sd"$osd_disk"1:/dev/sdf"$journal"
# echo osd activate node-"$host":/dev/sd"$osd_disk"1:/dev/sdf"$journal"
ceph-deploy osd prepare node-"$host":/dev/sd"$osd_disk"1:/dev/sdf"$journal"
ceph-deploy osd activate node-"$host":/dev/sd"$osd_disk"1:/dev/sdf"$journal"