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 SpecialistSectorTagForm; attr_writer :tag; end | |
Tag.where(tag_type: 'specialist_sector').each do |tag| | |
tag_form = SpecialistSectorTagForm.new({}) | |
tag_form.tag = tag | |
tag_form.save | |
puts "Successfully saved tag #{tag.tag_id}" | |
end |
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
{"index":{"_id":"jobs-exact","_type":"best_bet"}} | |
{"exact_query":"jobs","details":"{\"best_bets\":[{\"link\":\"/jobs1\",\"position\":1},{\"link\":\"/jobs2\",\"position\":2}],\"worst_bets\":[]}"} | |
{"index":{"_id":"vias-exact","_type":"best_bet"}} | |
{"exact_query":"vias","details":"{\"best_bets\":[],\"worst_bets\":[{\"link\":\"/it-is-a-link\"}]}"} |
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
unsub_info = [ | |
["DetailedGuide", "harbour-development-and-the-law"], | |
["DetailedGuide", "disposal-of-dredged-material-at-sea-regulations-and-controls"], | |
["DetailedGuide", "offshore-cables-and-pipelines"], | |
["DetailedGuide", "marine-construction-and-coastal-protection"], | |
["DetailedGuide", "licences-for-offshore-renewable-energy-installations"], | |
["DetailedGuide", "european-fisheries-fund-fishing-industry-common-interests"], | |
["DetailedGuide", "european-fisheries-fund-projects"], | |
["DetailedGuide", "investing-in-aquaculture"], | |
["DetailedGuide", "investing-on-board-your-fishing-vessel"], |
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 read_only_collection(section_name) | |
get "/#{section_name}" do | |
haml "#{section_name}/index".to_sym | |
end | |
get "/#{section_name}/:object_name" do | |
begin | |
haml "#{section_name}/#{params[:object_name]}".to_sym | |
rescue Errno::ENOENT | |
throw :halt, [404, "Not found"] |
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
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
class Archive | |
def initialize(starting_url) | |
@pages = [first_page = Page.new(starting_url)] | |
add_links_from(first_page) | |
end |
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
require 'fixnum' | |
describe Fixnum, 'when converting to Roman numerals' do | |
context "up to 5" do | |
it "represents units with I" do | |
1.to_roman_numerals.should == 'I' | |
2.to_roman_numerals.should == 'II' | |
3.to_roman_numerals.should == 'III' | |
end |
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 Fixnum | |
def to_roman_numerals | |
tens, remainder = self.divmod(10) | |
fives, units = remainder.divmod(5) | |
('X'*tens) + ('V'*fives) + ('I'*units) | |
end | |
end |
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
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
class IMDBRank | |
def self.rank(directory, number_to_return=10) | |
Dir["#{File.expand_path(directory)}/*.{avi,mp4,m4v}"].sort.map do |filepath| | |
File.basename(filepath) =~ /(.*?)(?:\s+.(\d{4}).)?\....$/ | |
new($1, $2) | |
end.reject { |film| film.score.nil? }. |
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
# Fuck you and your fucking divs | |
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | |
include ActionView::Helpers::OutputSafetyHelper | |
raw %(<span class="field-with-errors">#{html_tag}</span>) | |
end |
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
require 'open-uri' | |
open('http://podcast.timesonline.co.uk/rss/thebuglemp3.rss').each_line do |line| | |
next unless line =~ /(http.*?\.mp3)/ | |
system "wget #{$1}" | |
end |
OlderNewer