Skip to content

Instantly share code, notes, and snippets.

@guori12321
guori12321 / Justwriting_New
Created May 30, 2015 22:12
一个为JustWriting新建中文题目博文的小脚本
#!/usr/bin/env python
import sys
import time
from pypinyin import pinyin, lazy_pinyin
import pypinyin
py = lazy_pinyin(unicode("_".join(sys.argv[1:]), "utf-8"))
fileName = ''.join(py)
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
#!/usr/bin/python
from pyPdf import PdfFileWriter, PdfFileReader
import glob
for filename in glob.glob(r'./in/*'):
print filename
""""""""""" Encoding, to make sure the Chinese words looks nice
set encoding=utf-8
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
scriptencoding utf-8
""""""""""" Common Setting
set wrap
set guifont=Menlo\ Regular:h24
set display=lastline
" Modeline and Notes {
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
"
" __ _ _____ _
" ___ _ __ / _/ |___ / __ __(_)_ __ ___
" / __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \
" \__ \ |_) | _| |___) |_____|\ V / | | | | | | |
" |___/ .__/|_| |_|____/ \_/ |_|_| |_| |_|
" |_|
"
最通用的做法是,在程序的前面加上
# -*- coding: utf-8 -*-
import sys
reload(sys) # reload 才能调用 setdefaultencoding 方法
sys.setdefaultencoding('utf-8') # 设置 'utf-8'
第一行注释是程序本身的编码,就是说在代码中如果有汉字的字条串,一样可以识别。下面的几行,是使程序内部使用utf-8编码。这样,读写文件,和在mac的终端中重定向输出都没问题。
如果没有后三行,在处理utf-8字条串时,要用
@guori12321
guori12321 / .vimrc.local
Created October 29, 2013 10:11
My `.vimrc.local` of `spf13`.
""""""""""" Encoding, to make sure the Chinese words looks nice
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
""""""""""" Common Setting
set wrap
set guifont=Menlo\ Regular:h28
set display=lastline
@guori12321
guori12321 / utf-8_python_file
Created October 15, 2013 02:18
how to read utf-8 file with python
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
readFile = open('test.txt', 'r')
print readFile.read()
imap <C-H> <Left>
imap <C-J> <Down>
imap <C-K> <Up>
imap <C-L> <Right>
UnBundle 'scrooloose/syntastic'
@guori12321
guori12321 / .gvimrc
Created May 3, 2013 03:23
My .gvimrc. I tried to install `Conque-Shell` via Vundle, but it showed that 'ConqueTerm: Not an edit command'.
"""""""""""""""""""""插件管理,使用Bundle
"Vundle
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
" let Vundle manage Vundle
" required!