C#中ref out http://kb.cnblogs.com/a/224315/
posted @ 2012-04-13 23:42 Justin_Ma 阅读(5) 评论(0)
编辑
findstr /s /i "abc" *
findstr /s “.*.c" * 查找含有".c"的字符串 用的是正则表达式 注意* 前面的. .*表示一个多个字符
posted @ 2012-03-16 11:26 Justin_Ma 阅读(14) 评论(0)
编辑
#Usage: monkeyrunner recorder.py
#recorder.py http://mirror.yongbok.net/linux/android/repository/platform/sdk/monkeyrunner/scripts/monkey_recorder.py
from com.android.monkeyrunner import MonkeyRunner as mr
from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder
device = mr.waitForConnection()
recorder.start(device)
#END recorder.py
#Press ExportAction to save recorded scrip to a file
#Example of result:
#PRESS|{'name':'MENU','type':'downAndUp',}
#TOUCH|{'x':190,'y':195,'type':'downAndUp',}
#TYPE|{'message':'',}
============================================================================================
#Usage: monkeyrunner playback.py "myscript"
#playback.py http://mirror.yongbok.net/linux/android/repository/platform/sdk/monkeyrunner/scripts/monkey_playback.py
import sys
from com.android.monkeyrunner import MonkeyRunner
# The format of the file we are parsing is very carfeully constructed.
# Each line corresponds to a single command. The line is split into 2
# parts with a | character. Text to the left of the pipe denotes
# which command to run. The text to the right of the pipe is a python
# dictionary (it can be evaled into existence) that specifies the
# arguments for the command. In most cases, this directly maps to the
# keyword argument dictionary that could be passed to the underlying
# command.
# Lookup table to map command strings to functions that implement that
# command.
CMD_MAP = {
'TOUCH': lambda dev, arg: dev.touch(**arg),
'DRAG': lambda dev, arg: dev.drag(**arg),
'PRESS': lambda dev, arg: dev.press(**arg),
'TYPE': lambda dev, arg: dev.type(**arg),
'WAIT': lambda dev, arg: MonkeyRunner.sleep(**arg)
}
# Process a single file for the specified device.
def process_file(fp, device):
for line in fp:
(cmd, rest) = line.split('|')
try:
# Parse the pydict
rest = eval(rest)
except:
print 'unable to parse options'
continue
if cmd not in CMD_MAP:
print 'unknown command: ' + cmd
continue
CMD_MAP[cmd](device, rest)
def main():
file = sys.argv[1]
fp = open(file, 'r')
device = MonkeyRunner.waitForConnection()
process_file(fp, device)
fp.close();
if __name__ == '__main__':
main()
posted @ 2011-09-21 12:01 Justin_Ma 阅读(321) 评论(1)
编辑
#Save this file as mms.py and run it by Command: MonkeyRunner mms.py
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
# sets a variable with the package's internal name
package = 'com.android.mms'
# sets a variable with the name of an Activity in the package
activity = '.ui.ConversationList'
# sets the name of the component to start
runComponent = package + '/' + activity
# Runs the component
device.startActivity(component=runComponent)
# Presses the Menu button
device.press('KEYCODE_MENU',MonkeyDevice.DOWN_AND_UP)
# Takes a screenshot
result = device.takeSnapshot()
# Writes the screenshot to a file
result.writeToFile('shot1.png','png')
posted @ 2011-09-18 21:25 Justin_Ma 阅读(199) 评论(0)
编辑
写一个help.py
然后用命令 monkeyrunner.bat help.py
即可生成help.html
#help.py
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
text = MonkeyRunner.help("html");
f = open('help.html', 'w')
f.write(text);
f.close();
posted @ 2011-09-18 20:53 Justin_Ma 阅读(83) 评论(0)
编辑
第三章 C++中的C
1. .hxx .hpp也是C++头文件
2.写可移植的C++程序:用C++标准库,和尽量使用符合POSIX标准的函数
3.头文件<climits>和<cfloat>中定义了不同基本数据类型可能存储的最大值和最小值
4.sizeof 是一个运算符 不是函数, 如果对一个变量使用它,可以不要括号: int i = sizeof i;
5.同类型指针相减,其结果是两个指针之间相隔元素的个数
6.把变量和表达式转换成字符串:在一个预处理器宏中的参数前加一个#,预处理器会把这个参数转换为一个字符数组
#define P(A) cout<< #A <<": result" << A << endl;
7.## 标志粘贴:它允许设两个标识符并把它们粘贴在一起自动产生一个新的标识符。
#deifine FIELD(a) char * a##_string;
FIELD(my); ===> char* my_string;
第五章 隐藏实现
1.友元
class My{
public:
friend void g();//友元:全局函数
friend class z;//友元:类
friend Y::fun();//友元:其它类的成员函数
}
2.友元是可以嵌套的
第七章 函数重载与默认参数
1.union(联合)可以带有构造函数、析构函数、成员函数甚至访问控制,但它不能在继承时做基类使用
2.没有类型名和标识符的union叫匿名联合
int main(){
union{
int i;
float f;
};
i=12; f = 1.0;
}
第八章 常量
1.临时变量按引用传递给一个函数时,这个函数的参数必须是const引用
class X{};
X fun()(return X();}
void g1(X&){}
void g2(const X&){}
main(){
g1( fun() );//This line will cause build error : const temporary created by fun()
g2( fun() );
}
2.类的const实例对象只能调用const成员函数。类的非const实例对象,可调用const和非const成员函数 但会优先调用非const成员函数。
第十章 名字空间
1.静态对象的构造和析构函数
全局变量、对象的构造函数在main()之前被调用,且存储空间分配在静态存储区
所有静态对象无论是全局还是局部,它的析构函数都在main()之后被调用
如果一个包含局部静态对象的函数从未被调用过,那么这个对象的构造函数也不会被执行
2.内部连接
在文件作用域内,一个被明确声明为static的对象或函数是内部连接的
内部连接的一个好处是这个名字可以放在一个头文件中而不用担心连接时发生冲突。
那些通常入在头文件里的名字。如常量、内联函数、在默认情况下都是内部连接的(当然常量只在C++中默认为是内部连接,在C中外部连接)
3.namesapce可以有别名。一个namespace可以在多个头文件中用一个标识符来定义,从而往namespace中添加内容
posted @ 2010-11-22 10:45 Justin_Ma 阅读(90) 评论(0)
编辑
posted @ 2010-01-20 23:32 Justin_Ma 阅读(56) 评论(0)
编辑
摘要: 第八章 多态 静态方法不具备多态因为它是与类,而非单个对象相关联的。 Java中除了final和static方法之外,其它所有的方法都是后期绑定的 构造函数中的虚函数是动态联编的,但在C++中是静态联编的 TIJ书 P163 子类不可改变基类中函数的可见性。若基类中某函数为public,在继承时该函数仍需为public Java SE5 添加了返回类型,它允许子类在虚函数中返回基类的子类型。在实现...
阅读全文
posted @ 2009-12-30 15:57 Justin_Ma 阅读(119) 评论(0)
编辑
摘要: 第三章 操作符CLASSPATH环境变量用来查找编译时所需的类.java文件s1.关系操作符 引用比较:== 用于判断引用所指的对象(对象的内存地址)是否相同。 对象比较:equals()。比较两个对象中的内容是否相同则需覆盖equals()函数。 &&, ||, ! 只可用于boolean变量 如:int i; !(i < 10)//correct !i //wrong2...
阅读全文
posted @ 2009-12-02 11:25 Justin_Ma 阅读(28) 评论(0)
编辑
摘要: Java also has a “default” access, which comes into play if you don’t use one of the aforementioned specifiers. This is usually called package access because classes can access the me...
阅读全文
posted @ 2009-10-27 22:12 Justin_Ma 阅读(87) 评论(0)
编辑