Skip to content

Instantly share code, notes, and snippets.

import math
import random
def dice(num, size):
return sum(random.randint(1, size) for _ in range(num))
class Character:
def damage(self, amount):
@lyger
lyger / booth_download.js
Created May 5, 2019 10:35
BOOTHで購入したダウンロード商品を一気にダウンロードするスクリプト
let links = document.getElementsByClassName('nav-reverse');
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
for (let i=0; i<links.length; i++) {
let l = links[i]
if (l.innerText === 'Download' || l.innerText === 'ダウンロード') {
l.click();
await sleep(500);
}
import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Tuple, Union
from .autopackingrnn import AutoPackingRNN
FloatType = Union[torch.FloatTensor, torch.cuda.FloatTensor]
LongType = Union[torch.LongTensor, torch.cuda.LongTensor]
import torch.utils.data as D
from myutils.data import EmbeddingLoader, CompositeConverter, TextDataset, \
ParallelDataset, ParallelCollate, lowercase, tokenize_with_bos_and_eos
emb_en = EmbeddingLoader('/cl/work/michael-l/multiembed/en.multiCCA.512.embedding', 512)
emb_de = EmbeddingLoader('/cl/work/michael-l/multiembed/de.multiCCA.512.embedding', 512)
converter = CompositeConverter(lowercase, tokenize_with_bos_and_eos)
news_en = emb_en.process_dataset(
Alos
Amu
Ardol
Argola
Aricheo
Arite
Arlele
Arma
Armara
Armile
#!/usr/bin/env python3
import _dynet as dy
import numpy as np
from collections import OrderedDict
# End of word token.
EOW = "<EOW>"
@lyger
lyger / MobuDistinguishers.js
Created January 18, 2018 07:39
Template strings to distinguish monsters
const templates = {
"Humanoid traits": [
"with [genericadj+limbadj] [limbs]",
"with a missing [limb+appendage+face]",
"with [genericadj+eyeadj] eyes",
"wearing @[jewelryadj] [jewelry]",
"with [hairadj] hair",
"with @[voiceadj] voice"
],
"Mammalian traits": [