Skip to content

Instantly share code, notes, and snippets.

@rubenhorn
rubenhorn / conda_snippets.md
Last active May 26, 2021 12:57
The following snippets can be used to build a (cross platform) script to manage a local Anaconda environment by anyone.

Conda snippets

The following snippets can be used to build a cross platform script to manage a local Anaconda environment by anyone.

Create new environment

conda create -y -p ./.env python=3.9 && conda activate ./.env

Deactivate environment

conda deactivate

Remove environment

@rubenhorn
rubenhorn / list-videos.py
Last active March 18, 2021 15:29
A script to process youtube playlist takeout
#!/usr/bin/python3
import os, sys, requests, re, html
banner = '''
#==================================================
# A script to process youtube playlist takeout
#==================================================
'''
print(banner)
@rubenhorn
rubenhorn / summon_window.ahk
Last active January 30, 2024 10:29
AutoHotkey script for moving active window to main monitor
#SingleInstance force
; Hotkey: Alt + S
!s::
; Check if window active window exists
WinGetTitle, t, a
if(t = "Program Manager" or t = "") {
MsgBox ,, No window selected!, Please select a window.`n(Alt + Tab)
return
@rubenhorn
rubenhorn / retrolink-nes-controller.js
Created December 10, 2020 09:49
Function for reading input from Retrolink NES controller (https://www.gadgetreview.com/retrolink-usb-nes-controller-review) in the browser
@rubenhorn
rubenhorn / mnist_demo.py
Last active August 16, 2020 17:27
Neural network digit recognition example with GUI
# Based on https://www.tensorflow.org/datasets/keras_example
# Requires numpy, pygame, tensorflow and tensorflow-datasets
NUMBER_OF_EPOCHS = 8
import numpy as np
import pygame
pygame.init()
pygame.display.set_caption('MNIST digits')
@rubenhorn
rubenhorn / tic_tac_toe.py
Last active August 13, 2020 14:45
Simple RL-TicTacToe game written in python (change the variable of player_1 and player_2 in line 190 and 191 to human_player to play against the AI)
#!/usr/bin/env python3
import os, re, random, copy, sys, atexit
clear = lambda: os.system('cls' if os.name == 'nt' else 'clear')
def print_header():
print(' _____ _ _____ _____ ')
print(' |_ _(_)_|_ _|_ _ _|_ _|__ ___ ')
print(' | | | / _|| |/ _` / _|| |/ _ \/ -_)')
@rubenhorn
rubenhorn / tic_tac_toe.py
Created August 13, 2020 11:52
Simple TicTacToe game written in python
#!/usr/bin/env python3
import os, re, random
clear = lambda: os.system('cls' if os.name == 'nt' else 'clear')
def print_header():
print(' _____ _ _____ _____ ')
print(' |_ _(_)_|_ _|_ _ _|_ _|__ ___ ')
print(' | | | / _|| |/ _` / _|| |/ _ \/ -_)')
@rubenhorn
rubenhorn / 2xYT.js
Created August 3, 2020 12:50
Tampermonkey script to set YouTube playback speed to 2x
// ==UserScript==
// @name 2xYT
// @version 0.1
// @description Automatically sets the playback speed to 2x on YouTube.com
// @match *://www.youtube.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
@rubenhorn
rubenhorn / broadcast.py
Created June 7, 2020 09:44
Simple UDP broadcasting demo
import socket
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-m', '--mode', choices=['sender', 'receiver'], required=True)
arguments = parser.parse_args()
is_sender = arguments.mode == 'sender'
receiver_port = 1234
receive_size = 1024
@rubenhorn
rubenhorn / object_tracking.py
Created April 16, 2020 21:46
Simple OpenCV object tracking demo
import cv2
cap = cv2.VideoCapture(0)
tracker = cv2.TrackerMOSSE_create()
roi = None
while True:
_, frame = cap.read()