Skip to content

Instantly share code, notes, and snippets.

View selfboot's full-sized avatar
🎯
Focusing

selfboot selfboot

🎯
Focusing
View GitHub Profile
@selfboot
selfboot / install.sh
Created June 15, 2013 03:47
YouCompleteMe 安装问题
➜ YouCompleteMe git:(master) ✗ pwd
/Users/xuelang/.vim/bundle/YouCompleteMe
➜ YouCompleteMe git:(master) ✗ ls
CONTRIBUTING.md README.md cpp install.sh python
COPYING.txt autoload doc plugin style_format.sh
➜ YouCompleteMe git:(master) ✗ git submodule update --init --recursive
@selfboot
selfboot / compile_vim.md
Last active December 18, 2015 12:59
手动编译vim

可能要先删除已经安装的vim:

sudo apt-get remove vim vim-runtime gvim

ubuntu12.04上可能还要删除以下包:

sudo apt-get remove vim-tiny vim-common vim-gui-common

然后安装依赖:

@selfboot
selfboot / bubble_sort.py
Last active August 29, 2015 14:04
冒泡排序的python实现。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
original_sequence = raw_input("Enter the sequence: ")
sequence_str = original_sequence.split()
sort_sequence = []
for number_str in sequence_str:
sort_sequence.append(int(number_str))
count = len(sort_sequence)
@selfboot
selfboot / insertion_sort.py
Created July 27, 2014 04:28
插入排序的python实现。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
original_sequence = raw_input("Enter the sequence: ")
sequence_str = original_sequence.split()
sort_sequence = []
for number_str in sequence_str:
sort_sequence.append(int(number_str))
count = len(sort_sequence)
@selfboot
selfboot / quick_sort.py
Created July 27, 2014 04:29
快速排序的python实现
#! /usr/bin/env python
# -*- coding: utf-8 -*-
def quick_sort(sequence, start_index, end_index):
# print sequence
if start_index < end_index:
main_element = partition(sequence, start_index, end_index)
# print main_element
quick_sort(sequence, start_index, main_element-1)
@selfboot
selfboot / trie_tree.py
Last active August 29, 2015 14:04
简单字典树的实现。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
class Trie_tree():
def __init__(self):
# node = [father, child, keep_char, is_word]
self._root = [None, [], None, False]
def insert(self, word):
@selfboot
selfboot / stack.py
Created August 5, 2014 13:45
Stack的简单实现。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# This is a Stack implementing in list.
class Stack():
def __init__(self):
self._content = list()
def __len__(self):
@selfboot
selfboot / queue.py
Created August 5, 2014 13:46
Queue 的简单实现
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# This is a Queue implementing in list.
class Queue():
def __init__(self):
self._content = list()
def __len__(self):
@selfboot
selfboot / decorator_cache.py
Created August 10, 2014 10:01
用装饰器实现缓存机制,避免斐波那契数列递归实现中的重复调用,然后比较存在缓存和没有缓存下的运行时间。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from functools import wraps
def fib_direct(n):
assert n > 0, 'invalid n'
if n < 3:
@selfboot
selfboot / trie_pre_match.py
Created August 12, 2014 15:08
字典树实现前缀匹配。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
class Trie_tree():
def __init__(self):
# node = [father, child, keep_char, is_word]
self._root = [None, [], None, False]
def insert(self, word):