Skip to content

Instantly share code, notes, and snippets.

@zhenyi2697
zhenyi2697 / gist:1973973
Created March 4, 2012 17:21 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@zhenyi2697
zhenyi2697 / python_start_up.py
Created February 17, 2013 09:33
Python: start up
#!/usr/bin/python
# This is a start up list for python
# It will be used to quickly review the basic syntaxes and operations of python
# Code summerized from "简明 Python 教程" : http://woodpecker.org.cn/abyteofpython_cn/chinese/index.html
# Usually, python command options begin with two -- , e.g. --version --help
# Python Use True & False for boolean values
@zhenyi2697
zhenyi2697 / DateOperation.java
Created February 17, 2013 20:09
Java: Date operation
import java.util.Date;
import java.text.SimpleDateFormat;
import java.sql.Timestamp;
import java.lang.StringBuffer;
public class DateOperation{
private Date date;
public DateOperation(){
@zhenyi2697
zhenyi2697 / mou.md
Created February 17, 2013 20:10
markdown: mou demo

Mou

Mou icon

Overview

Mou, the missing Markdown editor for web developers.

Syntax

@zhenyi2697
zhenyi2697 / markdown.md
Created February 17, 2013 20:10
markdown: start up list

#Big Title

##Second big title

third big title

###分隔符:


###链接:

@zhenyi2697
zhenyi2697 / gist:5023355
Created February 24, 2013 10:32
Python: unicode conversion
#!/usr/bin/python
# To convert a Unicode string into an 8-bit string using a specific encoding, Unicode objects provide an encode() method that takes one argument, the name of the encoding. Lowercase names for encodings are preferred.
u"äöü".encode('utf-8')
# '\xc3\xa4\xc3\xb6\xc3\xbc'
# If you have data in a specific encoding and want to produce a corresponding Unicode string from it, you can use the unicode() function with the encoding name as the second argument.
unicode('\xc3\xa4\xc3\xb6\xc3\xbc', 'utf-8')
@zhenyi2697
zhenyi2697 / gist:5023358
Created February 24, 2013 10:36
Python: list slice - insert and clear
>>> # Replace some items:
... a[0:2] = [1, 12]
>>> a
[1, 12, 123, 1234]
>>> # Remove some:
... a[0:2] = []
>>> a
[123, 1234]
>>> # Insert some:
... a[1:1] = ['bletch', 'xyzzy']
@zhenyi2697
zhenyi2697 / gist:5023390
Created February 24, 2013 10:49
Python: Simple Fibonacci Sequences
>>> a, b = 0, 1
>>> while b < 1000:
... print b,
... a, b = b, a+b
...
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
@zhenyi2697
zhenyi2697 / gist:5028927
Created February 25, 2013 10:18
Vim: .vimrc
:set ai
:set hlsearch
:set nu
:set ts=4
:set expandtab
:%retab!
@zhenyi2697
zhenyi2697 / gist:5029778
Last active December 14, 2015 04:39
MySQL: connect to mysql using command
mysql -u root -p ENTER
CREATE DATABASE django CHARACTER SET utf8;