Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# aa.sh
# Scale and crop album art for embedding in music tags
if [ -z $1 ]
then
echo "Usage: `basename $0` image_file"
else
convert $1 -resize 300x300^ -gravity center -extent 300x300 folder.jpg
fi
# Strip ID3 Tags from FLAC
find . -name "*.flac" -exec id3v2 --delete-all {} \;
# Search for a text string in all files and subdirectories.
find -type f -print0 | xargs -0 grep -il "$1"
# Prints the folder name number of files and folders in each subdirectory.
for i in *; do show="$i"; num=`ls "$i" | wc -l`; echo "$show: $num"; done;
#!/bin/bash
# Checks to see if irexec is running and runs it if not already running.
youruser=richard
# Test to see if IRexec is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -vi start|grep -i irexec
then
ps aux|grep -i $youruser|grep -i irexec |grep -vi start|awk '{print $2}'|xargs kill
else
#/bin/bash
# Switch between XBMC and Boxee
if ps ax | grep -v grep | grep xbmc.bin > /dev/null
then
echo "XBMC running, killing process"
kill `pidof xbmc.bin`
sleep 7
echo "running Boxee"
/usr/bin/runBoxee &
elif ps ax | grep -v grep | grep Boxee > /dev/null
#!/bin/bash
# Convert videos from Canon S90 to flash-playable streaming format
for file in "$@"
do
filename=$(basename $file)
filename=${filename%.*}
# Convert the audio stream to AAC
ffmpeg -i $file -vcodec copy -acodec libfaac temp_vid.mp4
# Move the H.264 MOOV atom to the beginning of the file for progressive streaming
qt-faststart temp_vid.mp4 $filename.mp4
#!/bin/bash
#Setup passwordless login and install nagios plugin on remote client
ID=/etc/nagios3/keys/id_rsa
SCRIPT=nagios-install-plugins.sh
SCRIPTPATH=/home/richard/scripts
EXTRA=nagios-plugins-extra
if [ -e "$SCRIPTPATH/$SCRIPT" ]; then
sudo su -l -s /bin/bash nagios -c "ssh-copy-id -i $ID $1; \
#!/bin/bash
#Install nagios plugins
VERSION=1.4.15
DESTDIR=~/nagios-plugins
URL=http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/${VERSION}/nagios-plugins-${VERSION}.tar.gz
FILE=nagios-plugins-${VERSION}.tar.gz
FOLDER=nagios-plugins-${VERSION}
@richardpeng
richardpeng / install-dnsmasq
Last active December 17, 2015 08:58
Redirect all traffic on a wildcard domain to an IP address using Dnsmasq on Mac
# install dnsmasq with Brew
brew install dnsmasq
# follow instructions on how to create a config file and startup entries
# copy example config to live config file
cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
# install startup script
sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons