Skip to content

Instantly share code, notes, and snippets.

View selfboot's full-sized avatar
🎯
Focusing

selfboot selfboot

🎯
Focusing
View GitHub Profile
@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 / 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):
@selfboot
selfboot / article.txt
Created August 12, 2014 15:11
用字典树实现字频统计。
9 Mac OS X Port Command Examples to Install and Update Packages
by Sanjay Kumar, thegeekstuff.comJanuary 23
Port is a terminal command utility which is used to update open source software on Mac OS X.
The port command is bundled as part of MacPorts Framework.
You can install port command either by downloading and installing the binary version for your corresponding Mac OS X, or by downloading the source code and compiling it on your OS X version.
The binary file of MacPorts for various version of OSX are available here. Once you download the binary version, just click on the package to install it. You should have administrator right on your system to install it. X-code is pre-req for MacPorts. If you don’t have X-code on your system, it will display a warning message.
[General]
loglevel = notify
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 127.0.0.0/8, 100.64.0.0/10, localhost, *.local, e.crashlytics.com
bypass-tun = 192.168.0.0/16, 0.0.0.0/8, 1.0.0.0/9, 1.160.0.0/11, 1.192.0.0/11, 10.0.0.0/8, 14.0.0.0/11, 14.96.0.0/11, 14.128.0.0/11, 14.192.0.0/11, 27.0.0.0/10, 27.96.0.0/11, 27.128.0.0/9, 36.0.0.0/10, 36.96.0.0/11, 36.128.0.0/9, 39.0.0.0/11, 39.64.0.0/10, 39.128.0.0/10, 42.0.0.0/8, 43.224.0.0/11, 45.64.0.0/10, 47.64.0.0/10, 49.0.0.0/9, 49.128.0.0/11, 49.192.0.0/10, 54.192.0.0/11, 58.0.0.0/9, 58.128.0.0/11, 58.192.0.0/10, 59.32.0.0/11, 59.64.0.0/10, 59.128.0.0/9, 60.0.0.0/10, 60.160.0.0/11, 60.192.0.0/10, 61.0.0.0/10, 61.64.0.0/11, 61.128.0.0/10, 61.224.0.0/11, 100.64.0.0/10, 101.0.0.0/9, 101.128.0.0/11, 101.192.0.0/10, 103.0.0.0/10, 103.192.0.0/10, 106.0.0.0/9, 106.224.0.0/11, 110.0.0.0/7, 112.0.0.0/9, 112.128.0.0/11, 112.192.0.0/10, 113.0.0.0/9, 113.128.0.0/11, 113.192.0.0/10, 114.0.0.0/9, 114.128.0.0/11, 114.192.0.0/10, 115.0.0.0/8, 116.0.0.0/8, 117.0.0.0/9,
@selfboot
selfboot / 7B.R
Last active November 8, 2015 07:05
Mining Massive Datasets Quiz Week7B Basic.
# Question 1
# Suppose we have an LSH family h of (d1,d2,.6,.4) hash functions.
# We can use three functions from h and the AND-construction to form a (d1,d2,w,x) family,
# and we can use two functions from h and the OR-construction to form a (d1,d2,y,z) family.
# Calculate w, x, y, and z, and then identify the correct value of one of these in the list below.
matrix_m <- matrix(c(0,0.5,0.5,0,1,0,0,0,0,0,0,1,0,0,1,0) * 0.7,4,4)
beta_set <- matrix(c(2/3,1/3,0,0,2/3,1/3,0,0,2/3,1/3,0,0,2/3,1/3,0,0) * 0.3, 4, 4)
a <- matrix_m + beta_set