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
elsif ors? | |
case param_id | |
when 'or', 'ors', 'ors_', 'ors_about' | |
return ORS_ROOT | |
when /^nrs_/ | |
return NRS_ROOT + '/' + param_id | |
when /^tex\._/ | |
return TEXAS_STATUTES_ROOT + '/' + param_id |
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
board = ["R", "N", "B", "Q", "K", "B", "N", "R","P", "P", "P", "P", "P", "P", "P", "P"," ", " ", " ", " ", " ", " ", " ", " "," ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " "," ", " ", " ", " ", " ", " ", " ", " ","p", "p", "p", "p", "p", "p", "p", "p","r", "n", "b", "q", "k", "b", "n", "r"] | |
def Print_board(): | |
x = 0 | |
y = 0 | |
while y < 8: | |
print("\n") | |
while x < 8: | |
print(board[x] + " ", 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
def parse_title(dom: XmlResponse) -> Title: | |
name = pipe( | |
dom | |
, html.xpath("//TITLE-TEXT") | |
, text.titleize | |
) | |
number = pipe( | |
dom | |
, html.xpath("//TITLE-NUM") | |
, text.split(" ") |
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
async function handleRequest(request) { | |
// Is the visitor in the VIP list? | |
let data = request.cf | |
let visitor_asn = data.asn | |
// Query the KV database | |
let network_name = await VIP_API_ASN.get(visitor_asn) | |
// Create the HTTP header value | |
let is_vip = (network_name !== null) |
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 css(selector) | |
html.css(selector).text | |
end | |
def html | |
Nokogiri::HTML(response.body) | |
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
# | |
# Original | |
# | |
dl_lists: list[Any] = html.css("main dl") | |
if len(dl_lists) > 0 and isinstance(dl_lists[0], Selector): | |
first_dl_list = dl_lists[0] | |
else: | |
raise ParseException("Expected a <dl>") |
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
# Original | |
def first(node, css, expected): | |
result = str(node.css(css).get()) | |
if result is None: | |
raise ParseException(f"Could not parse the {expected}") | |
return result | |
# Refactored | |
def first(node, css, expected) -> str: |
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
# | |
# Original | |
# | |
error: Argument 1 to "assert_never" has incompatible type "Literal[Color.BLUE]"; | |
expected "NoReturn" | |
# | |
# Refactored | |
# |
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
from enum import Enum | |
class Color(Enum): | |
RED = "RED" | |
GREEN = "GREEN" | |
BLUE = "BLUE" # I just added this | |
def handle_color(color: Color): |
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 get_float(num: str | float): | |
match (num): | |
case str(num): | |
return float(num) |
NewerOlder