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
Tested this works https://stackoverflow.com/a/57014278/6147756 | |
Single command: | |
MAKEFLAGS="-j$(nproc)" pip install xxx | |
Enable for all commands in a script: | |
export MAKEFLAGS="-j$(nproc)" |
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
def get_available_ports(port_from=5000, port_to=6000): | |
import socket | |
for port in range(port_from, port_to): | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind(('localhost', port)) | |
s.close() | |
yield port | |
except: | |
continue |
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
def strip_codeblock(code_with_codeblock): | |
first_newline_idx = code_with_codeblock.find("\n") | |
code_tmp = code_with_codeblock[first_newline_idx+1:] | |
code_closing_idx = code_tmp.find("```") | |
code_striped = code_tmp[:code_closing_idx] | |
return code_striped |
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
curl -N -X 'POST' \ [12:04:09] | |
'http://localhost:8080/v1/chat-streaming' \ | |
-H 'Content-Type: application/json' \ | |
-H 'Accept: text/event-stream' \ | |
-d '{ | |
"turns": [ | |
{ | |
"role": "user", | |
"content": "fastapi 사용법" | |
} |
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
class DataType(str, Enum): | |
WITH_SUFFIX = "WITH_SUFFIX" | |
WITHOUT_SUFFIX = "WITHOUT_SUFFIX" |
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 random | |
def reservoir_sampling(file_name, k): | |
sample = [] | |
with open(file_name, 'r') as f: | |
f.seek(0, 2) # 파일의 끝으로 이동 | |
filesize = f.tell() # 파일의 크기를 얻음 (바이트) | |
random_set = sorted(random.sample(range(filesize), k)) |
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 bash | |
PID=<SOME_PID> | |
while true; do | |
if ! ps -p PID> > /dev/null; then | |
./run.sh | |
break | |
fi | |
sleep 10 |
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 logging | |
import sys | |
# Setup logging | |
logging.basicConfig( | |
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s", | |
datefmt="%m/%d/%Y %H:%M:%S", | |
handlers=[logging.StreamHandler(sys.stdout)], | |
) | |
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
<!-- Ref: https://daily-dev-tips.com/posts/making-gradient-text-with-tailwind-css/ --> | |
<div class="grid place-items-center h-screen"> | |
<h1 class="text-8xl font-extrabold text-transparent bg-clip-text bg-gradient-to-r from-purple-400 to-pink-600"> | |
Tailwind CSS | |
</h1> | |
</div> |
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
def find_all_span(d, s): | |
span_list = [] | |
offset = -1 | |
while True: | |
start_idx = d.find(s, offset + 1) | |
if start_idx == -1: | |
break |