Skip to content

Instantly share code, notes, and snippets.

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

Minglei Yin axhiao

🏠
Working from home
View GitHub Profile
@axhiao
axhiao / testRegex.js
Created August 16, 2024 06:37 — forked from hanxiao/testRegex.js
Regex for chunking by using all semantic cues
// Updated: Aug. 15, 2024
// Run: node testRegex.js testText.txt
// Used in https://jina.ai/tokenizer
const fs = require('fs');
const util = require('util');
// Define variables for magic numbers
const MAX_HEADING_LENGTH = 7;
const MAX_HEADING_CONTENT_LENGTH = 200;
const MAX_HEADING_UNDERLINE_LENGTH = 200;
@axhiao
axhiao / fusion.py
Last active July 28, 2020 20:24
fusion model
mods = {
"resnet50": (torchvision.models.resnet50, 2048),
"resnet152": (torchvision.models.resnet152, 2048),
"densenet121": (torchvision.models.densenet121, 1024*7*7),
"densenet201": (torchvision.models.densenet201, 1920*7*7),
"vgg16": (torchvision.models.vgg16, 512*7*7),
}
MOD = "densenet201"
class Fusion2Model(nn.Module):
@axhiao
axhiao / lambda
Created September 26, 2019 17:32
lambda
LAMBDA_REPO=$(mktemp) && \
wget -O${LAMBDA_REPO} https://lambdalabs.com/static/misc/lambda-stack-repo.deb && \
sudo dpkg -i ${LAMBDA_REPO} && rm -f ${LAMBDA_REPO} && \
sudo apt-get update && sudo apt-get install -y lambda-stack-cuda
@axhiao
axhiao / gist:c54c10ec125e077b4213cdbca92e20c1
Created July 7, 2016 01:51
my question about mysql get_lock
here is my application scenario: assuming there is a table in mysql, named orders including 4 fields(id, orderid, money, type), everytime I pick the last item of each orderid to manipulate. For examle, i choose one order whose orderid=777, i.e. this item (3, 777, 34.00, 1), to consume $2.00. Then this item firstly is changed into (3, 777, 34.00, 0), and then I insert one row into the table (4, 777, 32.00, 1).
But with the concurrency, there are probably two sessions to select the item(3, 777, 34.00, 1) at the same time, then consume $2.00 based on the same item. Now I totally have items (3, 777, 34.00, 0), (4, 777, 32.00, 1), (5, 777, 32.00, 1). Normally, everytime it should consume money based on the very last item of the order, i.e., (3, 777, 34.00, 0), (4, 777, 32.00, 0), (5, 777, 30.00, 1)
last = getInfoByOrderId(orderid, type);
//...
// if last does not satisfy some conditon, then return or throw exceptions directly
//...
explain select * from amortize_order_info_3 force index(PRIMARY) where source_sys = 'pmc' and order_create_gmt >= '2016-03-08 00:00:00' and order_create_gmt<= '2016-03-08 23:59:59' and id >10152664498617 order by id asc limit 1000;
+----+-------------+-----------------------+-------+---------------+---------+---------+------+----------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------------------+-------+---------------+---------+---------+------+----------+-------------+
| 1 | SIMPLE | amortize_order_info_3 | range | PRIMARY | PRIMARY | 8 | NULL | 30924473 | Using where |
+----+-------------+-----------------------+-------+---------------+---------+---------+------+----------+-------------+