Skip to content

Instantly share code, notes, and snippets.

View jbranchaud's full-sized avatar

Josh Branchaud jbranchaud

View GitHub Profile
@jbranchaud
jbranchaud / JavaScriptResources.md
Last active August 29, 2015 14:08
JavaScript Resources
puts '====='
puts 'defining the Parent class with #poop'
class Parent
def poop
puts "💩 💩"
end
end
puts 'defining the Child < Parent class with #poop'
# with postgres DDL
execute SQL<<-
create table users(
...
created_at timestamptz not null,
updated_at timestamptz not null
);
SQL
# with Rails DSL
@jbranchaud
jbranchaud / rails_slice.rb
Created August 13, 2015 21:45
slice and slice! in Rails
> {a: 1, b: 2, c: 3}.slice(:a)
=> {:a=>1}
> {a: 1, b: 2, c: 3}.slice!(:a)
=> {:b=>2, :c=>3}
@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