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 sys | |
from http.server import SimpleHTTPRequestHandler, HTTPServer | |
class GzipRequestHandler(SimpleHTTPRequestHandler): | |
'''HTTPRequestHandler for gzip files''' | |
def end_headers(self): | |
'''Set Content-Encoding: gzip for gzipped files''' | |
if self.path.endswith('.gz'): |
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
// ref: https://stackoverflow.com/questions/17267329/converting-unicode-character-to-string-format | |
function unicodeToChar(text) { | |
return text.replace(/\\u[\dA-F]{4}/gi, | |
function (match) { | |
return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16)); | |
}); | |
} |
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
create temp function ndcg(rels array<int64>, k int64) returns float64 as ( | |
( | |
with gain as ( | |
select | |
(pow(2, rel) - 1) / log(i + 2) as g, | |
(pow(2, rel_sorted) - 1) / log(i + 2) as g_ideal | |
from | |
unnest(rels) as rel with offset as i | |
left join unnest(( | |
select |
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 pandas as pd | |
import matplotlib.pyplot as plt | |
%load_ext autoreload | |
%autoreload 2 | |
# pandas settings | |
pd.set_option('display.max_columns', 200) | |
pd.set_option('display.max_rows', 100) |
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
kubectl get pods --field-selector=status.phase=Failed | cut -d' ' -f 1 | sed -e '1d' | xargs kubectl delete pod |
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 time | |
import requests | |
import json | |
import pings # pip install pings | |
HOSTNAME = '{{ HOSTNAME }}' | |
PING_TIMES = 10 | |
SLEEP_TIME = 100 | |
WEBHOOK_URL = '{{ WEBHOOK_URL }}' |
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
from rest_framework.views import APIView | |
from rest_framework.decorators import parser_classes | |
from rest_framework.parsers import FormParser | |
from django.http import JsonResponse | |
from drf_yasg import openapi | |
from drf_yasg.utils import swagger_auto_schema | |
class TestView(APIView): | |
'''Test API |
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
# use --trace-ascii to show the payload | |
curl -i -d 'key=value' [-v] [--trace-ascii /dev/stdout] https://example.com/ |
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 sys | |
def show_progress(e, i, t, l, v): | |
''' | |
Prints the training progress recursively. | |
Args: | |
e (int): the current epoch | |
i (int): the current batch | |
t (int): the total batches |
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 os | |
PATH_DIR = '/path/to/dir' | |
if not os.path.exists(PATH_DIR): | |
print('mkdir', PATH_DIR) | |
os.mkdir(PATH_DIR) |
NewerOlder