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
""" Implementation of OKapi BM25 with sklearn's TfidfVectorizer | |
Distributed as CC-0 (https://creativecommons.org/publicdomain/zero/1.0/) | |
""" | |
import numpy as np | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from scipy import sparse | |
class BM25(object): |
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 requests | |
import re | |
import time | |
""" | |
Prerequisite: Create access tokens | |
You need private access token to have full access to Github search | |
API. | |
Generate your access token in [here](https://github.com/settings/tokens) |
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
[user] | |
email = [email protected] | |
name = Yuta Koreeda | |
[core] | |
editor = emacs -nw | |
[alias] | |
# Adopted from https://www.jacobtomlinson.co.uk/quick%20tip/2016/01/18/pretty-git-logs-with-git-lg/ | |
lg = !"git lg1" |
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
# coding: utf-8 | |
""" | |
This is the ipython startup script that I used to use in university. | |
(but not anymore) | |
Place it in ~/.ipython/profile_default/startup/startup.py for it to work | |
""" | |
import numpy as np | |
import math | |
import matplotlib.pyplot as plt | |
import matplotlib |
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/bash | |
# seeding adopted from https://stackoverflow.com/a/41962458/7820599 | |
get_seeded_random() | |
{ | |
seed="$1"; | |
openssl enc -aes-256-ctr -pass pass:"$seed" -nosalt \ | |
</dev/zero 2>/dev/null; | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
<div style="background-image: linear-gradient(bottom, #FFD51A 50%, #FAC815 50%); | |
background-image: -o-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
background-image: -moz-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
background-image: -webkit-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
background-image: -ms-linear-gradient(bottom, #33D51A 50%, #FAC815 50%); | |
display: inline-block;">aaaa</div> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
@contextlib.contextmanager | |
def safe_mkdir(path, dir=None): | |
""" Create a directory in safe(r) way. Specified directory is created only when | |
whole operations in `with` scoped is completed successfully. All the files | |
that are created within the temporaly generated dir will be kept within. | |
This may not work in some OS. | |
""" | |
if dir is None: | |
dir = os.path.dirname(path) |
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
def lock(f): | |
""" decorator which locks class method | |
You need property _lock defined as in the following. | |
self._lock = threading.Lock() | |
""" | |
def body(self, *args, **kwargs): | |
with self._lock: | |
return f(self, *args, **kwargs) | |
return body |
NewerOlder