Skip to content

Instantly share code, notes, and snippets.

@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)
source "https://rubygems.org"
gem "rake"
# Screens
gem "ProMotion"
gem 'motion-layout'
@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;
@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 / 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 / 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 / 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.c
Created September 5, 2014 14:00
how to implement insert sort using c
#include <stdio.h>
int main() {
int arr[] = {1, 8, 9, 4, 8, 7, 2, 3, 4, 90, 34};
int len = sizeof(arr) / sizeof(arr[0]);
int i;
for(i = 1; i < len - 1; i++) {
int key = arr[i];
int j = i - 1;
while(arr[j] > key && j >=0) {
@easonhan007
easonhan007 / pyunit_start_point.py
Created October 26, 2014 11:42
pyunit start point
#coding: utf-8
import unittest
from selenium import webdriver
import time
class LoginCase(unittest.TestCase):
def setUp(self): #每个用例执行之前执行
print 'before test'
@easonhan007
easonhan007 / stock_config.rb
Created December 15, 2014 07:57
tableless没有数据库table的model
class StockConfig
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
include Virtus.model
attribute :money, Integer
attribute :month, Integer
attribute :policy_id, Integer