Skip to content

Instantly share code, notes, and snippets.

Avatar

Dingyuan Wang gumblex

  • Shanghai, China
View GitHub Profile
@gumblex
gumblex / num2chinese.py
Created Feb 8, 2015
Numbers to Chinese representations converter in Python. 中文数字转换
View num2chinese.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Licensed under WTFPL or the Unlicense or CC0.
# This uses Python 3, but it's easy to port to Python 2 by changing
# strings to u'xx'.
import itertools
def num2chinese(num, big=False, simp=True, o=False, twoalt=False):
@gumblex
gumblex / 词性标记.md
Last active Jul 6, 2020 — forked from luw2007/词性标记.md
词性标记: 包含 ICTPOS3.0词性标记集、ICTCLAS 汉语词性标注集、jieba 字典中出现的词性、simhash 中可以忽略的部分词性
View 词性标记.md

词的分类

  • 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
  • 虚词:副词、介词、连词、助词、拟声词、叹词。

ICTPOS3.0词性标记集

n 名词
	nr 人名
@gumblex
gumblex / zip64.py
Created Nov 14, 2015
Simple Python command line utility to create Zip64 files.
View zip64.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Simple command line utility to create Zip64 files.
For Python 3.3+
Most code are from the standard library `zipfile` and `shutil`.
"""
@gumblex
gumblex / 69-language-selector-zh-cn.conf
Created Feb 16, 2014
Ubuntu 界面中文字体fontconfig配置:文泉驿微米黑
View 69-language-selector-zh-cn.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<match target="pattern">
<test name="lang">
<string>zh-cn</string>
</test>
<test qual="any" name="family">
<string>serif</string>
@gumblex
gumblex / copytime.sh
Created May 22, 2016
Recursively restore file mtime from backup
View copytime.sh
#!/bin/bash
find . -type f -print0 | while IFS= read -r -d $'\0' filename; do
if [ -f "$1/$filename" ]; then
echo touch -r "$1/$filename" "$filename"
touch -r "$1/$filename" "$filename"
else
echo "$1/$filename" not exist
fi
done
@gumblex
gumblex / PathFitter.py
Created Apr 4, 2015
Path fitter in Python - An Algorithm for Automatically Fitting Digitized Curves
View PathFitter.py
"""
Ported from Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
http://paperjs.org/
Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey
http://scratchdisk.com/ & http://jonathanpuckey.com/
Distributed under the MIT license. See LICENSE file for details.
All rights reserved.
@gumblex
gumblex / ansi_mandelbrot.py
Created May 5, 2016
Mandelbrot ASCII art from PyPy (independent version)
View ansi_mandelbrot.py
import os
import sys
import colorsys
"""
Black 0;30 Dark Gray 1;30
Blue 0;34 Light Blue 1;34
Green 0;32 Light Green 1;32
Cyan 0;36 Light Cyan 1;36
Red 0;31 Light Red 1;31
@gumblex
gumblex / progress-all.sh
Created May 3, 2017
Find out each file position opened by a process
View progress-all.sh
#!/bin/bash
for fd in /proc/$1/fd/*; do
if [ ! -f "$fd" ]; then continue; fi
fdnum=$(basename "$fd")
fdinfo=/proc/$1/fdinfo/$fdnum
name=$(readlink "$fd")
size=$(stat -c "%s" "$name" 2>/dev/null || stat -c "%s" "$fd")
progress=$(grep ^pos "$fdinfo" | awk '{print $2}')
if [ $size -eq "0" ]; then
echo '['$fdnum']' "$name"':' $progress'/'$size
@gumblex
gumblex / urlrename.py
Created Feb 16, 2017
Simple script to get rid of url escaped filenames.
View urlrename.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import urllib.parse
for f in sys.argv[1:]:
os.rename(f, urllib.parse.unquote_plus(f))
@gumblex
gumblex / ssl.py
Created Jul 23, 2016
Patched ssl.py for PyPy3.3 with modern OpenSSL
View ssl.py
# Wrapper module for _ssl, providing some additional facilities
# implemented in Python. Written by Bill Janssen.
"""This module provides some more Pythonic support for SSL.
Object types:
SSLSocket -- subtype of socket.socket which does SSL over the socket
Exceptions:
You can’t perform that action at this time.