Skip to content

Instantly share code, notes, and snippets.

import os
import tkinter as tk
import random
from collections import namedtuple
WIDTH, HEIGHT = 300, 300
PROG = WIDTH//10
root = tk.Tk()
canvas = tk.Canvas(root, width=WIDTH, height=HEIGHT, bg='white')
img = tk.PhotoImage(width=WIDTH, height=HEIGHT)
import json
class DispatcherBase:
switch = 'what'
def __call__(self, act):
if not isinstance(act, dict):
act = json.loads(act)
what = act.pop(self.switch, None)
#!/usr/bin/env python3
import wmi, time
def watch():
c=wmi.WMI()
pss = c.query("select WorkingSetSize from win32_Process"
" where Name='chrome.exe'")
killed = [p.Terminate(0) for p in pss if int(p.WorkingSetSize) > 1800*1e6]
@Sorseg
Sorseg / problem.py
Created September 9, 2015 00:16
Mocking await calls in python 3.5 is a problem
async def some_coroutine():
await another_coroutine()
async def another_coroutine():
pass
import os
def cat(f):
return open(f).read()
def ls():
return os.listdir('.')
def pwd():
return os.getcwd()
from droidhelper import DroidHelper
import socket
import struct
import time
SMOOTH = 2
COEFF = 10000/20.0/SMOOTH
readings = [0] * SMOOTH
ind = 0
import turtle
from collections import namedtuple
from math import sin
from random import choice, randint as ri
import time
WIDTH_BASE = [1, 10]
WIDTH_PERIOD = [1, 100]
WIDTH_AMP = [0, 20]
@Sorseg
Sorseg / dev_install.sh
Created May 9, 2024 15:12
Steamos development tools installation
steamos-readonly disable
pacman-key --init
pacman-key --populate archlinux
pacman-key --refresh-keys
pacman -Sy base-devel openssl
steamos-readonly enable