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 weakref | |
| class Cached(type): | |
| """ | |
| Metaclass. | |
| Only allows the creation of one type of instance, all other instances | |
| with the same initialization variables return the same instance of the | |
| first creation. | |
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 Singleton(type): | |
| """ | |
| Metaclass. | |
| Only allows the creation of one instance, all other tries return | |
| the same instance of the first creation. | |
| Use: | |
| class Test(metaclass=Singleton): | |
| ... | |
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 functools | |
| import inspect | |
| import time | |
| import cProfile | |
| import time | |
| from contextlib import contextmanager | |
| import pstats | |
| import sys | |
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 | |
| echo "PIP PACKAGE UPDATER" | |
| going=true | |
| while $going | |
| do | |
| read -n 1 -p "`echo $'\n[1] Force update all packages'``echo $'\n[2] Check for updates'``echo $'\n[5] Update packages considering dependencies'``echo $'\n[9] Force reinstall all packages'``echo $'\n[Q] Quit'``echo $'\n> '`" ans; | |
| echo $'\n' | |
| case $ans in | |
| 1) | |
| echo $'Force updating all packages...\n' |
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
| { | |
| "editor.cursorBlinking": "phase", | |
| "editor.fontFamily": "Fira Code Retina, 'Courier New', monospace", | |
| "editor.fontLigatures": true, | |
| "editor.fontSize": 16, | |
| "editor.minimap.enabled": false, | |
| "editor.suggestSelection": "first", | |
| "extensions.autoUpdate": false, | |
| "files.exclude": { | |
| "**/.pyc": true, |
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
| # time everything precisely | |
| from time import perf_counter_ns | |
| from multiprocessing import Pool | |
| from functools import partial | |
| def persistance(n, minimum=10, sequence=False): | |
| if sequence: | |
| print(f"Started with {n}") | |
| depth = persinstence_rec(n, sequence=sequence) | |
| # only print numbers with a persistance greater than 10 |
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 | |
| from contextlib import contextmanager | |
| @contextmanager | |
| def time_this(label): | |
| start = time.perf_counter_ns() | |
| try: | |
| yield | |
| finally: |
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
| """ | |
| A* pathfinding starcraft in python | |
| How can I optimize create_path? | |
| """ | |
| import heapq | |
| import random | |
| import time | |
| import sc2 | |
| from sc2 import Race, maps, run_game |
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
Show hidden characters
| { | |
| "colors": { | |
| "activityBar.background": "#1E2428", // standard background | |
| "activityBar.border": "#000000", // standard border | |
| "activityBar.dropBackground":"#3E4246", // drag and drop | |
| "activityBar.foreground": "#dcdcdc", | |
| "activityBar.inactiveForeground": "#BCBDBE", | |
| "activityBarBadge.background": "#0F1519", | |
| "activityBarBadge.foreground": "#dcdcdc", | |
| "badge.background": "#3E4246", |
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 glob | |
| import os | |
| total_code_lines = 0 | |
| total_blank_lines = 0 | |
| total_comment_lines = 0 | |
| total_functions = 0 | |
| total_async_functions = 0 | |
| total_classes = 0 | |
| file_count = 0 |
NewerOlder