05 2012 档案
摘要:经常我们会发现,当我们把一个对象列表赋值给另一个对象列表之后,一个改变了,另一个也跟着改变了,但是这往往不是我们想看到的那么,怎么办呢?办法只有一个,那就是让你的对象实现IClonable接口对象代码:publicclassEmployee:ICloneable{publicintEmployeeID{get;set;}publicstringLastName{get;set;}publicstringFirstName{get;set;}publicstringTitle{get;set;}publicstringCity{get;set;}publicstringRegion{get;s.
阅读全文
摘要:1. 抽象注入接口publicinterfaceIDeviceWriter{voidsaveToDevice();}2. 接口的具体实现 实现1publicclassFloppyWriter:IDeviceWriter{publicvoidsaveToDevice(){Console.WriteLine("储存至软盘…");}} 实现2publicclassUsbDiskWriter:IDeviceWriter{publicvoidsaveToDevice(){Console.WriteLine("储存至移动硬盘…");}}3. 需要注入的业务对象pub
阅读全文
摘要:1. 配置文件<configuration><configSections><sectionGroupname="spring"><sectionname="context"type="Spring.Context.Support.ContextHandler,Spring.Core"/><sectionname="objects"type="Spring.Context.Support.DefaultSectionHandler,Spring.Cor
阅读全文
摘要:1. 经典的设计模式中的代码publicclassSingleton{privatestaticSingletoninstance;//唯一实例protectedSingleton(){}//封闭客户程序的直接实例化publicstaticSingletonInstance{get{if(instance==null)instance=newSingleton();returninstance;}}} 在多线程环境下存在缺陷, 最终将会保存最后创建的那个实例2. 改进后的多线程SingletonclassSingleton{privateSingleton(){}[ThreadStatic].
阅读全文
摘要:1. 安装Qt集成环境 sudo apt-get install qt4-dev-tools qt4-doc qt4-qtconfig qt4-demos qt4-designer2. 编写一个简单的Qt程序生成一个简单的窗口#include<QApplication>#include<QLabel>intmain(intargc,char*argv[]){QApplicationapp(argc,argv);QLabel*label=newQLabel("HelloQt!");label->show();returnapp.exec();}3
阅读全文
摘要:1. 首先安装g++ sudo apt-get install build-essential2. 输入一个简单的cpp程序#includeusingnamespacestd;intmain(){cout<<"HelloUbuntu!"<<endl;return0;}3. 编译 david@ubun...
阅读全文
摘要:类接口文件(MathDiv.h)#import<Foundation/Foundation.h>//DefinetheFractionclass@interfaceFraction:NSObject{intdividend;intdivider;}@propertyintdividend,divider;-(void)print;-(void)setTo:(int)nover:(int)d;-(double)convertToNum;@end类实现文件(MathDiv.m)#import"Fraction.h"@implementationFraction@sy
阅读全文
摘要:TableLayout有个属性shrinkColumns让第2,3,4列自动伸缩:android:shrinkColumns="1,2,3"效果如下:
阅读全文
摘要:一段复杂的逻辑,原先的代码我使用#tmp临时表来实现,性能是不好的,而且要考虑到多用户时的锁的问题代码如下:declare@StartDatedatetimedeclare@EndDatedatetimeselect@StartDate='2012-09-28'select@EndDate='2012-10-03'ifexists(select*fromtempdb..sysobjectswherenamelike'#tmpPolicyId%')droptable#tmpPolicyIdifexists(select*fromtempdb..sy
阅读全文
摘要:CTE - Common Table Expression(公用表达式)是SQL 2005最重要的改进之一。子查询有时候使用起来嵌套很复杂, 而使用#tmp类似的临时表, 性能又比较差。这个时候,介于两者之间的解决方案,CTE诞生了。我们可以用它来替代临时表在使用CTE时应注意如下几点:1. CTE后面必须直接跟使用CTE的SQL语句(如select、insert、update等),否则,CTE将失效2. CTE后面也可以跟其他的CTE,但只能使用一个with,多个CTE中间用逗号(,)分隔如下面的SQL语句所示: withcte1 as( select * from table1 where
阅读全文
摘要:1. 代码编写#include<stdlib.h>#include<stdio.h>#include"mysql.h"intmain(intargc,char*argv[]){MYSQLmy_connection;intres;mysql_init(&my_connection);if(mysql_real_connect(&my_connection,"localhost","root","mysql","mysql",0,NULL,0)){printf
阅读全文
摘要:1. 安装mysql client包 sudo apt-get install libmysqlclient15-dev2. 编写C程序#include<stdlib.h>#include<stdio.h>#include"mysql.h"intmain(intargc,char*argv[]){MYSQL*conn_ptr;conn_ptr=mysql_init(NULL);if(!conn_ptr){fprintf(stderr,"mysql_initfailed\n");returnEXIT_FAILURE;}conn_pt
阅读全文
摘要:1. 什么是Cocal TouchCocoa Touch is the collection of software frameworks that isused to build iOS applications and the runtime that those applications are executedwithin. Cocoa Touch includes hundreds of classes for managing everything frombuttons to URLs.(Cocoa Touch是IOS构建应用程序的框架集合, 它包括了许多类用来操作IOS上的许.
阅读全文
摘要:XCode中引入了静态分析器,用于发现普通编译错误以外的错误选择Build->Build and Analyze请看下面这段代码#import<Foundation/FOundation.h>intmain(intagrc,constchar*argv[]){NSAutoreleasePool*pool=[[NSAutoreleasePoolalloc]init];NSDate*date=[[NSDatealloc]init];NSLog(@"Thetimeis:%@",date);[pooldrain];return0;}上面这段代码中, date对象在
阅读全文
摘要:1. 声明变量 <Type> <Variable Name>;2. 基本数据类型 数字类型: int/float/double3. 对象类型 Objective-C中的对象类型必须使用指针 eg: NSString *userName;4. 对象的分配/初始化/释放 在对象使用前,必须分配内存和进行初始化 eg: [[<class name> alloc] init];UILabel*myLabel;myLabel=[[UILabelalloc]init];5. 快速初始化 一些内建的快速方法可以方便我们进行初始化NSURL*iPhoneURL;iPhone
阅读全文
摘要:1. 实现文件以.m为后缀名 #import “myClass.h”导入头文件@implementation myClass告诉编译器实现哪个类@synthesize myLabel;为实例变量产生getters和setters方法类方法实现+(NSString)myClassMethod:(NSString)aString{//ImplementtheClassMethodHere!}实例方法实现-(NSString)myInstanceMethod:(NSString)aStringanotherParameter:(NSURL)aURL{//ImplementtheInstanceMe.
阅读全文
摘要:1. Exploring the Objective-C File Structure 建立一个Objective-C的类会新建两个文件, 一个接口文件(头文件)(interface file), 后缀为.h, 一个实现文件(implementation file), 后缀为.m (见下图) 顾名思义, 接口文件定义所有方法签名, 实现文件具体实现代码逻辑 看下面这段代码#import语句用来导入某个头文件, 学过Java的朋友可以知道, 它类似Java中的import语句, 而Java中是导入某个包Directive(指示语句)Directives are commands that a..
阅读全文
摘要:有时候我们的需要制作一些守护进程,如果服务器出现了什么问题,就需要重启某个软件啊之类的那么这类守护进程怎么做呢?请看代码importtimeseconds_to_sleep=2*60while1:#这里你可以利用python的shell做一些系统操作print"HelloDavid,guardprocessisrunning..."time.sleep(seconds_to_sleep)运行方式:cmd进入命令行python 你的python程序名.py
阅读全文
摘要:Run Command Window->inetmgr
阅读全文
摘要:组策略设置 -> gpedit.msc,windows设置,安全设置,本地策略,安全选项,启用管理员帐户
阅读全文
摘要:1. Choosing a Project Type 确保选择IOS项目类型 建立好项目之后, 你会发现一个后缀名为.xcodeproj的文件 选择项目组 请记住, 这些只是逻辑组, 你在你的硬盘上找不到他们的名字Classes: 存放类Other Sources: 存放其他资源Resources: 存放图片,声音等其他资源文件Frameworks: 一些框架Products: 项目生成的exe文件2. Adding New Code Files to a Project 重要的一点, 你需要知道的是类由两部分组成: 1) 头文件或者称为接口文件, 后缀名为.h 作用为描述类的功能...
阅读全文
摘要:1. 构建服务端程序 usingSystem.ServiceModel;namespaceyournamespace{[ServiceContract(Name="HelloService",Namespace="http://www.master.haku")]publicinterfaceIHello{[OperationContract]stringSayHello();}}namespaceYourNameSpace{publicclassYourService{publicstringSayHello(stringwords){return&q
阅读全文
摘要:adb介绍SDK的Tools文件夹下包含着Android模拟器操作的重要命令adb,adb的全称为(Android Debug Bridge就是调试桥的作用。通过adb我们可以在Eclipse中方面通过DDMS来调试Android程序。借助这个工具,我们可以管理设备或手机模拟器的状态。还可以进行以下的操作: 1、快速更新设备或手机模拟器中的代码,如应用或Android 系统升级; 2、在设备上运行shell命令; 3、管理设备或手机模拟器上的预定端口; 4、在设备或手机模拟器上复制或粘贴文件; adb在集成开发环境中的工作 adb的工作方式比较特殊采用监听Socket TCP 5554等端..
阅读全文
摘要:我们需要用到android-sdk开发包中adb shell指令见下图退出adb shellexit
阅读全文
摘要:1. 登录 mysql -u root -p2. 改变数据库 use mysql;3. 显示当前数据库下所有表 show tables;4. 退出 quit
阅读全文
摘要:1. 安装mysql sudo apt-get install mysql-server
阅读全文
摘要:1.gedit编写C代码#include<stdio.h>intmain(intargc,char*argv[]){printf("Hello,David\n");return0;}2. 编译 gcc -o hello hello.c3. 执行 ./hello
阅读全文