几种粒子效果

    auto s = Director::getInstance()->getWinSize();
     
    auto sun = ParticleSun::create();
    sun->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    sun->setPosition(Vec2(s.width / 2 -100, s.height / 2));
     
    sun->setTotalParticles(130);
    sun->setLife(5.0f);
     
    this->addChild(sun);
    // timers
     
     
    auto fire = ParticleFire::create();
    fire->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    fire->setPosition(Vec2(s.width / 2 + 50, s.height / 2));
     
    fire->setTotalParticles(130);
    fire->setLife(5.0f);
     
    this->addChild(fire);
     
    auto fireworks = ParticleFireworks::create();
    fireworks->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    fireworks->setPosition(Vec2(s.width / 2 + 50, s.height / 2 - 200));
     
    fireworks->setTotalParticles(130);
    fireworks->setLife(5.0f);
     
    this->addChild(fireworks);
     
     
    auto galaxy = ParticleGalaxy::create();
    galaxy->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    galaxy->setPosition(Vec2( 50, s.height / 2 + 200));
     
    galaxy->setTotalParticles(130);
    galaxy->setLife(5.0f);
     
    this->addChild(galaxy);
     
     
 
    auto flower = ParticleFlower::create();
    flower->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    flower->setPosition(Vec2( 250, s.height / 2 + 200));
     
    flower->setTotalParticles(130);
    flower->setLife(5.0f);
     
    this->addChild(flower);
     
    //流星
    auto meteor = ParticleMeteor::create();
    meteor->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    meteor->setPosition(Vec2( 250, 20));
     
    meteor->setTotalParticles(130);
    meteor->setLife(5.0f);
     
    this->addChild(meteor);
     
     
    //旋涡
    auto spiral = ParticleSpiral::create();
    spiral->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    spiral->setPosition(Vec2( 450, 40));
     
    spiral->setTotalParticles(130);
    spiral->setLife(5.0f);
     
    this->addChild(spiral);
    
    //爆炸
    auto explosion = ParticleExplosion::create();
    explosion->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    explosion->setPosition(Vec2( 50, 440));
     
    explosion->setTotalParticles(130);
    explosion->setLife(5.0f);
     
    this->addChild(explosion);
     
     
    //烟雾
    auto smoke = ParticleSmoke::create();
    smoke->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    smoke->setPosition(Vec2( 450, 640));
     
    smoke->setTotalParticles(130);
    smoke->setLife(5.0f);
     
    this->addChild(smoke);
     
    //雪
    auto snow = ParticleSnow::create();
    snow->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    snow->setPosition(Vec2( 450, 840));
     
    snow->setTotalParticles(130);
    snow->setLife(5.0f);
     
    this->addChild(snow);
 
    //雨
    auto rain = ParticleRain::create();
    rain->setTexture(Director::getInstance()->getTextureCache()->addImage(fire.png));
    rain->setPosition(Vec2( 450, 940));
     
    rain->setTotalParticles(130);
    rain->setLife(5.0f);
     
    this->addChild(rain);

Linux Ctrl+Z 用法

假设你发现前台运行的一个程序需要很长的时间,但是需要干其他的事情,你就可以用 Ctrl-Z ,终止这个程序,然后可以看到系统提示:
[1]+ Stopped /root/bin/rsync.sh
然后我们可以把程序调度到后台执行:(bg 后面的数字为作业号)
#bg 1
[1]+ /root/bin/rsync.sh &
用 jobs 命令查看正在运行的任务:
#jobs
[1]+ Running /root/bin/rsync.sh &
如果想把它调回到前台运行,可以用
#fg 1
/root/bin/rsync.sh
这样,你在控制台上就只能等待这个任务完成了.
& 将指令丢到后台中去执行
[ctrl]+z 将前台任务丢到后台中暂停
jobs 查看后台的工作状态
fg %jobnumber 将后台的任务拿到前台来处理
bg %jobnumber 将任务放到后台中去处理
kill 管理后台的任务
命令运行时使用CTRL+Z,强制当前进程转为后台,并使之停止。
1. 使进程恢复运行(后台)
(1)使用命令bg
Example:
zuii@zuii-desktop:~/unp/tcpcliserv$ ./tcpserv01
*这里使用CTRL+Z,此时serv01是停止状态*
[1]+ Stopped ./tcpserv01
zuii@zuii-desktop:~/unp/tcpcliserv$ bg
[1]+ ./tcpserv01 & *此时serv01运行在后台*
zuii@zuii-desktop:~/unp/tcpcliserv$
(2)如果用CTRL+Z停止了几个程序呢?
Example:
zuii@zuii-desktop:~/unp/tcpcliserv$ jobs
[1]- Running ./tcpserv01 &
[2]+ Stopped ./tcpcli01 127.0.0.1
zuii@zuii-desktop:~/unp/tcpcliserv$ bg %1
bash: bg:任务 1 已转入后台 *后台运行*
2. 使进程恢复至前台运行
Example:
zuii@zuii-desktop:~/unp/tcpcliserv$ ./tcpserv04
[1]+ Stopped ./tcpserv04
zuii@zuii-desktop:~/unp/tcpcliserv$ fg
。/tcpserv04
总结:
(1) CTRL+Z停止进程并放入后台
(2) jobs 显示当前暂停的进程
(3) bg %N 使第N个任务在后台运行(%前有空格)
(4) fg %N 使第N个任务在前台运行
默认bg,fg不带%N时表示对最后一个进程操作!

New Years Resolution

2016, Be an Explorer

mysql + php 中文字符乱码解决

数据库、表、字段 3者都改成utf8编码

修改数据库编码方式:alter database testdb character set utf8;
修改表的编码方式:ALTER TABLE `test` DEFAULT CHARACTER SET utf8;
修改字段的编码方式:ALTER TABLE `test` CHANGE `name` `name` VARCHAR(36) CHARACTER SET utf8 NOT NULL;

php和请求的html都改为utf8编码

It Worked

Linux下装载win共享

1. 安装cifs-utils
2. 在需要装载的路径处新建一个空目录 eg. /mnt/xxx
3. mount -t cifs //win_ip/win_share_name /mnt/xxx -o username=win_user

2015

完成了什么
H-C
未完成什么
L-A
下年做什么
A-L-S

Lucky to be back

WL has been recovered from a mess. Everything back to normal !!!

解决eclipse使用git ssh模式auth fail问题

命令行下git一切正常,eclipse出现auth fail错误,
需要添加 GIT_SSH=/usr/bin/ssh

原文:

I had exactly same problem but I found the cure from a Eclipse bug report!

An environment variable named GIT_SSH must be set with a path to a ssh executable [1].

For example on Ubuntu Linux (10.10 64bit):

> export GIT_SSH=/usr/bin/ssh
> eclipse
After that pushes to GitHub repository work like they should. I tested this with Eclipse Galileo and Indigo.

The problem is really annoying and the solution is far from nice. For now, making the solution permanent for, at least Ubuntu users, one must make the env variable permanent. It can be done by adding the export command to ~/.profile or ~/.bashrc [2]. For example:

> cd ~
> echo “export GIT_SSH=/usr/bin/ssh” >> .profile
And then restart Eclipse to take effect.

Android 判断某个APK是否已安装

privateboolean isAppInstalled(String uri) {
PackageManager pm = getPackageManager();
boolean installed =false;
try {
pm.getPackageInfo(uri,PackageManager.GET_ACTIVITIES);
installed =true;
} catch(PackageManager.NameNotFoundException e) {
installed =false;
}
return installed;
}

if(isAppInstalled(“com.yourpackage.package”)) {
//app installed
} else {
//app not installed
}

Android HCE

引用

开发HCE功能必须使用到HostApduService,在使用HostApduService时需要配置HostApduService的对应AID,同一个手机可能安装多个HCE APP,或者同一个APP包含多个HostApduService,这时候就需要搞清楚配置的AID和对应的HostApduService之间的响应向后问题。
首先介绍一下关于HostApduService的AID配置问题,AID有两种模式:other和payment

第一种

          可以通过指定多个aid-filter,来注册多个AID。
          category可以指定为 other 或者 payment。
          requireDeviceUnlock为false的时候,可以在锁屏状态下完成处理,为true的时候,则会要求用户解锁屏幕。

第二种

 
          可以通过指定多个aid-filter,来注册多个AID。
          category可以指定为 other 或者 payment。
          requireDeviceUnlock为false的时候,可以在锁屏状态下完成处理,为true的时候,则会要求用户解锁屏幕

下面我们来详细说明一下关于不同模式下的AID响应问题(前提:一个手机,手机上有A、B两个HCE APP,通过读卡器向手机发送APDU选择指令)

1、A和B的应用AID设置的都是payment模式,

只有手机当前选定的默认支付APP会响应,另外一个APP的AID选择指令是不会响应的。

2、A和B的应用AID设置的都是other模式,

当A和B的AID是相同的时候系统会弹出对话框,列出A和B,让用户选择。

如果A和B的AID不同,那么两个APP之间没有相互影响。

3、A和B的应用AID设置的分别是payment(A)和other(B)模式,

如果A和B的AID相同,那么只有A会响应选择指令。

如果A和B的AID不同,那么两者之间不会相互影响

最后将如何判断当前HCE应用是否是默认支付程序以及如何设置成默认支付程序的方法贡献给大家

private void checkIsDefaultApp() {
CardEmulation cardEmulationManager = CardEmulation.getInstance(NfcAdapter.getDefaultAdapter(this));
ComponentName paymentServiceComponent = new ComponentName(getApplicationContext(), CardMangerService.class.getCanonicalName());
if (!cardEmulationManager.isDefaultServiceForCategory(paymentServiceComponent, CardEmulation.CATEGORY_PAYMENT)) {
Intent intent = new Intent(CardEmulation.ACTION_CHANGE_DEFAULT);
intent.putExtra(CardEmulation.EXTRA_CATEGORY,CardEmulation.CATEGORY_PAYMENT);
intent.putExtra(CardEmulation.EXTRA_SERVICE_COMPONENT,paymentServiceComponent);
startActivityForResult(intent, 0);
L.d(“TAG”,”当前应用不是默认支付,需手动设置”);
} else {
L.d(“TAG”,”当前应用是系统默认支付程序”);
}
}