Skip to content

Instantly share code, notes, and snippets.

View vanryan's full-sized avatar

Shane Z vanryan

  • San Francisco
View GitHub Profile
@vanryan
vanryan / EncodedFileToUTF-8File.py
Created May 14, 2018 04:15
Convert other encoding encoded file to a UTF-8 file, E.G => gb18030 (Chinese) to UTF-8
import codecs
# input file chunk size in bytes
BLOCKSIZE = 120000
sourceFileName = "moto_file.txt"
targetFileName = "atarashii_file.txt"
with codecs.open(sourceFileName, "r", "gb18030") as sourceFile:
with codecs.open(targetFileName, "w", "utf-8") as targetFile:
while True:
contents = sourceFile.read(BLOCKSIZE)
if not contents:
@vanryan
vanryan / .gitconfig
Last active March 19, 2024 07:34
~/.gitconfig
[user]
email = xxxx@xxx.com
name = xxxx
[core]
excludesfile = ~/.gitignore_global
editor = vim
[alias]
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
cm = commit
cmm = commit -m
@vanryan
vanryan / .bashrc
Last active September 6, 2017 19:18
Debian .bashrc setup
# A general Debian .bashrc setup
# Author: freenik
#
#
# do 'source ~/.bashrc' in '~/.bash_profile' or '~/.bash_login' to auto load .bashrc
#
#
GREEN="\[$(tput setaf 2)\]"
@vanryan
vanryan / Cartesian_prod_itertools.py
Created July 17, 2016 21:06
Computes the cartesian product of input iterables using itertools
from itertools import product
A = map(int,raw_input().split())
B = map(int,raw_input().split())
A.sort()
B.sort()
res = product(A, B)
# you can also get res from