Skip to content

Instantly share code, notes, and snippets.

unity and python is all a man needs

Badjano badjano

unity and python is all a man needs
View GitHub Profile
badjano /
Created Dec 30, 2021
Script de rateio de gastos em python
names = ["Fulano", "Sicrano", "Beltrano"]
costs = [397.03, 199.42, 0]
individual_cost = sum(costs) / len(costs)
costs_str = "\n".join([f"{a} gastou R${b}" for a, b in zip(names, costs)])
print(f"Sabendo que:\n{costs_str}\n")
print(f"E que o custo total foi R${sum(costs):.02f}\ne o individual foi R${individual_cost:.02f}\n")
for n, c in zip(names, costs):
specific_cost = individual_cost - c
word = "receber" if specific_cost < 0 else "pagar"
print(f"{n} deve {word}: R${abs(specific_cost):.02f}")
badjano /
Last active Dec 6, 2021
Converts all video from a folder to much smaller ones in another folder
import os
from glob import glob
from moviepy.editor import *
from tkinter import Tk
from tkinter.filedialog import askdirectory
from include.colors import Colors
def get_filename(file_path):
return file_path.split(os.sep)[-1]
badjano /
Created Nov 23, 2021
Make wacom tablet preserve aspect ratio
SIZE=`xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/'`
echo "SIZE: $SIZE"
echo "WIDTH: $WIDTH"
WACOM_SIZE=`xsetwacom get 11 Area`
import numpy as np
import cv2
from PIL import ImageGrab
from screeninfo import get_monitors
monitors = []
for m in get_monitors():
monitors.append((m.x, m.y, m.x + m.width, m.y + m.height))
bbox = monitors[0]
import datetime
class Range:
def __init__(self, start, end):
self.start = min(start, end)
self.end = max(start, end)
self.empty = self.start == self.end
self.log = False
import numpy as np
from PIL import Image
arr = np.random.rand(256, 256, 4) * 255
img = Image.fromarray(arr.astype('uint8'), mode="RGBA")"random_img.png")
badjano /
Created Mar 2, 2021
I shell script for installing fbcp-ili9341 with square screen cropping
sudo apt-get install cmake
cd ~
#git clone # original repo
git clone # my modified repo for square screen cropping
cd fbcp-ili9341
mkdir build
cd build
make -j
sudo install ./fbcp-ili9341 /usr/local/bin/fbcp
badjano /
Created Feb 28, 2021
Mouse and keyboard control for raspberry pi LCD HAT ST7735S
from pymouse import PyMouse
import time
import RPi.GPIO as GPIO
btn_up = 5
btn_down = 26
btn_left = 19
btn_right = 6
badjano /
Last active Feb 24, 2021
A class with persistent data
import json
import os
import pickle
import random
import uuid
class PersistentClass:
reserved_keys = ["__dict__", "filename", "debug", "autosave", "file_ext"]
badjano / favorites.txt
Last active Feb 20, 2021
My Pico-8 favorites
View favorites.txt
|46281 |42655 |1794 |ultrabrite | |sewers of d'oh!
|nightride-0 |nightride |1794 |vladcom | |night ride
|toyrogue-0 |toyrogue |1794 |extar | |toyrogue 1.0
|metrash-2 |metrash |1794 |st33d | |metrash
|pakpok-0 |pakpok |1794 |st33d | |pakpok
|cgprospector-0 |cgprospector |1794 |st33d | |cgprospector
|celeste_classic_2-5 |celeste_classic_2 |1794 |noel | |celeste classic 2
|dollarone_nightatthemuseum-0 |dollarone_nightatthemuseum |1794 |dollarone | |dollarone_nightatthemuseum
|picpots-0 |picpots |1794 |enrohk | |picpots
|flipknight-0 |flipknight |1794