Skip to content

Instantly share code, notes, and snippets.

@sergei-mironov
sergei-mironov / demo_func.py
Last active November 28, 2019 10:21
demo_func.py
inputs = keras.Input(shape=(784,), name='digits')
x = layers.Dense(64, activation='relu', name='dense_1')(inputs)
x = layers.Dense(64, activation='relu', name='dense_2')(x)
outputs = layers.Dense(10, activation='softmax', name='predictions')(x)
model = keras.Model(inputs=inputs, outputs=outputs)
model.fit(...)
@sergei-mironov
sergei-mironov / custom_transformer21.py
Last active November 21, 2019 08:08
TF Official bert customization, new design
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
import copy
import json
import math
import six
import itertools
@sergei-mironov
sergei-mironov / custom_transformer.py
Created November 20, 2019 14:38
TF Official bert customization, old design
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import copy
import json
import math
import six
import tensorflow as tf
import itertools
@sergei-mironov
sergei-mironov / minimal.py
Last active October 30, 2019 21:14
minimal.py
# Instructions
# 1. Load this file in IPython
# 2. call `run()`
# 3. Interrupt it with Ctrl+C
# 4. See no global state changed
from typing import Any,Optional
from time import sleep
class Model:
@sergei-mironov
sergei-mironov / train_assign.py
Created October 26, 2019 22:01
Global assignment followed by an errot
import os
import json
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
assert tf.version.VERSION.startswith('2.')
gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_virtual_device_configuration(
gpus[0],
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5.5*1024)])
@sergei-mironov
sergei-mironov / vkontakte_m3u8_downloader.sh
Last active October 21, 2023 20:04
vkontakte_m3u8_downloader.sh
#!/bin/sh
# VKontakte *m3u8 downloader
# Worked at the time of writing
mkdir /tmp/m3u8
set -e -x
cd /tmp/m3u8
rm *
@sergei-mironov
sergei-mironov / Streets_GInfo_Msk.html
Last active October 5, 2019 21:09
Streets_GInfo_Msk.html
This file has been truncated, but you can view the full file.
<html>
<head>
<script>
function clearclass(item, cls) {
item.classList.remove(cls);
}
function setclass(item, cls) {
item.classList.add(cls);
@sergei-mironov
sergei-mironov / SPb.md
Last active September 28, 2019 10:19
SPb.md
Район Название Дома
0 Адмиралтейский 1-я Красноармейская улица 1/21А, 1/21Д, 1/21Ж, 1/21З, 1/21К, 2, 2В, 3-5-7-9А, 3-5-7-9Б, 4, 6, 6Б, 8-10, 8-10Б, 11, 11В, 12, 13, 13Б, 13В, 14, 15, 16, 18, 18Б, 20, 22, 24, 24Б
1 Адмиралтейский 10-я Красноармейская улица 3, 3б, 4, 5, 5а, 5Б, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16А, 17, 19, 19А, 19Б1, 20, 20а, 21, 22, 23, 24, 26
2 Адмиралтейский 11-я Красноармейская улица 1, 2, 4, 5/13, 6, 7, 8, 9, 10, 11, 11А, 11В, 11Ж, 12, 13, 14, 15а, 15аБ, 15Б, 16, 18, 20, 22, 26, 28
3 Адмиралтейский 12-я Красноармейская улица 1, 2, 3, 4, 5, 6, 6Б, 6Г, 7, 8, 8Б, 8В, 10, 11, 12, 12Б, 13, 14, 14В, 15, 16Г, 16Н, 17, 19, 21, 23, 24, 25, 27, 29, 32, 33А, 34, 36, 37, 40
4 Адмиралтейский [13-я Красноармейская улица](http://spb.ginfo.ru/ulicy
@sergei-mironov
sergei-mironov / nl2bash-OOM.txt
Created September 23, 2019 17:09
nl2bash-OOM
attention input keep probability = 0.6
AttentionCellWrapper added!
W0922 22:44:48.935649 140431404037952 deprecation_wrapper.py:119] From /workspace/mironov/nl2bash/encoder_decoder/framework.py:200: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.
W0922 22:44:58.016724 140431404037952 deprecation.py:323] From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/clip_ops.py:286: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
W0922 22:45:20.083132 140431404037952 deprecation_wrapper.py:119] From /workspace/mironov/nl2bash/encoder_decoder/framework.py:223: The name tf.train.Saver is deprecated. Please use tf.compat.v1.train.Saver instead.
Making model_dir...
@sergei-mironov
sergei-mironov / mosh-nat-server.sh
Created September 15, 2019 20:21
mosh-nat-server.sh
#!/bin/sh
RELAY="$1"
PORT="$2"
echo -n 'nat-hole-punch' | socat STDIN "UDP-SENDTO:$RELAY:$PORT,sourceport=$PORT"
mosh-server new -p "$PORT" | sed -n 's/MOSH CONNECT [0-9]\+ \(.*\)$/\1/g p'