Skip to content

Instantly share code, notes, and snippets.

View FlorianLatapie's full-sized avatar
🧯
The_WolF_178

Florian Latapie FlorianLatapie

🧯
The_WolF_178
View GitHub Profile
@FlorianLatapie
FlorianLatapie / crop_golfed.py
Last active August 4, 2023 15:28
Python script to crop transparent pixels in .png images
from PIL import Image
import numpy as np
def crop_blank_pixels(path: str):
img = Image.open(path)
are_transparent_pixels = np.array(img)[:, :, 3] != 0
rows, cols = are_transparent_pixels.nonzero() # keep only non-transparent pixels
img.crop((cols.min(), rows.min(), cols.max() + 1, rows.max() + 1)).save(path)
if __name__ == "__main__":
@FlorianLatapie
FlorianLatapie / lvdh.drawio.svg
Last active August 4, 2023 14:10
Arbre narratif de La Vidéo Dont vous êtes le Héron par Inernet
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@FlorianLatapie
FlorianLatapie / go_to_gists.js
Last active December 3, 2022 19:24
Go directly to a person's GitHub Gist profile by clicking on a bookmark with this code.
javascript:window.location.href="https://gist."+window.location.href.match(/(github\.com\/[^/]+)(?:\/.*)?/)[1]
@FlorianLatapie
FlorianLatapie / switch_com_dev.js
Last active December 30, 2022 17:04
Switch between .com and .dev by clicking on a bookmark with this code.
javascript:window.location.host=window.location.host.replace(/(com|dev)/,x=>"comdev".replace(x,""))
@FlorianLatapie
FlorianLatapie / dl_TD_lippi.sh
Created October 13, 2022 10:06
Télécharger les TDs de Lippi
echo -e "Recherche de fichiers dans http://users.polytech.unice.fr/~lippi/cpp/td/"
# source : https://stackoverflow.com/a/26269730
wget -q -r -np -nH --cut-dirs=3 -R *.html* http://users.polytech.unice.fr/~lippi/cpp/td/
# -q : silencieux
# -r : récursivement
# -np : ne pas aller dans les répertoires du dessus
# -nH : ne pas sauvegarder les fichiers dans le dossier "hostname".
# --cut-dirs=3 : sauvegarde en omettant les 3 premiers dossiers ~lippi, cpp, td
# -R *.html* : exclure les fichiers .html
echo -e "Terminé !"
@FlorianLatapie
FlorianLatapie / tictactoe.py
Created June 9, 2022 14:32
Simple python Tic-tac-toe using the mouse in the terminal with curses, on Windows use the command `pip install windows-curses` to install curses
import curses
# Constants
import random
KEY_ESC = 27
X = "X"
O: str = "O"
EMPTY = " "
@FlorianLatapie
FlorianLatapie / mvn_win_install.cmd
Last active November 7, 2023 13:10
Apache Maven 3.8.6 auto install script for Windows *run the script with admin privileges*
@ECHO off
REM @Author Florian Latapie
echo Apache Maven auto install script for Windows & echo. & echo Downloading the zip file & echo.
curl -o tmp.zip https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.zip
echo Installation & echo.
powershell -command "Expand-Archive tmp.zip 'C:\Program Files\apache'"
setx /M PATH "%PATH%;C:\Program Files\apache\apache-maven-3.8.6\bin"
del tmp.zip
@FlorianLatapie
FlorianLatapie / AreYouDumb.java
Last active December 30, 2022 17:00
I got lost on Instagram and wanted to recreate what I saw.
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.Random;
import static javax.swing.SwingConstants.CENTER;
public class AreYouDumb extends JFrame {
private final JLabel label;
@FlorianLatapie
FlorianLatapie / snake.py
Last active December 30, 2022 17:01
Simple python snake using curses, on Windows use the command `pip install windows-curses` to install curses, using PyCharm IDE make sure that you enabled the "Emulate termianl in output console" option to make it work
import curses
from curses import KEY_RIGHT, KEY_LEFT, KEY_UP, KEY_DOWN
from random import randint
# Constants
KEY_ESC = 27
height = 10
width = 40
half_height = int(height / 2)
@FlorianLatapie
FlorianLatapie / imgzipper-golfed.py
Last active December 30, 2022 17:01
This script creates a zip file with the images asked by the user (two files : golfed and readable)
import os, sys, requests, json, shutil
results = json.loads(requests.request("GET", "https://imsea.herokuapp.com/api/1?q=" + sys.argv[1]).text)["results"]
os.path.exists(sys.argv[1] + "/") or os.makedirs(sys.argv[1] + "/")
[open(sys.argv[1] + "/" + sys.argv[1] + str(i // 2 + 1) + '.png', 'wb').write(requests.get(results[i]).content) for i in
range(0, len(results), 2)]
shutil.make_archive(sys.argv[1], 'zip', sys.argv[1] + "/")
shutil.rmtree(sys.argv[1] + "/")