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 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 |
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
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"> | |
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 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 |
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 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): |
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
<!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&distil_RID=D193A2F2-7BCB-11E4-9F20-DC7D289AB193&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> |
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
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 |
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 '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 |
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
# totally fine | |
Sequel.|( | |
Sequel.expr(:last_sent) < Time.now - repeat_threshold, | |
Sequel.expr(:last_sent) => nil | |
), | |
# instant runtime error |
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 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 |
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
/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) |
NewerOlder