- color_eyre
This file contains hidden or 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
| df_true: | |
| id dates year epiweek ... train_1 train_2 target_1 target_2 | |
| 0 3614204 2022-06-12 2022 202224 ... True True False False | |
| 0 3617405 2022-06-19 2022 202225 ... True True False False | |
| 0 3625692 2022-06-26 2022 202226 ... True True False False | |
| 0 3628534 2022-07-03 2022 202227 ... True True False False | |
| 0 3636802 2022-07-10 2022 202228 ... True True False False | |
| .. ... ... ... ... ... ... ... ... ... | |
| 0 3586758 2022-05-08 2022 202219 ... True True False False | |
| 0 3592058 2022-05-15 2022 202220 ... True True False False |
This file contains hidden or 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 datetime import datetime as dt | |
| calculate_age = ( | |
| lambda bd: ( | |
| (td := dt.today()) and (td.year - bd.year - ((td.month, td.day) < (bd.month, bd.day))) | |
| )) | |
| print(f"{calculate_age(dt(1990, 5, 21))}yo") |
This file contains hidden or 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
| use std::marker::Copy; | |
| fn main() { | |
| let r1 = Retangle { | |
| width: 50, | |
| height: 30.5, | |
| }; | |
| println!("{:?}", r1.get_area()) | |
| } |
This file contains hidden or 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
| fn print_type<T>(_: &T) { | |
| println!("{}", std::any::type_name::<T>()) | |
| } |
This file contains hidden or 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
| import unicodedata | |
| def normalize_str(string: str) -> str: | |
| non_ascii = ( | |
| unicodedata.normalize("NFKD", string).encode("ascii", "ignore").decode() | |
| ) | |
| string = non_ascii.lower().replace(" ", "_") | |
This file contains hidden or 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 socket import * | |
| def createServer(): | |
| serversocket = socket(AF_INET, SOCK_STREAM) | |
| try: | |
| serversocket.bind(('localhost',9000)) | |
| print('Starting server at http://127.0.0.1:9000/') | |
| serversocket.listen(5) | |
| while(1): | |
| (clientsocket, address) = serversocket.accept() |
This file contains hidden or 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 datetime import datetime | |
| import calendar | |
| def calc_last_month_range(date: datetime) -> tuple: | |
| if date.month == 1: | |
| ini_date = datetime(date.year - 1, 12, 1) | |
| else: | |
| ini_date = datetime(date.year, date.month - 1, 1) | |
| end_date = datetime( |
This file contains hidden or 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
| import bisect | |
| import random | |
| # bisect() | |
| def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'): | |
| i = bisect.bisect(breakpoints, score) | |
| return grades[i] | |
| [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]] | |
| # ['F', 'A', 'C', 'C', 'B', 'A', 'A'] |
This file contains hidden or 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 next_(n, x): | |
| return (x + n / x) / 2 | |
| # Repeats infinitely | |
| def repeat(f, a): | |
| yield a | |
| for v in repeat(f, f(a)): | |
| yield v | |
| # Delimiter |
NewerOlder