This file contains 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 pygame | |
import math | |
import itertools as it | |
pygame.init() | |
screen = pygame.display.set_mode((500, 500)) | |
clock = pygame.time.Clock() | |
running = True | |
pos = (0, 0) |
This file contains 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
# General reference: https://docs.micropython.org/en/latest/rp2/quickref.html | |
# Accelerometer library: https://github.com/adafruit/Adafruit_CircuitPython_LIS331 | |
# Units (unless otherwise noted): | |
# Length: inches | |
# Time: minute | |
# Speed: inches per minute | |
from math import pi, sin, sqrt | |
from collections import namedtuple |
This file contains 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
# Simple ceasar cipher (1 line of logic) | |
from string import ascii_uppercase as au | |
s=int(input("Shift: ")) | |
print(''.join(map(dict(zip(au+' ',au[-s:]+au[:-s]+' ')).get,input("Text: ").upper()))) |
This file contains 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 com.ctre.phoenix.motorcotrol.can.WPI_TalonSRX; | |
import java.util.concurrent.TimeUnit; | |
class Main { | |
public static int LEFT_MOTOR1 = 9; | |
public static void main(String... args) { | |
WPI_TalonSRX m = new WPI_TalonSRX(LEFT_MOTOR1); | |
m.set(0.5); | |
TimeUnit.SECONDS.sleep(2); |
This file contains 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
pipe=type('',(),{'__ror__':lambda s,v:[setattr(s,'v',v),s][1],'__or__':lambda s,f:f(s.v)})() | |
# That's it. Really | |
if __name__ == '__main__': | |
# Example: | |
1 |pipe| (lambda x: x + 1) |pipe| print |
This file contains 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 curses | |
from random import randint | |
from time import sleep | |
from collections import deque | |
SNAKE_CHAR = '█' | |
APPLE_CHAR = '█' | |
MARGIN = 10 | |
movement_dict = { |
This file contains 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 curses | |
import decimal | |
from math import * | |
log = [] | |
def drange(start, stop, step): | |
start = decimal.Decimal(str(start)) | |
step = decimal.Decimal(str(step)) | |
while start < stop: |
This file contains 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
SCALE, Point, Drawer, run, run_lines = 25, type('Point', (), {'__init__': lambda self, x, y, z: [None, [setattr(self, a, b) for a, b in zip('x y z _x _y _z'.split(), [x, y, z, x*SCALE, y*SCALE, z*SCALE])]][0]}), type('Drawer', (__import__('turtle').Turtle,), {'go_home': lambda self: [self.pu(),self.home(),self.pd()],'go_to_point': lambda self, p: [self.home(),self.seth(150),self.fd(p._x),self.seth(30),self.fd(p._y),self.seth(90),self.fd(p._z)],'draw_line': lambda self, p1, p2: [self.pu(),self.go_to_point(p2),position := self.pos(),self.go_to_point(p1),self.pd(),self.goto(position)],'draw_shape': lambda self, *l: [self.draw_line(l[x - 1], l[x]) for x in range(len(l))]}), lambda t, i: {'pu': t.pu, 'pd': t.pd, 'gp': t.go_to_point, 'dl': t.draw_line, 'ds': t.draw_shape, 'ex': __import__('sys').exit, 'cl': t.reset}.get(i[:2], lambda *a: print('?'))(*([Point(*[float(y.strip()) for y in x.split(',')]) for x in i[2:].split(';')] if len(i) != 2 else [])), lambda s: [t := Drawer(), t.speed(0), [run(t, w) for x in s.spl |
This file contains 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 re | |
import operator as op | |
import copy | |
class box: | |
__slots__ = ("obj",) | |
def __init__(self, obj): | |
self.obj = obj | |
def __repr__(self): | |
return f"<box {self.obj}:{type(self.obj)}>" |
This file contains 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 set of modules which emulate the standard library of Elixir in Python." | |
__version__ = '0.0.2' | |
import time | |
import math | |
import operator | |
from inspect import signature | |
import random |
NewerOlder