Skip to content

Instantly share code, notes, and snippets.

View query.py
R = TypeVar('R')
Rs = TypeVarTuple('Rs')
class Query(Generic[R]):
...
def execute(*args: *Map[Query, Rs]) -> Tuple[*Rs]:
...
View multi_field.py
GetSetVar = TypeVar('GetSetVar')
TagVar = TypeVarTuple('TagVar')
class MultiField(AbstractField[GetSetVar], Generic[*TagVar]):
def __init__(self, nbt_names: Sequence[str], *, default: GetSetVar = None) -> None:
...
@abc.abstractmethod
def to_python(self, *tags: *TagVar) -> GetSetVar:
...
View dataset_info.json
{
"citation": "@misc{\n author={Karpathy, Andrej},\n title={char-rnn},\n year={2015},\n howpublished={\\url{https://github.com/karpathy/char-rnn}}\n}",
"description": "40,000 lines of Shakespeare from a variety of Shakespeare's plays. Featured in Andrej Karpathy's blog post 'The Unreasonable Effectiveness of Recurrent Neural Networks': http://karpathy.github.io/2015/05/21/rnn-effectiveness/.\n\nTo use for e.g. character modelling:\n```\nd = tfds.load(name='tiny_shakespeare')['train']\nd = d.map(lambda x: tf.strings.unicode_split(x['text'], 'UTF-8'))\n# train split includes vocabulary for other splits\nvocabulary = sorted(set(next(iter(d)).numpy()))\nd = d.map(lambda x: {'cur_char': x[:-1], 'next_char': x[1:]})\nd = d.unbatch()\nseq_len = 100\nbatch_size = 2\nd = d.batch(seq_len)\nd = d.batch(batch_size)\n```",
"location": {
"urls": [
"https://github.com/karpathy/char-rnn/blob/master/data/tinyshakespeare/input.txt"
]
},
"name": "tiny_shakespeare",
"schema": {
View n.sh
#!/bin/bash
pkill -f ngrok
ngrok http $1 &> ~/.ngrok.log &
sleep 1
echo -n 'ngrok http '
json=$(curl -s http://localhost:4040/api/tunnels)
echo "$json" | python3 -c "import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])" || echo $json
View tb.py
#!/usr/bin/env python3
import argparse
import os
import subprocess
import socket
import tempfile
import getpass
parser = argparse.ArgumentParser()
View tnv.py
#!/usr/bin/env python3
import argparse
import pathlib
import subprocess
import os
import shutil
import tempfile
View t2.py
#!/bin/bash
set -o errexit
server=$1
remote_paths="$server:\""
for remote_path in "${@:2}"; do
remote_paths="$remote_paths '$remote_path'"
done
remote_paths="$remote_paths\""
View t.py
#!/usr/bin/env python3
import argparse
import fileinput
import os
import socket
import sys
parser = argparse.ArgumentParser()
parser.add_argument('files', nargs='*')
View test.py
import tensorflow as tf
import time
sess = tf.Session()
var = tf.Variable(0)
saver = tf.train.Saver(max_to_keep=1)
sess.run(var.initializer)
i = 0
while True:
View gist:4f10ac1db8f10cee5565d77f9c724c46
import tensorflow as tf
import time
sess = tf.Session()
var = tf.Variable(0)
saver = tf.train.Saver(max_to_keep=1)
sess.run(var.initializer)
i = 0
while True: