Skip to content

Instantly share code, notes, and snippets.

View VanDavv's full-sized avatar

Łukasz Piłatowski VanDavv

View GitHub Profile
@VanDavv
VanDavv / initialize_db.py
Last active May 27, 2017 19:49
[Django] Script which initializes Your db with data You provided in Your settings.py (For PostgreSQL databases)
import logging
import psycopg2
from emily_backend import settings # pass Your settings here
db_config = settings.DATABASES.get('default')
logger = logging.getLogger(__name__)
try:
conn = psycopg2.connect(f""
@VanDavv
VanDavv / split.sh
Created May 3, 2017 16:10
Simple script for splitting long audio file into same length frangments
#!/bin/bash
LENGTH=300 # length in seconds
INPUT="./music.mp3" # path to input file
for i in {0..180..5}; do
ffmpeg -i $INPUT -t $LENGTH -ss $[$i * 60] -acodec copy "./$i.mp3"
done
@VanDavv
VanDavv / remove.sh
Created June 8, 2017 20:53
One-liner to remove docker containers that returned with non 0 code
docker rm $(docker ps -a --format "table {{.ID}}\t{{.Status}}" | grep -v "Exited (0)" | awk '{print $1}' | grep -v "CONTAINER")
@VanDavv
VanDavv / remove.sh
Created June 8, 2017 20:55
One-liner to remove docker images that were not labeled, resulting in label equal to '<none>'
docker rmi $(docker images | grep "<none>" | awk '{print $3}')
@VanDavv
VanDavv / download.sh
Created June 16, 2017 06:33
Script to download latest chrome driver
#!/bin/bash
PLATFORM=linux64 # Change this line if You're using other platform
VERSION=$(curl http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
curl http://chromedriver.storage.googleapis.com/$VERSION/chromedriver_$PLATFORM.zip -LOk
unzip chromedriver_*
rm chromedriver_*
@VanDavv
VanDavv / move.sh
Created August 4, 2018 08:42
Raspberry PI scripted mouse move
#!/bin/bash
sleep 20
export DISPLAY=':0.0'
while [ 1 ]; do
xdotool mousemove 677 382 click 1
xdotool mousemove 10000 10000
sleep 10
xdotool mousemove 940 390 click 1
xdotool mousemove 10000 10000
@VanDavv
VanDavv / main.py
Created August 25, 2019 10:49
Micro:bit catch or loose game
from microbit import display, Image, button_a, button_b, pin0, running_time
import random
class Utils:
@staticmethod
def deepcopy(arr):
return [row[:] for row in arr]
@staticmethod
@VanDavv
VanDavv / main.py
Created August 25, 2019 10:54
Micro:bit catch or loose game with counter
import random
import radio
from microbit import display, Image, button_a, button_b, pin0, running_time
class Utils:
@staticmethod
def deepcopy(arr):
return [row[:] for row in arr]
@VanDavv
VanDavv / main.py
Created August 25, 2019 10:55
Micro:bit two player shooter
import random
import radio
from microbit import display, Image, button_a, button_b, pin0, running_time
class Utils:
@staticmethod
def deepcopy(arr):
return [row[:] for row in arr]
@VanDavv
VanDavv / depthai-minimal.py
Created May 28, 2020 09:21
A simple script with simple DepthAI pipeline init and preview
import consts.resource_paths
import cv2
import depthai
if not depthai.init_device(consts.resource_paths.device_cmd_fpath):
raise RuntimeError("Error initializing device. Try to reset it.")
p = depthai.create_pipeline(config={
"streams": ["metaout", "previewout"],
"ai": {