Skip to content

Instantly share code, notes, and snippets.

View tamuhey's full-sized avatar
🏠
Working from home

Yohei Tamura tamuhey

🏠
Working from home
View GitHub Profile
@2torus
2torus / doctesting_decorator.py
Last active November 21, 2020 10:02
Replacement for ipython_doctester
"""
ipython_doctester module is outdated. I tried to replace its test function with the function below
Code is from https://stackoverflow.com/a/47590703/996379
"""
import doctest
import copy
def test(func):
'''
Use test as a decorator to a function with doctests in Jupyter notebook.
Run the cell to see the results of the doctests.
@pandaman64
pandaman64 / memory_model.md
Last active December 18, 2020 07:54
papers on formalized memory models

色々メモリモデル

コンパイラ(LLVM)のメモリモデル

✅ Reconclining high-level optimization and low-level code in LLVM (https://dl.acm.org/doi/10.1145/3276495)

Lee, Hur, Jung, Liu, Regehr, Lopes.

  • 低レベル言語(C, C++, Rust)のコンパイラのメモリモデルには二つの相反する目標がある
    • high-level optimization
      • 最適化したい
  • 例:
@micahgodbolt
micahgodbolt / wsl_install_node.md
Last active December 22, 2022 09:37
WSL install Node

The apt-get version of node is incredibly old, and installing a new copy is a bit of a runaround.

So here's how you can use NVM to quickly get a fresh copy of Node on your new Bash on Windows install

$ touch ~/.bashrc
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
// restart bash
$ nvm install --lts

diffってなんだ

2つの要素に対して差分を求めるとは、何が変わっていないのか、何が追加されたのか、何が削除されたのか、求める行為である。

差分を計算するために、下記3つを計算する。

  • 編集距離 (levenshtein distance)
  • 2つの要素の差分を数値化したもの
  • LCS (Longest Common Subsequence)
  • 2つの要素 X と Y の最長共通部分列
@t-vi
t-vi / __init__.pyi
Last active July 13, 2023 09:11
PyTorch Type Hints work in progress (put into python3.x/dist-packages/torch/ directory to try)
from typing import List, Tuple, Optional, Union, Any, ContextManager, Callable, overload
import builtins
import math
import pickle
class dtype: ...
_dtype = dtype
@akirakubo
akirakubo / bert-japanese.md
Created July 11, 2020 00:10
日本語向け事前学習済みBERTモデルのリスト
@gatopeich
gatopeich / dataclass_from_dict.py
Created February 19, 2019 15:08
Python 3.7 dataclass to/from dict/json
from dataclasses import dataclass, fields as datafields
from ujson import dumps, loads
# Note: ujson seamlessly serializes dataclasses, unlike stdlib's json
@dataclass
class Point:
x: float
y: float
# Shallow dataclass can be rebuilt from dict/json:
@ines
ines / Install
Last active September 21, 2023 17:14
Streamlit + spaCy
pip install streamlit
pip install spacy
python -m spacy download en_core_web_sm
python -m spacy download en_core_web_md
python -m spacy download de_core_news_sm
@ryboe
ryboe / .travis.yml
Last active November 23, 2023 05:37
Example .travis.yml for Golang
# use the latest ubuntu environment (18.04) available on travis
dist: bionic
language: go
# You don't need to test on very old versions of the Go compiler. It's the user's
# responsibility to keep their compiler up to date.
go:
- 1.16.x
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/