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
| class Player(object): | |
| # Class Attributes, tracking all players | |
| players = {} | |
| id_player_names = {} # Just something to help you track id to players | |
| last_id = 0 | |
| def __init__(self, name=None, height = 0, weight = 0 , bmi =0): | |
| # Player attributes, tracking a player's stats |
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 time | |
| import pandas as pd | |
| def string_to_csv(string: str, csv_output_name: str): | |
| row_gen = (x.split("=") for x in string.split(';')) | |
| df = pd.DataFrame(row_gen) | |
| df['index'] = df.groupby(0).cumcount() |
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 functools import partial | |
| alphabet = 'abcdefghijklmnopqrstuvwxyz' | |
| alphabet_dict = {letter: order + 1 for order, letter in enumerate(alphabet)} | |
| alphabet_dict_reversed = {order: letter for letter, order in alphabet_dict.items()} | |
| def encrypt_text(text: str, shift: int, decrypt: bool = False): | |
| shift_n = (shift * (-1 if decrypt else 1)) # Useful line to switch to decryption | |
| encrypted_text = [ |
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
| """ | |
| Keras and talos using Mnist as toy example | |
| """ | |
| import talos | |
| from keras import Sequential | |
| from keras.activations import relu, elu, tanh, softmax | |
| from keras.layers import Conv2D, BatchNormalization, MaxPool2D, Flatten, Dense, Dropout | |
| from keras.losses import logcosh, binary_crossentropy | |
| from keras.optimizers import Adam, RMSprop |
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 sys | |
| import cv2 | |
| import numpy as np | |
| import xlsxwriter | |
| if len(sys.argv) != 4: | |
| print("That's not how it works") | |
| sys.exit(404) |
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
| # Implement a hashmap in Python without using a dictionary | |
| # A simple toy example, look to improve when the hashes start clashing with each other either by adapting a dynamic size | |
| # Or using a better hash function | |
| class HashMap(object): | |
| def __init__(self, size, hash_function): | |
| self.array = [None] * size | |
| self.size = size |
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 sum_bits(larger, smaller): | |
| """ Sum but using bits, only positive numbers""" | |
| top_down_sum = larger ^ smaller | |
| carry = (larger & smaller) << 1 | |
| if carry > 0: | |
| return sum_bits(top_down_sum, carry) | |
| return top_down_sum | |
| def sub_bits(larger, smaller): |
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 calendar | |
| import re | |
| from datetime import datetime | |
| from urllib.parse import urljoin, urlparse, parse_qs | |
| import pandas as pd | |
| import requests | |
| from bs4 import BeautifulSoup | |
| USED_BIKE_SEARCH_URL = "https://sgbikemart.com.sg/listing/usedbikes/listing/?bike_model=Honda+MSX125&bike_type=&price_from=&price_to=&license_class=2B®_year_from=1970®_year_to=2024&monthly_from=&monthly_to=&user=&status=10&category=" |
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
| #!/usr/bin/env bash | |
| set -euo pipefail | |
| DESCRIPTION="Convert an input file of {csv, parquet, json} format to {csv, parquet, json} format using Polars" | |
| VERBOSE=false | |
| usage() { | |
| echo "Usage: $0 <input_file> -f <output_format> [-o <output_file>] [-v]" | |
| echo " <input_file>: Path to the input file" |