Skip to content

Instantly share code, notes, and snippets.

@guori12321
guori12321 / gist:4950447
Created February 14, 2013 03:38
Ray12321's gvimrc
""""""""""""""""基本设置"""""""""""""""""
"编辑非utf8文件时通过fileencoding来转码
set encoding=utf-8
"使用中文菜单,并使用 UTF-8 编码。如果没有这句的话,在非 UTF-8 的系统,如 Windows 下,用了 UTF-8 的 encoding 后菜单会乱码。
set langmenu=zh_CN.UTF-8
"使用中文提示信息,并使用 UTF-8 编码。如果没有这句的话,在非 UTF-8 的系统,如 Windows 下,用了 UTF-8 的 encoding 后系统提示会乱码。
language message zh_CN.UTF-8
@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!
imap <C-H> <Left>
imap <C-J> <Down>
imap <C-K> <Up>
imap <C-L> <Right>
UnBundle 'scrooloose/syntastic'
@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()
@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
最通用的做法是,在程序的前面加上
# -*- coding: utf-8 -*-
import sys
reload(sys) # reload 才能调用 setdefaultencoding 方法
sys.setdefaultencoding('utf-8') # 设置 'utf-8'
第一行注释是程序本身的编码,就是说在代码中如果有汉字的字条串,一样可以识别。下面的几行,是使程序内部使用utf-8编码。这样,读写文件,和在mac的终端中重定向输出都没问题。
如果没有后三行,在处理utf-8字条串时,要用
" Modeline and Notes {
" vim: set sw=4 ts=4 sts=4 et tw=78 foldmarker={,} foldlevel=0 foldmethod=marker spell:
"
" __ _ _____ _
" ___ _ __ / _/ |___ / __ __(_)_ __ ___
" / __| '_ \| |_| | |_ \ _____\ \ / /| | '_ ` _ \
" \__ \ |_) | _| |___) |_____|\ V / | | | | | | |
" |___/ .__/|_| |_|____/ \_/ |_|_| |_| |_|
" |_|
"
""""""""""" 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
#!/usr/bin/python
from pyPdf import PdfFileWriter, PdfFileReader
import glob
for filename in glob.glob(r'./in/*'):
print filename
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{