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
# fork your own repo, example of my repo https://github.com/vadimkantorov/eventmap | |
git clone git@github.com:vadimkantorov/eventmapexample.git | |
cd eventmapexample | |
git remote add upstream git@github.com:vadimkantorov/eventmap.git | |
git pull upstream gh-pages | |
git checkout gh-pages | |
git push -u origin gh-pages | |
# update git to latest version on ubuntu | |
sudo add-apt-repository -y ppa:git-core/ppa |
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
# supports only strings, dicts and lists | |
# does not support multiline strings as the first list-item key `- run: |` | |
# does not support record parsing into a dict: `- {asd: foobar, foo: "bar"}` | |
def yaml_loads(content): | |
procval = lambda val: (val[1:-1] if len(val) >= 2 and ((val[0] == val[-1] == '"') or (val[0] == val[-1] == "'")) else val.split('#', maxsplit = 1)[0].strip()) if val else '' | |
lines = content.strip().splitlines() | |
res = {} |
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 xml.dom.minidom | |
def feed_write(ctx, path, generator_name = 'minimapython', generator_uri = 'https://github.com/vadimkantorov/minima', generator_version = 'https://github.com/vadimkantorov/minimapython'): | |
site = ctx.get('site', {}) | |
site__lang = site.get('lang') | |
page__url__absolute_url = '' | |
root__absolute_url = '' | |
site__time__date_to_xml_schema = '' | |
page__url__absolute_url__xml_escape = '' |
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
# CTC vanilla and CTC via crossentropy are equal, and their gradients as well. In this reformulation it's easier to experiment with modifications of CTC. | |
# References on CTC regularization: | |
# "A Novel Re-weighting Method for Connectionist Temporal Classification", Li et al, https://arxiv.org/abs/1904.10619 | |
# "Focal CTC Loss for Chinese Optical Character Recognition on Unbalanced Datasets", Feng et al, https://www.hindawi.com/journals/complexity/2019/9345861/ | |
# "Improved training for online end-to-end speech recognition systems", Kim et al, https://arxiv.org/abs/1711.02212 | |
import torch | |
import torch.nn.functional as F | |
## generate example data |
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
# python -m pip install timezonefinder pytz --user | |
import timezonefinder | |
import pytz | |
import datetime | |
latlnglist = ''' | |
43.0010092,41.0208743 | |
42.9972303,41.0089412 | |
43.0125911,40.9705287 | |
42.9991332,41.0408331 |
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
<html><body> | |
<link href="https://tile.openstreetmap.org/{z}/{x}/{y}.png" id="link_tiles" /> | |
<!-- | |
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.8.0/dist/leaflet.css" | |
integrity="sha512-hoalWLoI8r4UszCkZ5kL8vayOGVae1oxXe/2A4AO6J9+580uKHDO3JdHb7NzwwzK5xr/Fs0W40kiNHxM9vyTtQ==" | |
crossorigin=""/> | |
<script src="https://unpkg.com/leaflet@1.8.0/dist/leaflet.js" |
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
# https://sitemaps.org/protocol.html | |
import sys | |
import xml.dom.minidom | |
import urllib.request | |
def sitemapindex_urlset_concat(url): | |
sitemapindex = xml.dom.minidom.parse(urllib.request.urlopen(url)) | |
for sitemap in sitemapindex.getElementsByTagName('sitemap'): | |
urlset = xml.dom.minidom.parse(urllib.request.urlopen(sitemap.getElementsByTagName('loc')[0].firstChild.nodeValue)) |
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
# https://dumps.wikimedia.org/wikidatawiki/entities/ https://dumps.wikimedia.org/ruwiktionary/ https://dumps.wikimedia.org/ruwiktionary/20231201/ | |
# | |
# wget -L https://dumps.wikimedia.org/wikidatawiki/entities/20231213/wikidata-20231213-lexemes.json.bz2 https://dumps.wikimedia.org/ruwiktionary/20231201/ruwiktionary-20231201-pages-meta-current.xml.bz2 | |
# bzcat wikidata-20231213-lexemes.json.bz2 | wc -l # 1198580 | |
# bzcat wikidata-20231213-lexemes.json.bz2 | head -n 2 | |
# bzcat ruwiktionary-20231201-pages-meta-current.xml.bz2 | wc -l # 196257893 | |
# bzcat ruwiktionary-20231201-pages-meta-current.xml.bz2 | head -n 100 | |
# bzgrep '<page>' ruwiktionary-20231201-pages-meta-current.xml.bz2 | wc -l # 2814450 | |
# time python3 readwiktionary.py ruwiktionary-20231201-pages-meta-current.xml.bz2 ruwiktionary-20231201-pages-meta-current.xml.bz2 # real 11m15.868s # user 9m36.938s # sys 0m5.656s |
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
# 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 |
NewerOlder