2015
09.14
1.矩形剪切掉一条边
使用矩形工具画1个矩形,选择剪刀工具,鼠标分别点击要删除的边的2个顶点。这时候已经剪断了,只是肉眼看不到。然后鼠标切换成选择工具,框住剩余3条边(不要包含刚才的2个顶点),使用键盘,按住远离那条边的方向键。这时候我们能看到2部分已经分开了。
同理适用于椭圆。使用剪刀工具,点击圆周上的2点,使用键盘分开2部分即可。
2.画梯形
使用矩形工具先画个矩形,选择直接选择工具,使用鼠标框住一个顶点,使用键盘,按住能使该顶点变成梯形顶点的方向键,直到该顶点移动到合适的位置变成理想的梯形顶点位置。然后对另一个顶点执行同理操作。
3.多个图形组合成一个图形
鼠标框住想要组合的多个图形,然后菜单里选择“对象—路径—连接”。
4.切割图形的一部分
先画一个图形,然后画另一个图形,使2者重叠后,后者能够覆盖掉想第一个图形要保留的的部分。然后选中第一个图形,选择“对象—路径—分割下方对象”,然后鼠标只框住第2个图形,使用键盘的方向键将2部分分离,剩余第一个图形想要保留的那部分。
5.复制图形快捷键
选中图形,然后按住alt键,然后拖动鼠标。一个新的图形出现了。
6.旋转快捷键
选中图形,鼠标双击旋转工具,输入角度。
2015
06.30
启动:
memcached -d -u user -p 11211
默认内存64M,如果想指定内存大小,使用-m,后面加上要分配的内存大小(单位M)
停止:
service memcached stop
清空缓存:
telnet 127.0.0.1 11211
flush_all 回车
quit
查看状态:
telnet 127.0.0.1 11211
stats
其中,STAT bytes 一行显示的是当前占用内存的大小,
STAT limit_maxbytes 一行显示的是可用的最大内存。
2015
06.29
package com.example.myapplication;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
public class MainActivity extends ActionBarActivity implements MqttCallback{
private MqttClient mqttClient;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void clickButton(View button){
switch (button.getId()){
case R.id.register:
new Thread(new Runnable() {
@Override
public void run() {
int qos = 2;
String broker = "tcp://iot.eclipse.org:1883";
EditText editTextID = (EditText)findViewById(R.id.id);
String clientId = editTextID.getText().toString();
MemoryPersistence persistence = new MemoryPersistence();
try{
mqttClient = new MqttClient(broker, clientId, persistence);
MqttConnectOptions connOpts = new MqttConnectOptions();
connOpts.setCleanSession(true);
mqttClient.connect(connOpts);
mqttClient.subscribe(clientId);
mqttClient.setCallback(MainActivity.this);
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), mqttClient.isConnected() ? "连接成功" : "连接失败", Toast.LENGTH_LONG).show();
}
});
}
catch (Exception e){
e.printStackTrace();
}
}
}).start();
break;
case R.id.send:
EditText editTextTargetID =(EditText)findViewById(R.id.targetID);
final String targetID = editTextTargetID.getText().toString();
String content = ((EditText)findViewById(R.id.content)).getText().toString();
final MqttMessage message = new MqttMessage(content.getBytes());
if(mqttClient==null || !mqttClient.isConnected()){
Toast.makeText(getApplicationContext(),"MQTT未连接",Toast.LENGTH_LONG).show();
return;
}
new Thread(new Runnable() {
@Override
public void run() {
try{
mqttClient.publish(targetID, message);
}
catch (Exception e){
e.printStackTrace();
}
}
}).start();
break;
}
}
@Override
public void connectionLost(final Throwable cause) {
this.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "失去连接:" + cause.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
@Override
public void messageArrived(String topic, MqttMessage message)
throws Exception {
final String msg = new String(message.getPayload());
this.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "收到:"+msg, Toast.LENGTH_LONG).show();
}
});
}
@Override
public void deliveryComplete(IMqttDeliveryToken token) {
try {
final String msg = new String(token.getMessage().getPayload());
this.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "发送完毕:" + msg, Toast.LENGTH_LONG).show();
}
});
}
catch (Exception e){
e.printStackTrace();
}
}
}
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<TextView
android:layout_width="50dp"
android:layout_height="fill_parent"
android:gravity="center"
android:text="ID:"/>
<EditText
android:id="@+id/id"
android:layout_width="100dp"
android:layout_height="fill_parent" />
<Button
android:id="@+id/register"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="register"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:onClick="clickButton" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<TextView
android:layout_width="80dp"
android:layout_height="fill_parent"
android:gravity="center"
android:text="接收方ID:"/>
<EditText
android:id="@+id/targetID"
android:layout_width="50dp"
android:layout_height="fill_parent" />
<TextView
android:layout_width="40dp"
android:layout_height="fill_parent"
android:gravity="center"
android:text="内容:"/>
<EditText
android:id="@+id/content"
android:layout_width="100dp"
android:layout_height="fill_parent" />
<Button
android:text="Send"
android:id="@+id/send"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_below="@+id/textView"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:onClick="clickButton" />
</LinearLayout>
</LinearLayout>
2015
06.22
Service:运行于主线程,所以在运行过程中会造成UI没有响应;必须要调用stopService()或者stopSelf()方法去停止。
IntentService:会创建一个独立的新线程,所以不会影响UI;执行完成后自动停止,不必调用stopService()或stopSelft()方法。
2015
05.01
1、制作CA证书:
ca.key CA私钥:
openssl genrsa -des3 -out ca.key 2048
制作解密后的CA私钥(一般无此必要):
openssl rsa -in ca.key -out ca_decrypted.key
ca.crt CA根证书(公钥):
openssl req -new -x509 -days 7305 -key ca.key -out ca.crt
2、制作生成网站的证书并用CA签名认证
在这里,假设网站域名为https.abc.com
生成https.abc.com证书私钥:
openssl genrsa -des3 -out https.abc.com.pem 1024
制作解密后的https.abc.com证书私钥:
openssl rsa -in https.abc.com.pem -out https.abc.com.key
生成签名请求:
openssl req -new -key https.abc.com.pem -out https.abc.com.csr
在common name中填入网站域名,如https.abc.com即可生成改站点的证书
3.用CA进行签名:
先执行以下命令
$ mkdir -p ./demoCA/newcerts
$ cd demoCA
$ echo “01” > serial
$ touch index.txt (create an empty index.txt file)
$ cd .. (so we are back in our temporary directory)
openssl ca -policy policy_anything -days 1460 -cert ca.crt -keyfile ca.key -in https.abc.com.csr -out https.abc.com.crt
4. 配置nginx
配置文件中新建一个server,并加入
listen 443;
server_name https.abc.com;
ssl on;
ssl_certificate /path/to/https.abc.com.crt;
ssl_certificate_key /path/to/https.abc.com.key;
以上2个文件路径根据实际情况配置。其他配置和http server相同。
5. 重启nginx