Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
0xDEADBEEF

Louis louis-e

:octocat:
0xDEADBEEF
View GitHub Profile
View NumPy ndarray non recursive floodfill algorithm
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 Mar 4, 2021
Website Google Translation implementation
View translation.html
<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 / javascript_multi_language.html
Last active Aug 14, 2020
HTML JavaScript | Easy Multi Language Support
View javascript_multi_language.html
<!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 Jun 22, 2020 — forked from mdomrach/GridMesh.cs
Fixed line 17; otherwise the top and the right side of the grid won't be closed
View GridMesh.cs
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 / GridSnapping.cs
Last active Sep 3, 2020
GridSnapping.cs | GameObject Editor Grid Snapping (Optional: change the float gridSize to set the size of the grid)
View GridSnapping.cs
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 / UnityApplication.systemLanguageHindiFix.cs
Created May 23, 2020
Because in Unity/C# UnityApplication.systemLanguage doesn't support Hindi, you can use this C# code snippet to recognize a Hindi system language
View UnityApplication.systemLanguageHindiFix.cs
//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 Aug 18, 2019
A python script to protect raspberry pi against overheating because of omxplayer.
View tempcontrol.py
#!/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 Aug 15, 2019
Simple bash script to play youtube video with omxplayer and youtube-dl
View omxplayeryoutube.sh
#!/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")
@louis-e
louis-e / innovative_try_catch.js
Created Jul 24, 2019
JavaScript Try-Catch Stackoverflow
View innovative_try_catch.js
try {
//something
} catch(e) {
window.location.href =
"http://stackoverflow.com/search?q=[js] + "
+ e.message;
}
@louis-e
louis-e / UDPSocket.cs
Last active Jan 17, 2023 — forked from darkguy2008/UDPSocket.cs
Simple C# UDP server/client in 62 lines
View UDPSocket.cs
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
namespace UDP
{
public class UDPSocket
{
public Socket _socket;