Skip to content

Instantly share code, notes, and snippets.

@easonhan007
easonhan007 / insert_sort.py
Created September 5, 2014 09:24
how to implment insert sort using python
# insert sort using python
def insert_sort(the_list):
for i in range(1,len(the_list)):
print 'key is %d' %(key)
current = i - 1
while the_list[current] > key and current >= 0:
the_list[current + 1] = the_list[current]
current = current - 1
@easonhan007
easonhan007 / insert_sort.rb
Created September 5, 2014 09:00
how to implement insert sort using ruby
# insert sort using ruby
def insert_sort(array)
(1..array.size-1).each do |index|
key = array[index]
j = index - 1
while key < array[j] && j >= 0
array[j + 1] = array[j]
j = j-1
end #while
@easonhan007
easonhan007 / queue.js
Created September 4, 2014 09:39
implement queue using js and some examples
function Queue() {
this.dataSource = [];
this.enqueue = enqueue;
this.dequeue = dequeue;
this.front = front;
this.back = back;
this.toString = toString;
this.empty = empty;
@easonhan007
easonhan007 / insert_sort.js
Created September 2, 2014 03:49
insert sort using javascript and run it using node
// insert sort implement using javascript
function print(what) {
console.log(what);
}
function insertSort(array) {
var currentPos, before;
for(currentPos = 1; currentPos < array.length; currentPos++) {
@easonhan007
easonhan007 / stack.js
Created September 1, 2014 09:19
How to implement a stack using javascript
function Stack() {
this.dataSource = [];
this.top = 0;
this.push = push;
this.pop = pop;
this.peek = peek;
this.clear = clear;
this.length = length;
function push(element) {
@easonhan007
easonhan007 / list.js
Created September 1, 2014 08:21
How to implement list data structure using javascript
function List() {
this.listSize = 0;
this.pos = 0;
this.dataSource = [];
this.clear = clear;
this.find = find;
this.toString = toString;
this.insert = insert;
this.append = append;
this.remove = remove;
source "https://rubygems.org"
gem "rake"
# Screens
gem "ProMotion"
gem 'motion-layout'
@easonhan007
easonhan007 / how_to_use_jquery.py
Created June 23, 2014 10:58
python selenium中使用jquery
# -*- coding: utf-8 -*-
from selenium import webdriver
import time
import unittest
dr = webdriver.Chrome()
dr.get("http://192.168.10.21:28080/admin/tag/list.do")
jqueryPath = 'D:/jquery-1.7.1.js'
jqueryFile = open(jqueryPath)
@easonhan007
easonhan007 / create_post.py
Created January 25, 2014 03:54
how to test wordpress using python unittest
import unittest
from selenium import webdriver
import time
from time import sleep
class WordPressTestCase(unittest.TestCase):
dr = None
login_url = 'http://localhost/wordpress/wp-login.php'
post_list_url = 'http://localhost/wordpress/wp-admin/edit.php'
@easonhan007
easonhan007 / test_api.py
Created December 28, 2013 08:57
how to use python to test a json based api
import unittest, httplib, urllib, json
class ApiTestCase(unittest.TestCase):
def setUp(self):
self.conn = httplib.HTTPConnection('localhost', 5000)
def tearDown(self):
if self.conn is not None: self.conn.close()
def get(self, path='/'):