Skip to content

Instantly share code, notes, and snippets.

View xsthunder's full-sized avatar
💪
working

xsthunder

💪
working
  • everywhere
View GitHub Profile
@xsthunder
xsthunder / learn-beam-search-su.py
Created March 18, 2021 01:55
su's single batch version for beam search
#!/usr/bin/env python
# coding: utf-8
# # 学习 bean search
#
# ## ref
#
# [xueke.fm 束搜索](https://kexue.fm/archives/7500/comment-page-1)
#
# [C5W3L03 Beam Search - YouTube](https://www.youtube.com/watch?v=RLWuzLLSIgw)
.container{
width: 500px;
display: flex;
flex-direction: column;
background: yellow;
text-align: center;
}
.container-eachline{
margin-top: 10px;
margin-bottom: 10px;
.container{
width: 500px;
display: flex;
flex-direction: column;
background: yellow;
}
.container-eachline{
display: flex;
flex-direction: row;
margin-top: 10px;
@xsthunder
xsthunder / dict_in_insertation_order.py
Last active June 2, 2020 10:48
dict orders its key-value pairs in insertation order from python 3.7
# for each value(which is a dict) of input0, reorder the value dict in ascending order constructing output
import sys
assert float(sys.version[:3]) >= 3.7, """
this code only available from python version 3.7, see following for detail
https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6/39980744
dict orders its key-value pairs in insertation order
"""
input0 = {
'a':{
// in main.js
import Router from 'vue-Router'
vue.use(Router)
const originalPush = router.push
router.push = function(obj, ...params){
const current = this.history.current
// console.log(this, current)
const currentPath = current.path
const prefix = "/simed/"
if(obj instanceof Object && obj['doNotHack'] !== true){
/**
* recursively resolve children if exits
* obj = {
* name,
* icon,
* } ->{
* ...obj,
* meta:{title:name, icon:icon}
* }
* @param Object obj
@xsthunder
xsthunder / tqdm.py
Created April 28, 2019 11:30
tqdm.py
from tqdm import tdqm
for i in tqdm(range(100)):
print(i)
@xsthunder
xsthunder / split_and_match.py
Last active March 16, 2019 02:49
split str by regex,search each str with regex using grouping
# for splitting by regex see https://blog.csdn.net/programmer_at/article/details/77409507
spliters = [
r';',
]
reg = '(胰腺|肝脏)(.+)'
key_names=['部位','情况']
text = '胰腺未见局灶性占位。; 肝脏未见明显局灶性占位。;yes'
import re
def f(spliters, reg, key_names, text, throw_on_unmatch = False):
arr = re.split('|'.join(
@xsthunder
xsthunder / calling-an-external-command.py
Created February 28, 2019 07:58
Calling an external command in Python
# https://stackoverflow.com/questions/89228/calling-an-external-command-in-python
import subprocess
subprocess.run(["ls", "-l"])
@xsthunder
xsthunder / to_number.py
Created February 28, 2019 05:32
encode string to number and decode number
class To_Number:
def __init__(self, start_of_index = 0, ):
self.end_of_index = start_of_index
self.start_of_index = start_of_index
self.dict={}
self.decode_dict={}
def add(self, ele):
if ele not in self.dict:
self.dict[ele] = self.end_of_index
self.decode_dict[self.end_of_index] = ele