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
#!/usr/bin/env python3 | |
import argparse | |
from xml.dom import minidom | |
def main(): | |
p = argparse.ArgumentParser(description='Pretty-print an XML file.') | |
p.add_argument('file', type=str, help='File path to print.') | |
args = p.parse_args() | |
data = open(args.file).read() |
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
// Wrapper class of KyTea word segmenter. | |
// Author: odashi | |
// Date: 2021-01-26 | |
// License: MIT | |
#include <memory> | |
#include <string> | |
#include "kytea/kytea.h" | |
#include "kytea/string-util.h" |
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 dataclasses as dc | |
from jax import tree_util as jt | |
def register_jax_dataclass(cls): | |
"""Registers a dataclass as a JAX pytree.""" | |
if not dc.is_dataclass(cls): | |
raise TypeError('%s is not a dataclass.' % cls) | |
keys = [field.name for field in dc.fields(cls)] |
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
#!/bin/zsh | |
autoload colors; colors | |
if [ $# != 2 ]; then | |
echo "usage: $0 <root-dir> <command>" | |
exit 1 | |
fi | |
ROOTDIR=$1 |
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
#include <iomanip> | |
#include <iostream> | |
#include <cstdlib> | |
#include <vector> | |
#include <cuda.h> | |
#include <cudnn.h> | |
#define CUDA_CALL(f) { \ | |
cudaError_t err = (f); \ |
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
// 実行方法: | |
// g++ -std=c++11 xor.cc -lprimitiv && ./a.out | |
#include <cstdio> | |
#include <iostream> | |
#include <primitiv/primitiv.h> | |
using namespace primitiv; | |
namespace D = primitiv::devices; | |
namespace F = primitiv::functions; |
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
#include <chrono> | |
#include <cstdlib> | |
#include <iostream> | |
#include <random> | |
#include <thread> | |
#include <X11/Xlib.h> | |
#include <X11/Xutil.h> | |
using namespace std; |
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
#!/usr/bin/env python3 | |
import curses | |
from random import random | |
from time import sleep | |
def main(scr): | |
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_BLACK) | |
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_BLACK) | |
curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_WHITE) |
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
#!/usr/bin/env python3 | |
import sys | |
from argparse import ArgumentParser | |
from collections import defaultdict | |
def parse_args(): | |
p = ArgumentParser('Converts word to integer using byte-pair encoding.') | |
p.add_argument( | |
'--input', |
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 builtins | |
import random | |
def word_list(filename): | |
with open(filename) as fp: | |
for l in fp: | |
yield l.split() | |
def batch(generator, size): | |
batch = [] |