Skip to content

Instantly share code, notes, and snippets.

View vict0rsch's full-sized avatar
🌍
AI vs Climate Change

Victor Schmidt vict0rsch

🌍
AI vs Climate Change
View GitHub Profile
@vadimkantorov
vadimkantorov / perlin.py
Last active February 15, 2024 10:36
Perlin noise in PyTorch
# ported from https://github.com/pvigier/perlin-numpy/blob/master/perlin2d.py
import torch
import math
def rand_perlin_2d(shape, res, fade = lambda t: 6*t**5 - 15*t**4 + 10*t**3):
delta = (res[0] / shape[0], res[1] / shape[1])
d = (shape[0] // res[0], shape[1] // res[1])
grid = torch.stack(torch.meshgrid(torch.arange(0, res[0], delta[0]), torch.arange(0, res[1], delta[1])), dim = -1) % 1
@towbi
towbi / details_tag.rb
Last active March 6, 2022 17:17
Jekyll plugin for a tag block mimicking the behaviour of the HTML5 "details" element
# _plugins/details_tag.rb
module Jekyll
module Tags
class DetailsTag < Liquid::Block
def initialize(tag_name, markup, tokens)
super
@caption = markup
end
@kirang89
kirang89 / something.py
Last active November 11, 2022 05:10
Creating a mutable ARRAY data type in sqlalchemy
class Something(Base):
__tablename__ = 'yaddayadda'
id = Column(Integer, primary_key=True)
data = Column(MutableList.as_mutable(ARRAY(String(100))))
@jdkanani
jdkanani / Server.py
Last active April 25, 2023 16:40
Python SimpleHTTPServer : Routing sample
#!/usr/bin/env python
import os
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
ROUTES = [
('/', '/var/www/doc-html')
]
class MyHandler(SimpleHTTPRequestHandler):