Skip to content

Instantly share code, notes, and snippets.

View louis-e's full-sized avatar
:octocat:
0xDEADBEEF

Louis Erbkamm louis-e

:octocat:
0xDEADBEEF
View GitHub Profile
@louis-e
louis-e / UDPSocket.cs
Last active March 14, 2024 16:30 — forked from darkguy2008/UDPSocket.cs
Simple C# UDP server/client in 62 lines
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDP
{
public class UDPSocket
{
public Socket _socket;
def floodFill(img, sr, sc, new_value):
old_value = img[sr][sc][0]
queue = [(sr, sc)]
seen = set()
tot_rows = img.shape[0]
tot_cols = img.shape[1]
while queue:
nxt = []
for x, y in queue:
if (img[x][y] == new_value):
@louis-e
louis-e / translation.html
Created March 4, 2021 15:22
Website Google Translation implementation
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
@louis-e
louis-e / innovative_try_catch.js
Created July 24, 2019 14:46
JavaScript Try-Catch Stackoverflow
try {
//something
} catch(e) {
window.location.href =
"http://stackoverflow.com/search?q=[js] + "
+ e.message;
}
@louis-e
louis-e / GridSnapping.cs
Last active September 3, 2020 09:37
GridSnapping.cs | GameObject Editor Grid Snapping (Optional: change the float gridSize to set the size of the grid)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteInEditMode]
public class GridSnapping : MonoBehaviour
{
public GameObject target;
Vector3 gridPos;
public float gridSize = 10f;
@louis-e
louis-e / javascript_multi_language.html
Last active August 14, 2020 23:22
HTML JavaScript | Easy Multi Language Support
<!DOCTYPE html>
<html>
<body>
<p id="text1">Test auf Deutsch!</p>
<script>
if (navigator.language != "de-DE" && navigator.language != "de" && window.location.hash != "#eng")
{
window.location.href = "#eng";
@louis-e
louis-e / GridMesh.cs
Last active June 22, 2020 21:42 — forked from mdomrach/GridMesh.cs
Fixed line 17; otherwise the top and the right side of the grid won't be closed
using UnityEngine;
using System.Collections.Generic;
[RequireComponent(typeof(MeshRenderer))]
[RequireComponent(typeof(MeshFilter))]
public class GridMesh : MonoBehaviour
{
public int GridSize;
void Awake()
@louis-e
louis-e / UnityApplication.systemLanguageHindiFix.cs
Created May 23, 2020 12:38
Because in Unity/C# UnityApplication.systemLanguage doesn't support Hindi, you can use this C# code snippet to recognize a Hindi system language
//NOTE: This only works for Android
using (AndroidJavaClass cls = new AndroidJavaClass("java.util.Locale"))
{
using (AndroidJavaObject locale = cls.CallStatic<AndroidJavaObject>("getDefault"))
{
if (locale.Call<string>("getDisplayLanguage") == "हिन्दी")
{
//HINDI
}
@louis-e
louis-e / tempcontrol.py
Last active August 18, 2019 15:34
A python script to protect raspberry pi against overheating because of omxplayer.
#!/usr/bin/python
import os
import time
def measure_temp():
temp = os.popen("vcgencmd measure_temp").readline()
return (temp.replace("temp=","").replace("'C",""))
while True:
temp = measure_temp()
@louis-e
louis-e / omxplayeryoutube.sh
Created August 15, 2019 15:13
Simple bash script to play youtube video with omxplayer and youtube-dl
#!/bin/bash
#Requirements:
#youtube-dl
#omxplayer
#Move this file into /usr/local/bin and add execute permission (sudo chmod +x omxplayeryoutube.sh)
#Run it like this: ./omxplayeryoutube.sh https://www.youtube.com/watch?v=l4bDVq-nP-0
omxplayer -o hdmi $(youtube-dl -g "$1")