This file contains hidden or 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
| # Sometimes you want to define your FastAPI app within a class for some reason, e.g., | |
| # you wanted to initialize the servers at the point you intended, not the point of import. | |
| # | |
| # In this case, @app.method decorator doesn't work as-is with instance methods due to the | |
| # difference of its signature. | |
| # | |
| # You need to manually call the decorator as a usual function after obtaining self (e.g., | |
| # in the __init__ method like below) rather than using the decorator syntax. | |
| class MyApp: |
This file contains hidden or 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
| !pip install ipywidgets &> /dev/null | |
| import ipywidgets as wgt | |
| controls = wgt.VBox([]) | |
| add_button = wgt.Button(description="Add", icon="plus") | |
| pos_prompt_area = wgt.Textarea(placeholder="Positive prompts appear here.") | |
| neg_prompt_area = wgt.Textarea(placeholder="Negative prompts appear here.") | |
| ui = wgt.VBox([pos_prompt_area, neg_prompt_area, add_button, controls]) | |
| def generate_prompt(change): |
This file contains hidden or 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
| あまり大きな声で言えないのですが | |
| あまり知られてないのですが | |
| ありえない | |
| あんまり言いたくないけど | |
| いい加減にしてほしい | |
| いい歳してお恥ずかしいのですが | |
| 悪用厳禁なのですが | |
| 安心してください | |
| 言いたくない過去を言うと | |
| 言わせてください |
This file contains hidden or 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 datetime | |
| import logging | |
| import os | |
| from google.cloud import logging as cloud_logging | |
| import tweepy | |
| THRESHOLD_DAYS = 3 | |
| BATCH_SIZE = 25 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; |