Skip to content

Instantly share code, notes, and snippets.

View tweakimp's full-sized avatar
🏠
Working from home

FW tweakimp

🏠
Working from home
View GitHub Profile
@tweakimp
tweakimp / printColumns.py
Created January 21, 2018 22:32
Python: Print a list in columns
testlist = ['A2 White Pawn', 'B2 White Pawn', 'C2 White Pawn', 'D2 White Pawn',
'E2 White Pawn', 'F2 White Pawn', 'G2 White Pawn', 'H2 White Pawn',
'A7 Black Pawn', 'B7 Black Pawn', 'C7 Black Pawn', 'D7 Black Pawn',
'E7 Black Pawn', 'F7 Black Pawn', 'G7 Black Pawn', 'H7 Black Pawn',
'B1 White Knight', 'G1 White Knight', 'B8 Black Knight',
'G8 Black Knight', 'C1 White Bishop', 'F1 White Bishop',
'C8 Black Bishop', 'F8 Black Bishop', 'A1 White Rook',
'H1 White Rook', 'A8 Black Rook', 'H8 Black Rook',
'D1 White Queen', 'D8 Black Queen', 'E1 White King',
'E8 Black King']
@tweakimp
tweakimp / theme.jsonc
Last active September 20, 2019 06:19
theme.json
{
"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",
@tweakimp
tweakimp / distribute_workers.py
Last active October 18, 2018 06:48
New distribute workers?
async def scv_distribute_workers(self):
workers_to_distribute = [scv for scv in self.scvs.idle]
workers_must_distribute = [scv for scv in self.scvs.idle]
deficit_bases = []
deficit_refineries = []
mining_bases = self.get_mining_bases()
refinery_tags = {
ref.tag
for ref in self.units(REFINERY).ready.filter(
lambda ref: any([ref.position.distance_to_point2(base.position) <= 10 for base in mining_bases])
@tweakimp
tweakimp / line_count.py
Last active January 16, 2019 15:23
code statistics
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
@tweakimp
tweakimp / theme.jsonc
Created October 16, 2018 20:36
VS Code Theme
{
"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",
@tweakimp
tweakimp / a_star.py
Last active December 17, 2018 21:12
A* pathfinding in starcraft
"""
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
@tweakimp
tweakimp / time_this.py
Last active September 25, 2019 17:00
Time code blocks
import time
from contextlib import contextmanager
@contextmanager
def time_this(label):
start = time.perf_counter_ns()
try:
yield
finally:
@tweakimp
tweakimp / multiplicative_persistance.py
Last active April 29, 2019 17:38
multiplicative persistance
# 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
@tweakimp
tweakimp / settings.json
Last active December 28, 2019 09:38
vscode settings
{
"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,
@tweakimp
tweakimp / pip_updater.sh
Created September 24, 2019 05:36
pip updater
#!/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'