Skip to content

Instantly share code, notes, and snippets.

@erulabs
erulabs / kernel.sh
Created November 9, 2018 00:29
kernel.sh
#!/bin/bash
echo -n "Waiting for dpkg to settle"
while ! cloud-init status | fgrep done; do
echo -n "."
sleep 3
done
echo
KERNEL_SHORT="4.18.17"
@erulabs
erulabs / raspbian-kube-setup.sh
Last active October 29, 2018 06:48
raspbian-kube-setup.sh
#!/bin/sh
# This installs the base instructions up to the point of joining / creating a cluster
sudo systemctl enable ssh
sudo systemctl start ssh
curl -sSL get.docker.com | sh && \
sudo usermod pi -aG docker
@erulabs
erulabs / mysql_slave_alterer.sh
Created May 10, 2017 01:56
A simple tool to do extremely long running ALTERs on every single table (useful for changing ROW_FORMAT and COLLATION) in a database
#!/bin/bash
# configurable options:
MIN_FREE_GB_LEFT=${MIN_FREE_GB_LEFT:-10}
SECONDS_BEHIND_MASTER_ALLOWED=${SECONDS_BEHIND_MASTER_ALLOWED:-0}
USAGE='Usage: ./mysql_slave_optimize.sh <database_name> "<query>" "[table table table...]"
Example queries:
- "OPTIMIZE _TABLE_"

Keybase proof

I hereby claim:

  • I am erulabs on github.
  • I am erulabs (https://keybase.io/erulabs) on keybase.
  • I have a public key whose fingerprint is 9E36 D604 AD4D B02A 3058 64B7 9A19 0FEE 8E2E 80AD

To claim this, I am signing this object:

#!/bin/bash
NEW_SERVERS=(server1 server2)
rotato=0
curl -sS -XGET 'http://localhost:9200/_cat/shards' | fgrep 'r STARTED' | while read line ; do
index="$(echo $line | awk '{print $1}')"
shard="$(echo $line | awk '{print $2}')"

Keybase proof

I hereby claim:

  • I am erulabs on github.
  • I am erulabs (https://keybase.io/erulabs) on keybase.
  • I have a public key whose fingerprint is 6014 2D0E 8E2C 9707 AD79 50B3 76BD 8647 ED35 968D

To claim this, I am signing this object:

# Make sure to escape these paths if there are spaces in the names
# for example: '/family guy' should be '/family\ guy'
# CHANGE THESE PATHS
SHOW_DIR_IN="/home/arc/Downloads/samurai.jack/"
SHOW_DIR_OUT="/home/arc/Downloads/samurai.jack/"
for file in `find ${SHOW_DIR} -name *.*`; do
BASENAME=$(basename ${file})
ffmpeg -i "${file}" -vcodec libx264 -acodec libfdk_aac -r:v 25 -vf scale=640:360 -aspect 16:9 -b:v 520k -b:a 96k -ar 44100 "${SHOW_DIR_OUT}${BASENAME}.converted.mp4"
for FULLPATH in `ls -1 /home/arc/Downloads/South\ Park/`; do
FILE=$(basename ${FULLPATH})
echo "Starting to convert ${FILE}"
ffmpeg -i ${FULLPATH} -c:v libx264 __OTHER_OPTIONS_HERE__ /home/arc/Documents/South\ Park\ Converted/${FILE}
done
@erulabs
erulabs / apache_parser.js
Last active August 29, 2015 14:19
Parse apache log files :)
#!/usr/bin/env node
/*jslint regexp: true, indent: 2 */
(function () {
'use strict';
var readline = require('readline'),
// Default log format - Used to parse the input stream
LOG_FORMAT = '%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-agent}i"',
// Used to WRITE the json - keys of KEY_MAP are keys in your output JSON
#!/bin/bash
# Loop over all the input files
for file in /whereever/i/keep/videos/*.input
do
# If the output file doesnt exist
if [ ! -e ${file}.output ]
then
# Then encode it
ffmpeg -re -y -i ${file}