Skip to content

Instantly share code, notes, and snippets.

View alexandre01's full-sized avatar
🚀
Building

Alexandre Carlier alexandre01

🚀
Building
View GitHub Profile
@alexandre01
alexandre01 / random_mask_generation.py
Created December 21, 2019 14:37
Tensor operation-only random mask generation
import torch
x = torch.randn(1, 3, 800, 1200)
n, _, h, w, = x.shape
rnd = torch.rand(2, n, 1, 2).sort(-1).values
r, c = torch.linspace(0, 1, h+2)[None, None], torch.linspace(0, 1, w+2)[None, None]
mask = (((r > rnd[0, :, :, :1]) & (r < rnd[0, :, :, 1:])).unsqueeze(-1) *
((c > rnd[1, :, :, :1]) & (c < rnd[1, :, :, 1:])).unsqueeze(-2))[:, :, 1:-1, 1:-1].expand_as(x)
@tshirtman
tshirtman / dyn_rv.py
Last active May 15, 2022 15:04
An example of how to create an infinite scroll with recycleview (appending data as user scrolls)
from kivy.lang import Builder
from kivy.properties import ListProperty
from kivy.app import App
from random import sample
from string import ascii_letters as letters
KV = '''
<MyButton@Button>:
on_press: print(self.text)
@plentz
plentz / nginx.conf
Last active September 1, 2025 19:26
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048