2015年11月26日 星期四

有趣的gif動態圖

圖皆為網路上擷取,如有侵權請告知:





  
 

2015年10月20日 星期二

Run demo of Selenium2Library (Robotframework)

1. Download Selenium2Library.zip
https://github.com/robotframework/Selenium2Library

2. Unzip Selenium2Library.zip, we only need "demo" folder.
copy demo folder to any path.

 ============= Run demo using command line =================

a. open windows command line and change location to your demo path.
ex. cd F:/Project/demo

b. use commands on windows command line:
rundemo.py login_tests

Finished.

 ============= Run demo using Robotframework-RIDE ===========

a. open windows command line, enter:
ride.py

b. File->Open Directory, select demo folder

c. Start demp webpage :
open windows command line, change path to \demoo\demoapp, enter :
>server.py start

d. Select testsuite you want to test and click Run->start on right tab page.


Finished.

Robotframework install on windows

1. Install python 2.7.10
https://www.python.org/downloads/
install python-2.7.10.msi

P.S. Also select install python to system path.

2. Install Robotframework
https://pypi.python.org/pypi/robotframework
select robotframework-2.9.2.win32.exe

3. Install Robotframework-RIDE (IDE) 
open windows command line, enter :
pip install robotframework-ride

4. Install wxPython : You need to install wxPython 2.8.12.1 with unicode support to run RIDE.
http://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/

select wxPython2.8-win32-unicode-2.8.12.1-py27.exe

5. Start Robotframework-RIDE :
open windows command line, enter:
ride.py

==================================================
6. Another libs
pip install requests
pip install robotframework-requests
pip install robotframework-selenium2library 

P.S. Import library of requests should use work: RequestsLibrary 


Finish.


嬰兒黑白卡高解析

自製黑白卡,抓取網路上低解析度照片手動修圖放大,有需要可自取:





Upgrade python to 2.7.x on Ubuntu 10.04 (pyton 3.2 also available)

$ python -V ##current version
python 2.6.5
$ curl -kL https://raw.github.com/utahta/pythonbrew/master/pythonbrew-install | bash

##must use this command to make install pythonbrew completely 
$ echo "source ~/.pythonbrew/etc/bashrc" >> ~/.bashrc 

##add pythonbrew to system path 
$ sudo echo export PATH=\"\$PATH:~/.pythonbrew/bin\" >> /etc/profile
 
##this command will take a long time depend on your computer becasue it will compile
##python to install. You can use "top" to check cpu rate. 
$ pythonbrew install 2.7.2 

##After installed, switch to python 2.7.2 
$ pythonbrew switch 2.7.2
switched to Python-2.7.2
$ python -V
python 2.7.2

2015年10月14日 星期三

Python學習筆記

1. Display python version:
python -V

2. Python help:
python
>>>help('len')  ## help for 'len'
>>>help()         ## enter help mode
help>return      ## help for 'return'
...................
help>q              ## return to python mode
>>>

3. Comments
In python are using # as comment symbol.

4. Single Quote '' and Double Quotes ""
Strings in double quotes work exactly the same way as strings in single quotes.
You can use triple quotes - (""" or ''') for specify multi-line strings. An example is:
''' This is a multi-line string. This is first line.
This is second line.
"How are you?," I asked.
He said "I'm fine."
'''

5. Strings are Immutable
Can not change string after created.

6. Concat strings in python
Example:
age = 20
name = 'Wayne'
print '{0} was {1} years old'.format(name, age)
print 'Why is {0} playing with that python?'.format(name)

print name + ' is ' + str(age) + ' years old too'

print 'My name is', name


Output:
Wayne was 20 years old when he wrote this book
Why is Wayne playing with that python?

Wayne is 20 years old too
My name is Wayne

 7. Special char in strings
Can use backreferences \ or raw string: r"This is change line indicated \n"

8. If elif else
number = 23
guess = int(raw_input('Enter an integer:'))

if guess == number:
    print 'Guess it'
elif guess < number:
    print 'No, it is a litter higher than that'
else:
    print 'No, it is a little lower than that'

print 'Done'

8. While
number = 23
running = True
while running:
    guess = int(raw_input('Enter an integer : '))
    if guess == number:
        print 'Congratulations, you guessed it.'
        running = False
    elif guess < number:
        print 'No, it is a little higher than that.'
    else:
        print 'No, it is a little lower than that.'
else:
    print 'The while loop is over.'

print 'Done'


9. For
for i in range(1, 5):
    print i
else:
    print 'The for loop is over'

10. Function
def say_hello(a):
    # block belonging to the function
    print 'hello world', a

# End of function


a = 'test'
b = 'happy'
say_hello(a) # call the function
say_hello(b) # call the function again


11. global statement and local scope
x = 50
y = 10
def func(input):
    global x          ## use global value 50, otherwise will be local scope

    print 'input is', input
    y = 100
    print 'x is', x

    print 'y is', y
    x = 2
    print 'Changed global x to', x


func(y)
print 'Value of x is', x

print 'Value of y is', y

Output:
input is 10
x is 50
y is 100
Changed global x to 2
Value of x is 2
Value of y is 10

12. Default argument values
def say(message, times=1):
    print message * times
say('Hello')
say('World', 5)


Output:
Hello
WorldWorldWorldWorldWorld

13. Keyword arguments
def func(a, b=5, c=10):
    print 'a is', a, 'and b is', b, 'and c is', c
func(3, 7)
func(25, c=24)
func(c=50, a=100)

#func(b=10)  ## Add this line will compile error, should be removed

Output:
a is 3 and b is 7 and c is 10
a is 25 and b is 5 and c is 24
a is 100 and b is 5 and c is 50

14. Varargs parameters
def total(initial=999, *numbers, **keywords):
    count = initial
    print 'count is', count
    for number in numbers:
        print 'number is', number
        count += number
        print '[number]count is', count
    for key in keywords:
        print 'keywords[key] is', keywords[key]
        count += keywords[key]
        print '[key]count is', count
    return count
print total(10, 1, 2, 3, vegetables=50, fruits=100) ##Cannot use
total(10, 1, test=9, 3, vegetables=50, fruits=100) or  total(10, 1, 3, vegetables=50, fruits=100, 99) will compile error

Output:
count is 10
number is 1
[number]count is 11
number is 2
[number]count is 13
number is 3
[number]count is 16
keywords[key] is 50
[key]count is 66
keywords[key] is 100
[key]count is 166
166

15.



2015年6月29日 星期一

Broadcom NetXtreme 57xx Gigabit Wireshark VLAN 如何讓網卡可抓到VLAN?

在此是以Broadcom NetXtreme 57xx Gigabit Controller為例,是DELL E5400的筆記型電腦.

  1. 開始->執行->輸入"regedit"
  2. 點擊HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet,搜尋"TxCoalescingTicks"
  3. 找到後在同一個目錄下,右鍵新增字串,名稱輸入"PreserveVlanInfoInRxPacket",值改成"1".
完成.

2015年6月18日 星期四

How to build "android-gif-drawable-sample" by Android Studio

1. Download source code from here:
    https://github.com/koral--/android-gif-drawable-sample#android-gif-drawable-sample
2. Create a new Project of Android Studio, select "Add no Activity".
3. Copy all folder and file from /android-gif-drawable-sample/sample/src/ to your /project/app/src/
4. Add dependencies of android-gif-drawable:
    a. File->Project Structure
    b. Select app->Dependencies
    c. Add "Library dependency", search "pl.droidsonroids.gif:android-gif-drawable:1.1.7", select it press ok.
5. Build->Rebuild Project.

Done.

2015年6月15日 星期一

WHR-G301N VPN設定

1.
先確認路由器有要到Public IP, Public IP指的是可從網際網路訪問到的IP address.
可以用這個網址來確認: http://www.ip-adress.com/





2.
將VPN Server功能打開, 選擇"PPTP機能使用",加密選"MS-CHAPv2認證(40/128bits暗號鍵)",設完按"設定"儲存。



建立vpn的帳號密碼,上圖最下面選"PPTP接續xxxx", 新增帳號密碼,設完按"新規追加"。

到此路由器設定完成。

3.
如何連線?
新增VPN連線, IP填public ip, 帳號密碼填第二步設定的.




2015年6月11日 星期四

Android Studio安裝教學與問題排解

1. 安裝Android Studio前要先安裝好
    a. JAVA jdk ----- 編譯java用
    b. Gradle ------ 用來管理Project的程式

1.1 Java JDK 安裝:
       設定環境變數:
       JAVA_HOME: C:\Program Files\Java\jdk1.8.0_45
1.2 Gradle 安裝:
       a. Download Gradle from here : https://gradle.org/downloads/ , select Complete distribution.
       b. Unzip this file.
       c. 設定環境變數, 新增變數GRADLE_HOME, 在原有Path後新增%GRADLE_HOME%\bin:
           GRADLE_HOME: F:\software\gradle-2.4
           Path: xxx;%GRADLE_HOME%\bin



      d. 測試是否安裝成功: 在cmd下執行gradle -v, 若有版本顯示則安裝成功。
2. 安裝Android Studio:
     Download from here: https://developer.android.com/sdk/index.html, click "Download Android Studio For Windows".

########## 問題排解 #############
Q1.使用ActionBar時啟動出現 java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity...... ?

A: change styles.xml to
<style name="AppTheme" parent="@style/Theme.AppCompat.Light.NoActionBar" />
Q2.How to add pic to android studio ?如何將圖檔加入android studio專案中?

A: install plugins "Android Drawable Importer".
    1. File->Settings->Plugins search "Android Drawable Importer" and install.
    2. To use: Right clicks on "Drawable" folder->New->, you can see four options.
        Select what you want.