Skip to content

Instantly share code, notes, and snippets.

@davidoram
davidoram / pre-commit.rb
Created December 20, 2012 18:35
svn pre-commit hook that prevents text files (based on extension) from being committed if they contain a Byte Order Mark (BOM). If using on windows must wrap in a batch script
#!/usr/bin/env ruby
# pre-commit.rb
# Exit 1 if is a text file and has a BOM at the head of the file
# Create list of file extensions that are considered text files.
text_files = [
".awk",
".bas",
".bat",
".cfc",
@davidoram
davidoram / findext.rb
Created December 20, 2012 18:21
Output a list of the unique file extensions in the current directory and all subdirectories, lowercased and sorted
#!/bin/ruby
# Output a list of the unique file extensions in this directory and all subdirectories
# lowercased and sorted
extensions = {}
Dir.glob('**/*') do |f|
ext = File.extname(f).downcase
extensions[ext] = ext if ext
end
puts extensions.keys.sort