Skip to content

Instantly share code, notes, and snippets.

View danya02's full-sized avatar

Danya Generalov danya02

View GitHub Profile
import subprocess
import random
ROOM_SIZE = 100
xb = random.randint(0, ROOM_SIZE)
yb = random.randint(0, ROOM_SIZE)
xs = random.randint(0, ROOM_SIZE)
ys = random.randint(0, ROOM_SIZE)
print("Open prog")
@danya02
danya02 / guide.md
Created April 25, 2022 19:19
Руководство по Markdown для самых маленьких

Руководство по Markdown для самых маленьких

Версия v0.1

Версия Что нового
0.1 Первый релиз

(Это руководство тоже написано на Markdown! Откройте исходный код, чтобы узнать как это сделано!)

@danya02
danya02 / organize.py
Created August 1, 2020 20:10
Organize files into directories based on their filename prefixes, like "./he/hell/helloworld.txt"
import os
def organize(dir, prefix_len):
last_cwd = os.getcwd()
os.chdir(dir)
existing_dirs = set()
find = os.popen('find -type f')
for line in find:
filename = line[2:].strip()
@danya02
danya02 / magictime.moscow.py
Created January 19, 2020 13:21
LED display thing Python control code. Yes.
import requests
import re
base = 'http://magictime.moscow/'
obl_params = {'controller': 'stel', 'stel_key':'eccbc87e4b5ce2fe28308fd9f2a7baf3'}
useragent = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1'
def request(method, params, **kwargs):
params.update(obl_params)
ans = requests.request(method, base, params=params, headers={'user-agent':useragent}, **kwargs)
@danya02
danya02 / turtle1.ino
Created February 12, 2017 14:06
Arduino turtle avoidance program
#include <Servo.h>
#include <Ultrasonic.h>
Servo servo;
Ultrasonic ultrasonic(13,12);
int l=0;
int r=0;
void forward() {
digitalWrite(5, 1);
digitalWrite(7, 1);
digitalWrite(6, 0);
@danya02
danya02 / mirrors.py
Last active September 18, 2016 13:16
#!/usr/bin/python3
import random
magic = { # some automagical codes
"start_line": "\r",
"clear_line": "\033[K"}
matrixa_init=[]
matrixb_init=[]
for i in range(1,18):
matrixa_init+=[i]
matrixb_init+=[i]
@danya02
danya02 / but_test2.py
Last active August 8, 2016 08:31
The code for the button-detecting circuit that people can understand.
import gpiozero
import threading
import time
b=gpiozero.Button(21)
global presses
global prss
global timed
presses=0
prss=0
timed=False
@danya02
danya02 / pip3-freeze_output.txt
Last active June 29, 2016 13:36
output of 'pip3 freeze' on danya02's new machine
Pillow==2.6.1
RPi.GPIO==0.6.2
RTIMULib==7.2.1
certifi==2016.2.28
chardet==2.3.0
colorama==0.3.2
future==0.15.2
gpiozero==1.2.0
html5lib==0.999
mcpi==0.1.1
@danya02
danya02 / binary_clock.py
Last active July 25, 2020 17:05
Binary clock using a RPi and a Sense HAT.
#!/usr/bin/env python
from sense_hat import SenseHat
import time, datetime
hat = SenseHat()
year_color = (0, 255, 0)
month_color = (0, 0, 255)
day_color = (255, 0, 0)