Skip to content

Instantly share code, notes, and snippets.

@davidoram
davidoram / custom_formatter.rb
Created Aug 19, 2015
Rspec 2 formatter to output files in the order they are tested
View custom_formatter.rb
#
# Rspec 2.x custom formatter that will run all your tests and output a list of spec files that have been run
#
# Can be usefull for extracting all of the files that nmake up the test run
#
# TZ=Pacific/Auckland bundle exec rspec spec --tag ~integration --tag ~fragile --require ./custom_formatter.rb --format CustomFormatter --out specs.txt --seed 34104
#
require "rspec/core/formatters/base_text_formatter"
require 'JSON'
class CustomFormatter < RSpec::Core::Formatters::BaseTextFormatter
@davidoram
davidoram / serve_mov.sh
Created Jul 26, 2015
ffmpeg: Server `in.mov` file via ffserver (see other gist)
View serve_mov.sh
#!/bin/bash
ffmpeg -i in.mov -f ffm http://127.0.0.1:8090/feed1.ffm
@davidoram
davidoram / ffserver.conf
Created Jul 26, 2015
ffmpeg: Run ffserver available via http://localhost:8090/stat.html
View ffserver.conf
# Run via:
# ffserver -d -f ffserver.conf
Port 8090
BindAddress 0.0.0.0
MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 1000
CustomLog -
NoDaemon
@davidoram
davidoram / ffmpeg_filter.sh
Created Jul 26, 2015
ffmpeg: Apply a filter to a .mov file
View ffmpeg_filter.sh
#!/bin/bash
ffmpeg -i in.mov -vf "vflip" out.mov
@davidoram
davidoram / vcap.sh
Last active Aug 29, 2015
Capture video from OS X iSight camera using ffmpeg
View vcap.sh
#!/bin/bash
#
# Capture iSight Camera to a iSight.mpg file
#
# Press 'q' to stop capture
#
ffmpeg -f avfoundation -i "FaceTime" iSight.mpg
@davidoram
davidoram / dbutil.sh
Last active Aug 29, 2015
Backup or restore postgres db
View dbutil.sh
#!/usr/bin/env bash
#
# Backup, or Restore your postgres database
#
set -e
usage()
{
cat << EOF
@davidoram
davidoram / schema.sh
Last active Aug 29, 2015
Generate schemaspy docs for postgres db
View schema.sh
#!/usr/bin/env bash
#
# Spit out Schemaspy docs for a rails project, on a postgres db
#
# Assumes:
# - Have installed graphviz installed & in the path
# If not run 'brew install graphviz'
# - java installed & in the path
# - postgresql-9.3-1102.jdbc41.jar in current dir
# - schemaSpy_5.0.0.jar in current dir
@davidoram
davidoram / custom_cell.rb
Created May 15, 2014
Custom UITableViewCell in rubymotion
View custom_cell.rb
class CustomCell < UITableViewCell
def location=(value)
@locationLabel.text = value
end
def ringName=(value)
@ringNameLabel.text = value
end
@davidoram
davidoram / pre-commit.rb
Created Dec 20, 2012
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
View pre-commit.rb
#!/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 Dec 20, 2012
Output a list of the unique file extensions in the current directory and all subdirectories, lowercased and sorted
View findext.rb
#!/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