Skip to content

Instantly share code, notes, and snippets.

@rubenhorn
rubenhorn / EnergySource.cs
Last active October 29, 2019 17:41
A Unity3d script emulating a power network
using System.Collections.Generic;
using UnityEngine;
public class EnergySource : MonoBehaviour
{
public float maxEdgeLength = 1.0f;
public string vertexTag = "GraphVertex";
private TransformGraph<GameObject> graph = new TransformGraph<GameObject>();
@rubenhorn
rubenhorn / code.gs
Created November 26, 2019 21:28
Google App Script for logging temperature values in Google Sheet file
// From https://github.com/varul29/SHT25_GoogleSheets_GoogleScript?source=post_page-----27912740e74a----------------------
var filename = 'temp_log_sheet';
var sheetName = 'values';
var columns = ['time', 'celsius', 'location'];
function getSheet() {
var files = DriveApp.getFilesByName(filename);
var file;
var didCreateFile = false;
{
"name": "latex-workshop",
"displayName": "LaTeX Workshop",
"description": "Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.",
"icon": "icons/icon.png",
"version": "8.7.1",
"publisher": "James-Yu",
"license": "MIT",
"homepage": "https://github.com/James-Yu/LaTeX-Workshop",
"repository": {
@rubenhorn
rubenhorn / RedirectAppOutputStream.java
Last active March 21, 2020 15:05
Redirect the output of System.out.println() to a Swing gui
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class RedirectAppOutputStream {
@rubenhorn
rubenhorn / fast_object_localization.py
Created April 12, 2020 22:10
Fast (30fps on CPU) object localization using pretrained model from TensorFlow Hub
#!/usr/bin/env python3
import cv2
import tensorflow as tf
import tensorflow_hub as hub
import time
module_handle = 'https://tfhub.dev/google/object_detection/mobile_object_localizer_v1/1'
print('loading object detection model...')
@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()
@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 / 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 / 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 / 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(' | | | / _|| |/ _` / _|| |/ _ \/ -_)')