Skip to content

Instantly share code, notes, and snippets.

Avatar
👯‍♀️
OMG

Ian Vaughan IanVaughan

👯‍♀️
OMG
View GitHub Profile
View application_helper.rb
def path_to_attachment_image(attachment)
image_path("attachments/#{attachment.filename}")
end
View application_helper.rb
module ApplicationHelper
# Access Levels
ACCESS_LEVELS = { :private => 0, :friends => 1, :public => 2 }
# Access levels i18n translation
def access_levels
ACCESS_LEVELS.collect{|k,v| [I18n.t("access." + k.to_s), v]}
end
end
@IanVaughan
IanVaughan / monitor.sh
Created Jul 22, 2010
monitor.sh - checks for any file changes within a folder
We couldn’t find that file to show.
@IanVaughan
IanVaughan / backup_all_subfolders.sh
Created Aug 16, 2010
This will tar all the subfolders within the PWD, uncomment the rm at your peril!
View backup_all_subfolders.sh
#!/bin/bash
# This will tar all the subfolders within the PWD, uncomment the rm at your peril!
DIRS=`ls -d */`
for DIR in ${DIRS}; do
TAR_PATH=${DIR%%/}
echo "Processing : $TAR_PATH"
tar -zcvf ${TAR_PATH}.tar.gz ${TAR_PATH} > ${TAR_PATH}.tar.gz.log
# rm -rf ${TAR_PATH}
done
@IanVaughan
IanVaughan / remove.rb
Created Aug 19, 2010
remove.rb - removes tons of #ifdef defines in code bases
View remove.rb
#!/usr/bin/env ruby
class Remover
attr_accessor :remove_words
attr_accessor :error_files
def initialize(path = "")
@remove_words = ['#ifdef RIDEBUG', '#endif']
@error_files = []
end
@IanVaughan
IanVaughan / install_perl.sh
Created Oct 28, 2010
Installing perl modules for Bugzilla when no internet access
View install_perl.sh
#!/bin/sh
# Download locations
# http://www.bugzilla.org/docs/3.6/en/html/modules-manual-download.html
# http://www.bugzilla.org/docs/3.6/en/html/modules-manual-optional.html
LOGFILE=install_progress.txt
PROCESSED_FILES_DIR=processed_files
mkdir -p ${PROCESSED_FILES_DIR}
@IanVaughan
IanVaughan / current_ips.sh
Created Nov 2, 2010
bash shell script that gets the current IP address and xflash version and echos into a file, which is then copied onto a remote host
View current_ips.sh
#!/bin/bash
REMOTE_SERVER=192.168.109.2
#IRV: Cat into same file? What if many try at same time? But would be better cos could tail -f!
#OUTPUT=/path/hosts_${HOSTNAME}.txt #IRV: advantage here is file date/time is updated on target, so dont need to know date here
#OUTPUT=/path/hosts.txt
OUTPUT=hosts.txt
touch $OUTPUT
REMOTE_PATH=/path2
#TIME_STAMP=$(date +%Y%m%d) # doesnt work on blades due to no battery!
@IanVaughan
IanVaughan / whereami.sh
Created Nov 9, 2010
file that wants to email you with its IP addresses (doesnt work!)
View whereami.sh
#!/bin/bash
SEND=mail.txt
echo "Date: " > $SEND
echo "Subject: $S2SYSTEM is now at" >> $SEND
echo "From: ECM" >> $SEND
echo "" >> $SEND
ifconfig eth0 | grep "inet addr" >> $SEND
@IanVaughan
IanVaughan / setup_ssh.sh
Created Nov 10, 2010
setup_ssh.sh - copies SSH public keys between hosts
View setup_ssh.sh
#!/bin/bash
HOST=0
if [ "$SYSTEM" == "type1" ]; then
HOST=192.168.0.2
elif [ "$SYSTEM" == "type2" ]; then
HOST=192.168.0.1
else
echo "Error 1"
exit
@IanVaughan
IanVaughan / record.sh
Created Nov 21, 2010
record.sh - use rec to record parameter $1.ogg for $2 hours
View record.sh
#!/bin/bash
FILENAME=$1
HOURS=$2
SECONDS=$((3600 * ${HOURS}))
echo "Recording ${FILENAME} for ${SECONDS} seconds..."
rec -c 2 ${FILENAME}.ogg trim 0 ${SECONDS}