This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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__": |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:window.location.href="https://gist."+window.location.href.match(/(github\.com\/[^/]+)(?:\/.*)?/)[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:window.location.host=window.location.host.replace(/(com|dev)/,x=>"comdev".replace(x,"")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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é !" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import curses | |
# Constants | |
import random | |
KEY_ESC = 27 | |
X = "X" | |
O: str = "O" | |
EMPTY = " " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] + "/") |
NewerOlder