View marc-search.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'optparse' | |
CMD = File.basename __FILE__ | |
def usage | |
"Usage: #{CMD} [OPTIONS] TAG [CODE...] FILE [FILE...]" | |
end |
View Walters TEI surfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Jun 28 2013 W4_tei.xml <surface n="Upper board outside" xml:id="n348.022200"><graphic url="master/W4_000001_1200.tif" xml:id="n348.022201"/> | |
Jun 28 2013 W7_tei.xml <surface n="Upper board outside" xml:id="n352.028025"><graphic url="master/W7_000001_1022.tif" xml:id="n352.028026"/> | |
Jun 28 2013 W12_tei.xml <surface n="Upper board outside" xml:id="n357.048799"><graphic url="master/W12_000001_1200.tif" xml:id="n357.048800"/> | |
Jun 28 2013 W13_tei.xml <surface n="Upper board outside" xml:id="n471.035784"><graphic url="master/W13_000001_1200.tif" xml:id="n471.035785"/> | |
Jun 28 2013 W18_tei.xml <surface n="Upper board outside" xml:id="n342.010960"><graphic url="master/W18_000001_700.tif" xml:id="n342.010961"/> | |
Jun 28 2013 W26_tei.xml <surface n="Upper board outside" xml:id="n360.007143"><graphic url="master/W26_000001_1200.tif" xml:id="n360.007144"/> | |
Jun 28 2013 W30_tei.xml <surface n="Upper board outside" xml:id= |
View incremental_web_mv.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# IMPORTANT: this script assumes that are no spaces in any of your paths | |
# create a dir list this way: | |
# | |
# $ find /path/to/source/directories -type d -name web | grep -v extra > /path/to/list-of-web-directories.txt | |
# | |
# This command will find all directories (-type d) named 'web' -- but not | |
# the ones in the `extra` folders -- and redirect all that to a file listing |
View gssapi-with-mic.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rsync -Cavz -e 'ssh -p 1234 -i $HOME/.ssh/id_dsa' usernam@host.com:path/to/files/*.txt . | |
Permission denied (publickey,gssapi-with-mic). | |
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] | |
rsync error: unexplained error (code 255) at io.c(601) [Receiver=3.0.8] |
View hg merge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# switch to the named branch | |
$ hg update -C my_branch | |
# write some code and commit the changes | |
$ hg commit | |
# switch to default | |
$ hg update -C default | |
# merge the revised code from the branch |
View where_does_it_go.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def magical_solution_to_all_your_problems(*args) | |
# do something critical | |
end |
View deletable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/deletable.rb | |
ActiveRecord::Base.class_eval do | |
before_destroy :check_deletable | |
def self.undeletable_if_used(by_hash) | |
unless by_hash[:by] | |
raise "Expected hash to have key :by and a value of one or more symbols" | |
end | |
define_method(:deletable?) do | |
![by_hash[:by]].flatten.detect { |a| |
View destroy_tag.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def destroy_tag(object) | |
if current_user.admin? | |
if object.deletable? | |
link_to('Destroy', object, :confirm => 'Are you sure?', | |
:method => :delete) | |
else | |
"[Item used]" | |
end | |
end | |
end |
View deletable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.undeletable_if_used(by_hash) | |
unless by_hash[:by] | |
raise "Expected hash to have key :by and a value of one or more symbols" | |
end | |
define_method(:deletable?) do | |
![by_hash[:by]].flatten.detect { |a| | |
if self.respond_to? "#{a.to_s}_count" | |
self.send("#{a.to_s}_count") > 0 | |
else | |
self.send(a.to_s).count |
View deletable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Category < ActiveRecord::Base | |
before_destroy :check_deletable | |
has_many :tasks | |
has_many :projects | |
# ... | |
end | |
class Task < ActiveRecord::Base |
NewerOlder