Skip to content

Instantly share code, notes, and snippets.

View jbranchaud's full-sized avatar

Josh Branchaud jbranchaud

View GitHub Profile
@jbranchaud
jbranchaud / SVNAuthorList.bash
Created November 9, 2011 03:59
List Authors/Committers for SVN Repsitory
#!/bin/bash
# Outputs the list of authors/committers for the SVN repository
# This script must be run from within the working copy of the repository
svn log --quiet | awk '/^r/ {print $3}' | sort -u
@jbranchaud
jbranchaud / SVNAuthorCommitCount.bash
Created November 9, 2011 12:54
Counts the number of commits a given author has made in the SVN repository
#!/bin/bash
# This script must be run from within the working copy of the repository
# Put the author in a variable
author=$1
# Count the number of commits for a given author
svn log --quiet | awk '/^r/' | awk "/$author/" | wc -l
@jbranchaud
jbranchaud / GetHeadRevNumber.bash
Created November 9, 2011 13:23
Get the revision number for the HEAD of the repository
#!/bin/bash
# This script must be run from within the working copy of the repository
# Get the revision number for the HEAD of the repository
svn info -r HEAD | awk '/^Revision:/ {print $2}'
@jbranchaud
jbranchaud / FindAllOfType.bash
Created November 20, 2011 06:40
Finds all files at or below this directory of a given file type.
#!/bin/bash
# This script is going to find all files below the current directory of the given type
ftype=$1
find ./ | awk "/${ftype}$/ {print \$0}" | sed -e 's/\/\//\//'
exit 0
@jbranchaud
jbranchaud / GetPrevRevision.bash
Created November 29, 2011 22:44
Find the revision number previous to the given one for the given file
#!/bin/bash
# Given a filename and a revision number, find the revision number previous to this one.
fname=$1
curr=$2
prev=""
for revnum in `svn log -q $fname | awk '/^r/ {print $1}' | sed -e 's/r//' | sort -n`
do
@jbranchaud
jbranchaud / GetSortedOccurrenceList.bash
Created December 14, 2011 17:19
Get a sorted list of unique items in a file with their number of occurrences.
#!/bin/bash
# Given a file, output a sorted list of unique items with the number of occurrences for each item next to it
fname=$1
cat $fname | sort | uniq -c
exit 0
@jbranchaud
jbranchaud / getFileContents
Created February 7, 2012 20:30
Read file contents into a char[]
public char[] getFileContents(File file) {
// char array to store the file contents in
char[] contents = null;
try {
// Read in the contents line by line storing them in a StringBuffer
BufferedReader br = new BufferedReader(new FileReader(file));
StringBuffer sb = new StringBuffer();
String line = "";
@jbranchaud
jbranchaud / createParser
Created February 7, 2012 21:09
Create an ASTParser (CompilationUnit) for the JDT using a char[]
public CompilationUnit createParser(char[] contents) {
// Create the ASTParser which will be a CompilationUnit
ASTParser parser = ASTParser.newParser(AST.JLS4);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(contents);
parser.setResolveBindings(true);
CompilationUnit parse = (CompilationUnit) parser.createAST(null);
return parse;
@jbranchaud
jbranchaud / CSVtoLaTeX.bash
Created April 19, 2012 04:36
Convert CSV to LaTeX table
# Convert a CSV like the following:
# a,b,c,d,e,f,g
# To the LaTeX table format like the following:
# {a} & {b} & {c} & {d} & {e} & {f} & {g} \\\hline
sed 's/,/} \& {/g' Table1.csv | sed 's/^/{/' | sed 's/$/} \\\\\\hline/' > Table1Format.txt
@jbranchaud
jbranchaud / RSVPCounter
Created August 24, 2012 19:17
Count people that have RSVP'd
cat rsvpresults.yaml | grep 'totalPeople' | sed 's/totalPeople: //' | awk '{s+=$1} END {print s}'