Skip to content

Instantly share code, notes, and snippets.

@jamespenguin
jamespenguin / wiki_scraper
Created April 10, 2015 06:03
The greatest wiki scraper ever made.
#!/usr/bin/env python -S
#
# Wikipedia Sentence Scraper
#
# This script requires the Wikipedia module to run (https://pypi.python.org/pypi/wikipedia/)
# If you have pip installed, just run
# pip install wikipedia
#
import re
import threading
1.9.3-p385 :001 > require 'sqlite3'
=> true
1.9.3-p385 :002 > require 'sequel'
=> true
1.9.3-p385 :003 > db = Sequel.connect('sqlite://blah.db')
=> #<Sequel::SQLite::Database: "sqlite://blah.db">
def is_divisible(number):
for i in range(1, 21):
if number % i != 0:
return False
return True
i = 19
while not is_divisible(i):
i += 1
print i
def is_palindrome(number):
s = str(number)
r = list(s)
r.reverse()
return "".join(r) == s
results = []
for num_1 in range(999, 99, -1):
for num_2 in range(999, 99, -1):
if is_palindrome(num_1 * num_2):
<!DOCTYPE html>
<head>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="refresh" content="10; url=/distil_r_blocked.html?Ref=/yugioh/crimson-crisis/necroface?partner=YGOPRCS&amp;distil_RID=D193A2F2-7BCB-11E4-9F20-DC7D289AB193&amp;distil_TID=20141204154005" />
<script type="text/javascript" src="/ga.17411289363684.js?PID=14CDB9B4-DE01-3FAA-AFF5-65BC2F771745" defer></script><style type="text/css">#d__fFH{position:absolute;top:-5000px;left:-5000px}#d__fF{font-family:serif;font-size:200px;visibility:hidden}#reputation5ef4a18a,#emotion3671976d,#categoryec2e7d0c,#emotion3671976d{display:none!important}</style></head>
get '/api/rising_and_falling' do
begin
data = CardPrices.success({"rising" => CardPrices::PriceStats.top_rising_cards,
"falling" => CardPrices::PriceStats.top_dropping_cards})
rescue
data = CardPrices.error "Failed to retrieve rising and falling price data."
end
content_type :json
return data.to_json
require 'json'
require 'awesome_print' # this is an external gem and you'll need to install it with the command "gem install awesome_print"
file_path = "monster_cards.json"
data = JSON.parse File.read file_path
card_name = "Raigeki"
ap data["R"][card_name] # If you have awesome print
puts data["R"][card_name] # If you don't have awesome print
# totally fine
Sequel.|(
Sequel.expr(:last_sent) < Time.now - repeat_threshold,
Sequel.expr(:last_sent) => nil
),
# instant runtime error
class Series < Sequel::Model(:series)
one_to_many :chapters
def validate
validates_unique :title
validates_format /([0-9]{4})?/, :year
# validates_type TrueClass, :available
# validates_type TrueClass, :completed
/opt/rvm/gems/ruby-2.1.1/gems/sequel-4.9.0/lib/sequel/model/base.rb:1441:in `save': available is not a valid trueclass, completed is not a valid trueclass (Sequel::ValidationFailed)