Skip to content

Instantly share code, notes, and snippets.

View IanVaughan's full-sized avatar
👯‍♀️
OMG

Ian Vaughan IanVaughan

👯‍♀️
OMG
View GitHub Profile
def path_to_attachment_image(attachment)
image_path("attachments/#{attachment.filename}")
end
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 July 22, 2010 12:20
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 August 16, 2010 11:14
This will tar all the subfolders within the PWD, uncomment the rm at your peril!
#!/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 August 19, 2010 16:36
remove.rb - removes tons of #ifdef defines in code bases
#!/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 October 28, 2010 15:59
Installing perl modules for Bugzilla when no internet access
#!/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 November 2, 2010 11:42
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
#!/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 November 9, 2010 11:24
file that wants to email you with its IP addresses (doesnt work!)
#!/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 November 10, 2010 11:31
setup_ssh.sh - copies SSH public keys between hosts
#!/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 November 21, 2010 20:29
record.sh - use rec to record parameter $1.ogg for $2 hours
#!/bin/bash
FILENAME=$1
HOURS=$2
SECONDS=$((3600 * ${HOURS}))
echo "Recording ${FILENAME} for ${SECONDS} seconds..."
rec -c 2 ${FILENAME}.ogg trim 0 ${SECONDS}