Skip to content

Instantly share code, notes, and snippets.

View Elfsong's full-sized avatar
😃
Excelsior

Mingzhe Elfsong

😃
Excelsior
View GitHub Profile
@Elfsong
Elfsong / git_stat.sh
Created June 11, 2020 16:22
Git info statistic
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --since ==2020–05-02 --until=2018-06-11 --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
@Elfsong
Elfsong / esim.py
Created May 18, 2019 02:46 — forked from namakemono/esim.py
Implementation of ESIM(Enhanced LSTM for Natural Language Inference)
"""
Implementation of ESIM(Enhanced LSTM for Natural Language Inference)
https://arxiv.org/abs/1609.06038
"""
import numpy as np
from keras.layers import *
from keras.activations import softmax
from keras.models import Model
def StaticEmbedding(embedding_matrix):
@Elfsong
Elfsong / server.java
Created April 19, 2019 03:56
Sent file in blocksize
// TODO: FILE_BYTES_REQUEST
for (int initial_position = 0; initial_position < qq.fileDescriptor.fileSize; ) {
long offset = 0;
long remained = qq.fileDescriptor.fileSize - initial_position;
if (remained > blockSize) {
offset = blockSize;
} else {
offset = remained;
@Elfsong
Elfsong / combinations pair
Created April 2, 2019 05:09
Musician pairs
(_,_,_) -> (0,_,_) = remove all three pitchs
(_,_,_) -> (a,b,c) = a + b == 3 or a + c == 3 retrive all three notes or octaves
@Elfsong
Elfsong / split_story_dialogue.py
Created March 26, 2019 07:49
故事对话分割
import json
import os
import re
import jieba
ROOT_PATH = "/Users/elfsong/PycharmProjects/BERT_demo"
RESOURCE_PATH = os.path.join(ROOT_PATH, "Test text")
@Elfsong
Elfsong / V_Byte_V1.py
Created March 25, 2019 12:53
V_Byte#python
def vbyte_encode(num):
# out_bytes stores a list of output bytes encoding the number
out_bytes = []
###
# Your answer BEGINS HERE
###
while num >= 128:
out_bytes = [num % 128] + out_bytes
@Elfsong
Elfsong / average_split.py
Last active March 11, 2019 07:41
优雅地均匀分割字符串
def avsplit1(s, n):
fn = len(s)//n
rn = len(s)%n
ar = [fn+1]*rn+ [fn]*(n-rn)
si = [i*(fn+1) if i<rn else (rn*(fn+1)+(i-rn)*fn) for i in range(n)]
sr = [s[si[i]:si[i]+ar[i]] for i in range(n)]
return sr
def avsplit2(s, n):
fn = len(s)//n
@Elfsong
Elfsong / pinyin
Created March 4, 2019 12:13
pinyin
# coding: utf-8
import ast
import clr
import json
import os
import re
from StoryTelling.tts import append_pronunciation
from StoryTelling.tts.tools import OnlineTts
from Speech.Cognitive.Services import TimeLine
@Elfsong
Elfsong / movie_studio.py
Created February 19, 2019 12:06
movie_studio
import os
import time
from multiprocessing import Process
import cocos
import cv2
import numpy as np
import pyglet
from PIL import ImageGrab
from cocos.actions import CallFunc
@Elfsong
Elfsong / excel_reader
Created January 26, 2019 06:11
Excel Reader #spreadsheet #python
import os
import xlrd
ROOT_PATH = r"C:\Users\t-midu\PycharmProjects\Scenario"
RESOURCE_PATH = os.path.join(ROOT_PATH, "resource")
file_path = os.path.join(RESOURCE_PATH, "sentence_class.xls")
data = xlrd.open_workbook(file_path)