Skip to content
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
module OrderedModel
def up
self.class.update_all 'ord = ord + 1', "ord = #{self.ord-1}"
update_attribute :ord, self.ord-1
end
def down
self.class.update_all 'ord = ord - 1', "ord = #{self.ord+1}"
update_attribute :ord, self.ord+1
end
def dups(arr, i, j)
l_dups, r_dups = 0, 0
i.upto(j) do |n|
break if arr[n] != arr[i]
l_dups +=1
end
j.downto(i) do |n|
break if arr[n] != arr[j]
r_dups += 1
end
def setbits_count(s)
# bits map
bm = {"0" => 0, "1" => 1, "2" => 1, "3" => 2, "4" => 1, "5" => 2, "6" => 2, "7" => 3,
"8" => 1, "9" => 2, "A" => 2, "B" => 3, "C" => 2, "D" => 3, "E" => 3, "F" => 4}
sum = 0
0.upto(s.size-1) { |i| sum += bm[s[i]] }
sum
end
require 'rubygems'
require 'mechanize'
FILE = 'crawler.log'
a = Mechanize.new { |agent|
agent.user_agent_alias = 'Mac Safari'
}
a.get('http://www.com/') do |page|
Something went wrong with that request. Please try again.