Skip to content

Instantly share code, notes, and snippets.

View binhna's full-sized avatar

Binh Nguyen binhna

  • Vietnam
View GitHub Profile
@binhna
binhna / requirements.txt
Created July 2, 2024 10:52
Environment for training LLM with unsloth
absl-py==2.1.0
accelerate==0.31.0
aiohttp==3.9.5
aiosignal==1.3.1
alabaster==0.7.16
annotated-types==0.7.0
anyio==4.4.0
argon2-cffi==23.1.0
argon2-cffi-bindings==21.2.0
array_record==0.5.1
@binhna
binhna / Install OpenFst with Python Binding on OSX
Created June 9, 2021 03:38 — forked from naoko/Install OpenFst with Python Binding on OSX
How to install OpenFst with Python Biding on OSX
# download
curl -O http://www.openfst.org/twiki/pub/FST/FstDownload/openfst-1.6.2.tar.gz
tar -xvzf openfst-1.6.2.tar.gz
rm openfst-1.6.2.tar.gz
cd openfst-1.6.2
./configure --enable-python
make
make install
# Test installtion
@binhna
binhna / solve_sshfs.md
Last active June 10, 2021 06:37
cannot umount or mount an sshfs volume after ssh connection cut on MAC OS
  1. Find the culprit sshfs process:

    $ pgrep -lf sshfs

  2. Kill it:

    $ kill -9 <pid_of_sshfs_process>

  3. sudo force unmount the "unavailable" directory:

@binhna
binhna / wavetrend_backtest.py
Last active May 23, 2021 06:51
backtest wavetrend
import talib
import pandas as pd
import glob
from tqdm import tqdm
def cal_wavetrend(df):
df['hlc3'] = (df['high']+df['low']+df['close'])/3
df['esa'] = talib.EMA(df.hlc3, 10)
df['d'] = talib.EMA(abs(df.hlc3 - df.esa), 10)
df['ci'] = (df['hlc3'] - df['esa']) / (0.015*df['d'])
@binhna
binhna / routers.py
Last active October 23, 2020 02:29
Flask API boilerplate
from flask import Flask, request, jsonify
from flask_bootstrap import Bootstrap
from flask_cors import CORS
import torch
import pickle
from infer_chunking import load_model, infer_sentence
task_er, model_er, is_cuda = load_model()
app = Flask(__name__)
@binhna
binhna / download.py
Created November 22, 2019 07:13
Download a file with tqdm
from tqdm import tqdm
import requests
url = "http://www.ovh.net/files/10Mb.dat" #big file test
file_name = url.split('/')[-1]
# Streaming, so we can iterate over the response.
r = requests.get(url, stream=True)
# Total size in bytes.
total_size = int(r.headers.get('content-length', 0))
block_size = 1024 #1 Kibibyte
@binhna
binhna / google_drive_downloader.py
Created October 25, 2019 01:32
python google_drive_downloader.py id name_out.zip
from tqdm import tqdm as tqdm
from argparse import ArgumentParser
import requests
def download_file_from_google_drive(id, destination):
def get_confirm_token(response):
for key, value in response.cookies.items():
if key.startswith('download_warning'):
return value
@binhna
binhna / countries - 国
Created August 14, 2019 08:37
List name of countries in Japanese - 国名のリストを日本語で
アフガニスタン
アルバニア
アルジェリア
アンドラ
アンゴラ
アンチグア・バーブーダ
アルゼンチン
アルメニア
オーストラリア
オーストリア