Skip to content

Instantly share code, notes, and snippets.

View techieji's full-sized avatar

Pradhyum R techieji

View GitHub Profile
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)
@techieji
techieji / stw.py
Created June 3, 2023 18:41
Robot code
# 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
# 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())))
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);
@techieji
techieji / pipes.py
Created January 12, 2022 03:28
Oneline piping definition
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
@techieji
techieji / snake.py
Created October 29, 2021 02:28
Snake ... for terminal!
import curses
from random import randint
from time import sleep
from collections import deque
SNAKE_CHAR = '█'
APPLE_CHAR = '█'
MARGIN = 10
movement_dict = {
@techieji
techieji / termplot.py
Created October 19, 2021 00:26
A plotter... for terminal!
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:
@techieji
techieji / iso.py
Last active October 5, 2021 22:50
A 3d drawer
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
@techieji
techieji / lisp.py
Created October 25, 2020 21:15
lisp.py
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)}>"
@techieji
techieji / elixpy.py
Created August 17, 2020 22:19
elixpy.py
"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