CSDN blog recommended articles Http://prog3.com/sbdm/blog Http://prog3.com/sbdm/static.blog/images/logo.gif CSDN blog content aggregation service Http://prog3.com/sbdm/blog Zh-cn (C) 2011 PROG3.COM Http://prog3.com/sbdm/blog 14:37:04 2015/12/27 The principle of non - zero - circle rule in Canvas Http://prog3.com/sbdm/blog/itpinpai/article/details/50412260 Http://prog3.com/sbdm/blog/itpinpai/article/details/50412260 Itpinpai 14:21:48 2015/12/27


Non - zero - circle rule: for a specified range of paths in the path, a sufficiently long line segment is drawn from the region to make the line segment completely outside the path.


Non zero surround rule counter:
Then, the counter is initialized to 0, when the line and the path of a straight line or curve intersection, changing the value of the counter, if it is with the path clockwise intersection, then the counter will add 1, if it is counter clockwise intersection with the path, then the counter will be reduced by 1
If the counter is always not 0, then this area is in the path of the inside, in the call fill () method, the browser will be filled with it. If the final value is 0, then the area is not in the path, the browser will not be filled.

From the image above
The first line segment: according to the non zero surrounding rules, this line only after a path and the path is counter clockwise direction, then the counter is -1; according to the browser on the counter calculation principle, when the call fill () method, the browser will fill the area.

Second line segments: according to the non zero surrounding rules, this straight path through two times and the path is counter clockwise, then the counter is -2; according to the browser on the counter calculation principle, when the call fill () method, the browser will fill the area.

Third line segments: according to the non zero surrounding rules, this straight path two times; the first time after the path is counter clockwise, counter is -1; the path is clockwise second times, the counter is 1; reason counter of the final value of 0-1+1 = 0; so according to the browser counter calculation principle, when the call fill () the browser will not fill this area.


According to the above principle, the example of drawing a circle diagram is demonstrated.

As follows:



Instance code:

Type= text/css "<style" >
Canvas {
Solid #e5e5e5 border:1px;
}
</style>
Id= firstCanvas "<canvas" width= "400" height= "400" > not supported </canvas> Canvas

Type= text/javascript "<script" >
Canvas var = document.getElementById ("firstCanvas"),
Context = canvas.getContext & & canvas.getContext ("2D");

Context.fillStyle = "#ff6600";

Current subPath / / clear
Context.beginPath ();
Outer / / circle
Context.arc (200, 200, 100, 0, Math.PI * 2, true);
Inner / / circle
Context.arc (200, 200, 50, 0, Math.PI * 2, false);
Context.fill ();

</script>




Author: itpinpai published in 14:21:48 2015/12/27Text link
Read: 9 comments: 0View comments
]]>
C++14 can directly write binary literal constants Http://prog3.com/sbdm/blog/csfreebird/article/details/50412173 Http://prog3.com/sbdm/blog/csfreebird/article/details/50412173 Sheismylife 13:51:21 2015/12/27

One Direct writing binary literal constant

C++14 brings the 0b or 0B at the beginning of the binary string representation of the literal constant, as the literals. binary the following code

WriteBinaryLiterals void () {
I size_t = 42;
J size_t = 0b101010;
The cout (I = = J) < endl;
}

Running results output 1 so, you can not have to write as before, such as 0x2a, for example,, and then the brain inside and then converted into binary computing bit operation results.

Dean Author:

2015-12-27 13:49 Created:

Validate

Author: sheismylife published in 13:51:21 2015/12/27Text link
Read: 65 comments: 0View comments
]]>
LeetCode 226 Binary Tree Invert (conversion two fork tree) Http://prog3.com/sbdm/blog/nomasp/article/details/50411971 Http://prog3.com/sbdm/blog/nomasp/article/details/50411971 NoMasp 12:31:40 2015/12/27 translation
In the image above the two fork tree into the following form, specifically for each left child node and the right child node swap positions.

Write the picture here.

the original

As above

Analysis

Each time the problem of the tree is in the boundary conditions...... So this time carefully think over:

VoidSwapNode (TreeNode*Tree) {
    If(tree= = NULL ||(tree- >Left= = NULL & &Tree- >Right= = NULL{}))
    Else    If(tree- >Left= = NULL & &Tree- >Right=! NULL{)
树节点*温度=•>是的
树•>=温度;
树•>是的=nullptr;
}
    其他的    如果(树•>是的= =  & &•>!= ){
树节点*温度=•>左;
树•>是的=温度;
树•>=nullptr;
}
    其他的{
树节点*温度=•>左;
树•>=•>是的
树•>是的=温度;
}
}

仅仅是这样还不够,它只是互换了一次,所以我们要用到递归:

如果(树>!=)
swapnode(树>);
如果(树>是的!=)
swapnode(树>是的);

最后在题目给定的函数内部调用自己写的这个递归函数就好。

TreeNode * inverttree(TreeNode *根){
    如果(根= =返回 ;
swapnode(根);
    返回根;
}

代码

* * * *
*定义对于一个二叉树结点。
*结构树节点{
*int瓦尔;
*树*;
*树*是的;
*树节点(intx):Val(X),),是的){ }
* };
*
溶液{
公共:
无效swapnode(节点树){
        如果(树= = = = =| |(树>= =与树- >是的= =){ }
        其他的    如果(树>= =与树- >是的!=){
TreeNode *温度=树>是的;
树>=温度;
树>是的= nullptr;
}
        其他的    如果(树>是的= =与树- >!=){
TreeNode *温度=树>;
树>是的=温度;
树>= nullptr;
}
        其他的{
TreeNode *温度=树>;
树>=树>是的;
树>是的=温度;
}
        如果(树>!=)
swapnode(树>);
        如果(树>是的!=)
swapnode(树>是的);
}

TreeNode * inverttree(TreeNode *根){
        如果(根= =)返回;
swapnode(根);
返回根;
}
};

学习

自己的解决方案还是太初级,所以来学习学习大神的解法:

TreeNode * inverttree(TreeNode *根){

    如果nullptr=根)返回根;

    队列< TreeNode * >myqueue;/我们的队列做BFS
myqueue推(根);推送最早的项目-根

    (!myqueue。empty()){在队列中有节点
* = myqueue front() TreeNode节点;从队列中获取元素
myqueue。pop();从队列中删除元素

        如果(节点-左!=nullptr){如果存在的话,将左小男孩添加到队列中
myqueue。推(节点->左);
}
        如果(节点-权利!=nullptr){加对孩子
myqueue。推(节点->右);
}

        左、右指针反转
TreeNode * TMP =节点->左;
节点-左=节点-右;
节点->右= TMP;

}
    返回根;
}

争取以后少用递归了,加油!

作者:nomasp发表于2015 / 12 / 27 12:31:40原文链接
阅读:131评论:2查看评论
]]>
Maven中剖面和过滤实现多个环境下的属性过滤 http://prog3.com/sbdm/blog/luckyzhoustar/article/details/50411962 http://prog3.com/sbdm/blog/luckyzhoustar/article/details/50411962 zhouchaoqiang 2015 / 12 / 27 12:54:09  

 背景

项目构建的时候,需要根据不同的场景来改变项目中的属性资源,最为常见的莫过于数据库连接配置了,试想有生产环境、测试缓存、发布环境等,需要为不同的场景下来动态的改变数据库的连接配置。而使用Maven就可以帮我们解决这些问题。下面就来分享一下Maven中的剖面和过滤的属性。


为了便于测试一下功能,需要搭建Maven的Web项目,具体配置请详见如何用Maven创建Web项目


 过滤功能


主要用来替换项目中的资源文件(*。XML、*。性质)当中的$ {…},比如$ {分贝。URL },那么如果配置了分贝。url = AAA的话,在项目编译的时候,就会自动的把$ {分贝。URL }替换为AAA,下面以实例来讲解一下


采取参照博客中创建完Maven的Web项目后,会看到SRC /主/源的目录,在此目录下面创建个”试验。性质”,里面随便来上一行,例如你好$ {用户名称},好了,接下来修改我们的POM文件,来启动过滤功能


<Project xmlns=”http://maven.apache.org/POM/XSI 4.0.0 xmlns:“=”http://服务/2001/XMLSchema实例”
XSI:SchemaLocation=”http:///POM maven.apache.org 4.0.0 http:/ / / / maven.apache.org XSD maven-4.0.0.xsd”>
modelversion><></modelversion 4.0.0
groupid><></groupid testwebproject
artifactid><></artifactid com.test.web.test
<><>0.0.1-snapshot版本/版本
<>></包装包装
> <建设
<!——第一种方式,两种方式都需要指定需要编译的目录——>
> <资源
> <资源
<目录> SRC /主/资源/ <目录>
<!可以在此配置过滤文件——>——
<五>
<>××/×.xsd include include></
<>××/×.properties include include></
<五>
<!开启filtering功能——>——
<>></过滤过滤真
资源></
资源></

	


> <插件
> <插件
Maven是artifactid><></artifactid插件
配置> <
<><>2.5版本的版本号
></配置
></插件
></插件
></编译
></项目


然后编译我们的maven项目

 干净的编译-duser.name MVN美元汤姆

编译完后,查看输出文件目标/班/ test.properties的内容,可见原先的”你好user.name } {“已经变成”你好,汤姆“。


上面如果麻烦的话,也可以把filtering用到的变量写在项目得属性段里面,如下面的方式

 

<!也可以配置到外部属性里面——>——
<属性>
<>></user.name user.name幸运
<>50></user.age user.age
<属性>


进行编译MVN,编译在此查看的话美元,清洁,就会看到属性被替换的效果

当然了,如果属性比较多的话,那么此时可以把属性单独抽取出来一个* .properties文件来保存,例如我们在pom.xml的同级目录下面创建一个project.properties,里面指明我们的内容

user.name =幸运

紧接着在修改我们的pom文件,如下


<Project xmlns=”http://maven.apache.org/POM/XSI 4.0.0 xmlns:“=”http://服务/2001/XMLSchema实例”
XSI:SchemaLocation=”http:///POM maven.apache.org 4.0.0 http:/ / / / maven.apache.org XSD maven-4.0.0.xsd”>
modelversion><></modelversion 4.0.0
groupid><></groupid testwebproject
artifactid><></artifactid com.test.web.test
<><>0.0.1-snapshot版本/版本
<>></包装包装


> <建设
<!——第一种方式,两种方式都需要指定需要编译的目录——>
> <资源
> <资源
<目录> SRC /主/资源/ <目录>
<!可以在此配置过滤文件——>——
<五>
<>××/×.xsd include include></
<>××/×.properties include include></
<五>
<!开启filtering功能——>——
<>></过滤过滤真
资源></
资源></

> <滤波器
<!是以该pom文件路径作为参考——>——
<>></project.properties过滤器过滤器
></滤波器


> <插件
> <插件
Maven是artifactid><></artifactid插件
配置> <
<><>2.5版本的版本号
></配置
></插件
></插件
></编译
></项目


再次执行编译命令的话,就会看到效果



 profile功能

里面定义若干个profile段,允许在项目文件(pom.xml文件)然后在编译时选择其中的一个用于覆盖项目文件原先的定义.接着上一个例子,如果我们需要为开发环境和生产环境定义不同的用户的名字属性值,则我们在项目目录里创建两个属性文件分别是pre.properties和dev.properties lucky和user.name,然后再每个文件里分别写入user.name = =旺旺,然后在此修改我们的pom文件,修改后如下所示

<Project xmlns=”http://maven.apache.org/POM/XSI 4.0.0 xmlns:“=”http://服务/2001/XMLSchema实例”
XSI:SchemaLocation=”http:///POM maven.apache.org 4.0.0 http:/ / / / maven.apache.org XSD maven-4.0.0.xsd”>
modelversion><></modelversion 4.0.0
groupid><></groupid testwebproject
artifactid><></artifactid com.test.web.test
<><>0.0.1-snapshot版本/版本
<>></包装包装


> <建设
<!——第一种方式,两种方式都需要指定需要编译的目录——>
> <资源
> <资源
<目录> SRC /主/资源/ <目录>
<!可以在此配置过滤文件——>——
<五>
<>××/×.xsd include include></
<包括> * * * * * * * * * * * * * * * * * * * * * * * * *
< /包含>
<!——开启过滤功能-->
<过滤>真< /过滤>
<资源>
< /资源>

<配置文件>
<配置文件>
<标识>开发< /标识>
<激活>
<!——默认的编译选项-->
< activebydefault >真的< / activebydefault >
< /激活>
<建设>
<筛选器>
<筛选器>预。
< /筛选器>
< /构建>
< [配置文件>

<配置文件>
<标识>前< /标识>
<建设>
<筛选器>
<滤镜> dev.properties < /过滤器>
< /筛选器>
< /构建>
< [配置文件>
< /配置文件>


<插件>
<插件>
< > Maven插件artifactId战争/ artifactId > <
<配置>
<版本> 2.5 < /版本>
< /配置>
< /插件>
< /插件>
< /构建>
< /项目>

在编译项目时,可以使用•磷参数指定需要使用的简介身份证件,比如下面命令将会使用发展概况

$ MVN清洁编译PEDV

如果想使用前,只需要改为以下即可

$ MVN清洁编译PPRE

假如不指定•磷参数的话,则会使用activebydefault =真的一项(即)。



 

 

 

 

作者:zhouchaoqiang发表于2015 / 12 / 27 12:54:09原文链接
阅读:108评论:1查看评论
]]>
为OLED屏增加GUI支持2:2d图形库 http://prog3.com/sbdm/blog/jdh99/article/details/50411871 http://prog3.com/sbdm/blog/jdh99/article/details/50411871 jdh99 2015 / 12 / 27 12:06:20 为OLED屏增加GUI支持2:2d图形库


本文博客链接:http://prog3.com/sbdm/blog/jdh99,作者:JDH,转载请注明。

 

环境:

主机:赢10

开发环境:mdk5.13

STM32F103单片机:


说明:
桂库的基础是一个2D图形库,为控件提供绘图功能
此图形库还包括单色BMP图像显示函数,为图片控件提供支持


源代码:

gui_2d_lib。H

* * * *
*版权所有(C),2015-2025年
* @ gui_2d_lib C文件。
* @简单的2D图形库主文件
* @作者JDH
*日期2015 / 9 / 6
* @更新2015 / 9 / 7
* @更新2015 / 11 / 22
*

#则_gui_2d_lib_h_
#定义_gui_2d_lib_h_

/ *********************************************************************
*头文件
********************************************************************** /

#包括“gui_interface。”

/ *********************************************************************
*函数
********************************************************************** /

* * * *
简要绘制水平线条* @
* @param Y Y位置
* @param x0:X起始位置
* @param X1:X结束位置
*

无效gui_draw_hline(uint16_t Y,uint16_t uint16_t X0,X1);

* * * *
简要绘制垂直线条* @
* @param x x位置
* @param Y0:Y起始位置
* @param Y1:Y结束位置
*

无效gui_draw_vline(uint16_t X,uint16_t Y0,uint16_t Y1);

* * * *
简要绘制线条* @
* @param x0:X起始位置
* @param Y0:Y起始位置
* @param X1:X结束位置
* @param Y2:Y结束位置
*

无效gui_draw_line(uint16_t x0,y0 uint16_t,uint16_t uint16_t X1,Y1);

* * * *
简要绘制矩形* @
* @param x0:左上角X坐标
* @param Y0:左上角Y坐标
* @param X1:右上角X坐标
* @param Y2:右上角Y坐标
*

无效gui_draw_rect(uint16_t x0,y0 uint16_t,uint16_t uint16_t X1,Y1);

* * * *
简要填充矩形* @
* @param x0:左上角X坐标
* @param Y0:左上角Y坐标
* @param X1:右上角X坐标
* @param Y2:右上角Y坐标
* @param显示:0:1:不显示,显示
*

无效gui_fill_rect(uint16_t x0,y0 uint16_t,uint16_t X1,uint16_t Y1,uint8_t显示);

* * * *
简要在指定位置显示图片* @
* @param x x坐标
* @param Y Y坐标
* @param BMP:图片
*

无效gui_draw_bitmap(uint16_t X、Y uint16_t,const uint8_t * BMP);

# endif



gui_2d_lib C。
* * * *
*版权所有(C),2015-2025年
* @ gui_2d_lib C文件。
* @简单的2D图形库主文件
* @作者JDH
*日期2015 / 9 / 6
* @更新2015 / 9 / 7
* @更新2015 / 11 / 22
*

/ *********************************************************************
*头文件
********************************************************************** /

#包括“gui_2d_lib。”
#包括“弦。”

/ *********************************************************************
*数据结构
********************************************************************** /

# pragma包(1)

* * * *
简要文件头* @
*

结构_bmp_file_header
{
/ /文件标志
uint16_t型;
/ /文件大小
uint32_t大小;
/ /保留
uint16_t保留1;
/ /保留
uint16_t保留2;
/ /位图偏移量
uint32_t offbits;
};

* * * *
* @ BRI信息头
*

结构_bmp_info_header
{
/ /信息头大小
uint32_t大小;
/ /位图宽度
uint32_t宽度;
/ /位图高度
uint32_t高度;
/ /位图的位面数
uint16_t飞机;
/ /每个像素点所需的数据位数(24)
uint16_t offbits;
/ /压缩算法
uint32_t压缩;
/ /位图数据字节数
uint32_t size_image;
/ / /米的单位表示水平分辨率以像素
uint32_t xpe_is_per_meter;
/ / /米的单位表示垂直分辨率以像素
uint32_t ype_is_per_meter;
/ /位图使用的颜色数
uint32_t color_used;
/ /指定重要颜色数
uint32_t color_important;
};

#语用pack()

/ *********************************************************************
*函数
********************************************************************** /

* * * *
简要绘制水平线条* @
* @param Y Y位置
* @param x0:X起始位置
* @param X1:X结束位置
*

无效gui_draw_hline(uint16_t Y,uint16_t uint16_t X0,X1)
{
uint16_t x = 0;
	
对(X = x0;x <= X1;X + +)
{
gui_interface_draw_pixel(x,y,1);
}
}

* * * *
简要绘制垂直线条* @
* @param x x位置
* @param Y0:Y起始位置
* @param Y1:Y结束位置
*

无效gui_draw_vline(uint16_t X,uint16_t Y0,uint16_t Y1)
{
uint16_t y = 0;
	
为(y = y0;Y <= Y1;Y + +)
{
gui_interface_draw_pixel(x,y,1);
}
}

* * * *
简要绘制线条* @
* @param x0:X起始位置
* @param Y0:Y起始位置
* @param X1:X结束位置
* @param Y2:Y结束位置
*

无效gui_draw_line(uint16_t x0,y0 uint16_t,uint16_t uint16_t X1,Y1)
{
浮动= 0;
浮动0;
浮XX0 = x0;
浮yy0 = y0;
浮XX1 = x1;
浮YY1 = Y1;
uint16_t x = 0;
uint16_t y = 0;
	
=(yy0 - 1)/(XX0 - 1);
B = yy0 -(yy0 - 1)以/(x0 - X1);
	
对(X = x0;x <= X1 x0;X + +)
{
= * * * *;
gui_interface_draw_pixel(x,y,1);
}
}

* * * *
简要绘制矩形* @
* @param x0:左上角X坐标
* @param Y0:左上角Y坐标
* @param X1:右上角X坐标
* @param Y2:右上角Y坐标
*

无效gui_draw_rect(uint16_t x0,y0 uint16_t,uint16_t uint16_t X1,Y1)
{
gui_draw_hline(Y0,X0,X1);
gui_draw_hline(Y1,X0,X1);
gui_draw_vline(x0,y0,y1);
gui_draw_vline(X1,Y0,Y1);
}

* * * *
简要填充矩形* @
* @param x0:左上角X坐标
* @param Y0:左上角Y坐标
* @param X1:右上角X坐标
* @param Y2:右上角Y坐标
* @param显示:0:1:不显示,显示
*

无效gui_fill_rect(uint16_t x0,y0 uint16_t,uint16_t X1,uint16_t Y1,uint8_t显示)
{
uint16_t我= 0;
uint16_t j = 0;
	
对(我= x0;我< = x1;i++)
{
为(J = y0;J <= Y1;j++)
{
gui_interface_draw_pixel(I,J,显示);
}
}
}
* * * *
简要在指定位置显示图片* @
* @param x x坐标
* @param Y Y坐标
* @param BMP:图片
*

无效gui_draw_bitmap(uint16_t X、Y uint16_t,const uint8_t * BMP)
{
结构_bmp_file_header bmp_file_header;
结构_bmp_info_header bmp_info_header;
uint8_t * buf_pt = 0;
uint16_t我= 0;
uint16_t j = 0;
uint8_t点= 0;
uint8_t index_bit = 0;
uint16_t行= 0;
uint16_t柱= 0;
uint16_t num_bit_invalid = 0;
	
/ /读取文件头
memcpy(与bmp_file_header,BMP,sizeof(struct _bmp_file_header));
/ /读取信息头
memcpy(与bmp_info_header + sizeof(struct _bmp_file_header,BMP),sizeof(struct _bmp_info_header));
/ /图片数据
buf_pt =(uint8_t *)+ bmp_file_header.offbits BMP;
/ / 4字节对齐导致的无效位数
num_bit_invalid = 32(bmp_info_header.width % 32);
	
/ /显示图片
为(i = 0;i < bmp_info_header.width * bmp_info_header。高度;i++)
{
位=(* buf_pt > >(7 index_bit))& 0x1;
inf_lcd_draw_pixel(X + Y + bmp_info_header.height柱,1排,位);
		
index_bit + +;
如果(index_bit > = 8)
{
index_bit = 0;
buf_pt + +;
}
		
列+ +;
如果(列> = bmp_info_header。宽度)
{
列= 0;
行+ +;
			
/ /补齐
为(J = 0;J < num_bit_invalid;j++)
{
index_bit + +;
如果(index_bit > = 8)
{
index_bit = 0;
buf_pt + +;
}
}
}
}
}



作者:jdh99发表于2015 / 12 / 27 12:06:20原文链接
阅读:142评论:0查看评论
]]>
leetcode笔记:同一棵树 http://prog3.com/sbdm/blog/liyuefeilong/article/details/50411786 http://prog3.com/sbdm/blog/liyuefeilong/article/details/50411786 liyuefeilong 2015 / 12 / 27 11:43:25 一。题目描述

给定2个二叉树,写一个函数来检查它们是否相等或不相等。

二元树被认为是平等的,如果它们在结构上相同,节点具有相同的值。

二。题目分析

题目的意思很简单,判断两棵树是否相同,递归,对两棵树的结点进行比较即可。

三。示例代码

#包括 <iostream>

使用命名空间标准;

结构树节点{
int val;
树节点*左;
树节点*是的
树节点(int x):Val(x),左(),对(){ }
};

类解{
公共:
布尔issametree(树节点*P、树节点*问)
{
        如果(对= =  & &Q= = 返回 真正的/ / P和问不同时到达叶节点,则剪枝
        其他的 如果((对!=  & &Q= = | |(对= =  & &Q!= 返回 返回(对•>瓦尔= =Q•>Val)& &issametree(P•>左,问•>左)
               & &issametree(P•>权利,问•>权利);
}
};

四。小结

该题属于二叉树的遍历中的基础题目,难度不大。

作者:liyuefeilong发表于2015 / 12 / 27 11:43:25原文链接
阅读:152评论:0查看评论
]]>
代理模式 http://prog3.com/sbdm/blog/zjf280441589/article/details/50411737 http://prog3.com/sbdm/blog/zjf280441589/article/details/50411737 hanqing280441589 2015 / 12 / 27 11:27:12
代理模式

标签:Java与设计模式


代理模式

为其他对象提供一种代理以控制对这个对象的访问(可以详细控制访问某个对象的方法,在调用这个方法[前/后]做[前/后]置处理,从而实现将统一流程放到代理类中处理)。

  • 我们书写执行一个功能的函数时,经常需要在其中写入与功能不是直接相关但很有必要的代码(如日志记录,事务支持等);这些枝节性代码虽然是必要的,但它会带来以下麻烦:

    1. 枝节性代码游离在功能性代码之外,它不是函数的目的,这是对OO是一种破坏;
    2. 枝节性代码会造成功能性代码对其它类的依赖,加深类之间的耦合,会造成功能性代码移植困难,可重用性降低,这是OO系统所竭力避免的;
    3. 从正常角度来说:枝节性代码应该监视着功能性代码,然后采取行动,而不是功能性代码通知枝节性代码采取行动,这好比吟游诗人应该是主动记录骑士的功绩而不是骑士主动要求诗人记录自己的功绩

  • Java代理分类

    1. 静态代理:手动定义代理类
    2. 动态代理:动态生成代理类
      • JDK自带的动态代理
      • javaassist字节码操作库实现
      • CGLIB
      • ASM(底层使用指令,可维护性差)

  • 代理中的角色

    1. 抽象接口:声明真实对象和代理对象的共同接口
    2. 代理对象:代理对象内部包含真实对象的引用,从而可以操作真实对象;同时,代理对象与真实对象有相同的接口,能在任何时候代替真实对象,而且代理可以在真实对象前后加入特定的逻辑以实现功能的扩展
    3. 真实对象:代理对象所代表的对象;是我们最终要引用的对象

静态代理

我们模拟请明星唱歌这个过程,但大家都知道要请明星唱歌(比如周杰伦)是一件比较麻烦的事情,比如唱歌前要签约,唱歌之后还有收款,而平时明星们都是比较忙的,想签约,收款这些事情一般都是由他的助手来代理完成的,而明星只负责唱歌就行了,像签约收款这种事情就可以算作是明星的增强,虽然这不是明星的主要目的,但是这个流程是必须要有的

  • 目标接口
* * * *
*定义真实对象和代理对象的公共接口
*由技防15 / 12 / 20。
*
公共 接口 明星{
    / /签约
    无效signcontract();

    / /唱歌
    无效singsong();

    / /收款
    无效collectmoney();
}
  • 真实对象
公共  瑞之达 实现了 明星{
    * * * *
*由于这些事情都委托给代理来做了,因此我们只是象征性实现就好了
*
    “重写”
    公共 无效 signcontract(){
}

    “重写”
    公共 无效 collectmoney(){
}

    * * * *
*但唱歌是要自己真唱的
*
    “重写”
    公共 无效 单调的(){
系统,println(。“周杰伦在唱歌”);
}
}
  • 代理对象
    自己并未实现业务逻辑接口,而是调用真实角色来实现:
公共  staticproxy 实现了 明星{

    私人星星;

    公共 staticproxy(星){
        星=星;
}

    “重写”
    公共 无效 signcontract(){
系统,println(。“代理签约”);
}

    * * * *
*代理可以帮明星做任何事,但唯独唱歌这件事必须由明星自己来完成
*
    “重写”
    公共 无效 单调的(){
singsong()明星;
}

    “重写”
    公共 无效 collectmoney(){
系统,println(。“代理收钱”);
}
}
  • 客户端
公共 客户{

“测试”
    公共 无效 客户端(){
星星=新的staticproxy(新的realstar());
signcontract()明星;
singsong()明星;
collectmoney()明星;
}
}

可以看出,客户实际想要调用的是瑞之达单调的方法,现在用staticproxy来代理瑞之达类,也可以达到同样的目的,同时还封装了其他方法(像singcontract ` ` collectmoney),可以处理一些其他流程上的问题。
如果要按照上述的方法使用代理模式,那么真实角色必须是事先已经存在的,并将其作为代理对象的内部属性;但是实际的Java应用中,如果有一批真实对象,而毎个代理对象只对应一个真实对象的话,会导致类的急剧膨胀;此外,如果我们事先并不知道真实角色,那么该如何使用编写代理类呢?这个问题可以通过Java的动态代理机制来解决。


动态代理

所谓动态代理是这样一种:它是在运行时生成的类,在生成它时你必须提供一组接口给它,然后该类就宣称它实现了这些接口。

JDK对动态代理提供了以下支持:

  • java.lang.reflect.proxy动态生成代理类和对象
  • java.lang.reflect.invocationhandler
    • 可以通过调用方法实现对真实角色的代理访问;
    • 每次通过代理生成代理类对象时都要指定对象的处理器对象。

首先,明星接口可以精简一下,只做他该做的事情:

  • 明星
* * * *
*星只负责唱歌就行了
*由技防15 / 12 / 20。
*
公共 接口 明星{
    / /唱歌
    无效singsong();
}
  • 瑞之达
公共  瑞之达 实现了 明星{
    * * * *
*唱歌是要自己真唱的
*
    “重写”
    公共 无效 单调的(){
系统,println(。“周杰伦在唱歌”);
}
}

当执行动态代理对象里的方法时,实际上会替换成调用InvocationHandler中的调用方法。

  • InvocationHandler:用于实现代理
* * * *
*相当于原先的代理需要执行的方法
*由技防15 / 12 / 20。
*
公共  proxyhandler 实现了 InvocationHandler{

    私人星星;

    公共 proxyhandler(星){
        星=星;
}

    * * * *
*代理对象的实现的所有接口中的方法,内容都是调用调用方法
*
*@参数代理代理对象(代理。代理实例返回的对象)
*@参数方法当前被调的方法
*@参数一执行当前方法的参数
*“返回”执行方法方法的返回值
*“扔”Throwable
*
    “重写”
    公共对象调用(代理对象、方法、对象[] args)抛出Throwable {
系统,println(。“签约”);
对象结果=如果(方法。getname()。等于(“单调的”){
结果:方法调用(明星,args);
}
系统,println(。“收款”);
        返回结果;
}
}
  • 客户端
公共  客户端{

    “测试”
    公共 无效 客户端(){
        * * * *
*代理实例方法会动态生成一个代理类,他实现了明星接口,然后创建该类的对象。
*
*三个参数
* 1。类加载器:生成一个类,这个类也需要加载到方法区中,因此需要指定classloader来加载该类
* 2。类接口:要实现的接口[ ]
* 3。调用处理器InvocationHandler:
*
明星proxystar =(星)代理。代理实例(getsystemclassloader()类加载器,新的类[ ] {星类},新的proxyhandler(新的realstar()));
proxystar。singsong();
}
}

代理工厂实现动态代理

  • 动态代理虽然可以使得我们不用在手写代理对象的代码,但是InvocationHandler还是面向特定的抽象接口(如星)The proxy factory can make our code written moreabstract(and does not have to write code for a determined abstract interface).
  • The target of the agency isTarget object and enhancement method can be changed, this pattern in the reality of the performance is:
    A.The star of the agent is not necessarily consistent, the star may be replaced at any time (Assistant);
    B.The stars don't have to sing.He may also be dancing.
    C.Agents may not just serve a star
    In this way, we will implement a proxy factory.The auxiliary work done by the agent can be changed at will; and the target object can also be added at any time..

    Can see,ProxyFactoryandStartThere is no relationship between them, and they can be linked to other is entirely by Client to facilitate.


  • Agent factory

/ * *
* by Jifang on 15/12/21. Created
* /
Public Class ProxyFactory{

    PrivateBeforeAdvice BeforeAdvice;
    PrivateTargetObject Object;
    PrivateAfterAdvice AfterAdvice;

    Public ProxyFactory(1)
}

    Public ProxyFactory(beforeAdvice Object, targetObject BeforeAdvice, afterAdvice AfterAdvice) {
        This.beforeAdvice = beforeAdvice;
        This.targetObject = targetObject;
        This.afterAdvice = afterAdvice;
}

    PrivateHandler InvocationHandler =NewInvocationHandler () {

        @Override
        PublicObjectInvoke(proxy Method, method Object[], args Object)ThrowsThrowable {
            IfBeforeAdvice! =.Null{)
BeforeAdvice.before ();
}

Result Object =Null;
            IfTargetObject! =.Null{)
Result = method.invoke (targetObject, args);
}

            IfAfterAdvice! =.Null{)
AfterAdvice.after ();
}

            ReturnResult;
}
};

    PublicObjectCreateProxy(1)
        ReturnProxy.newProxyInstance (ClassLoader.getSystemClassLoader (), targetObject.getClass ().GetInterfaces (), handler ();
}
}
  • Client
    StarandRealStaribid
/ * *
* by Jifang on 15/12/20. Created
* /
Public Class Client{

    @Test
    Public Void Client(1)
Star Star = (Star)NewProxyFactory (NewStarBeforeAdvice (),NewRealStar (),NewStarAfterAdvice ()).CreateProxy () ();
Star.singSong ();
}

    / * *
* BeforeAdvice implementation can be customized
* /
    Private Static Class StarBeforeAdvice Implements BeforeAdvice{

        @Override
        Public Void Before(1)
System.out.println ("Sign a contract");
}
}

    / * *
* AfterAdvice implementation can be customized
* /
    Private Static Class StarAfterAdvice Implements AfterAdvice{

        @Override
        Public Void After(1)
System.out.println ("Collection");
}
}
}

Now, we have a relatively high demand for the star, he will not only sing, but also dance.

Public Interface{Star
    / / sing
    VoidSingSong ();

    / / Dance
    VoidDancing ();
}
Public Class RealStar Implements Star{
    / /...

    @Override
    Public Void Dancing(1)
System.out.println ("Jay Chou is dancing...");
}
}

At this time, ourClientNothing needs to be changed, just add a call can be:

Public ClassClient {

@Test
    Public Void Client(1)
Star Star = (Star)NewProxyFactory (NewStarBeforeAdvice (),NewRealStar (),NewStarAfterAdvice ()).CreateProxy () ();
Star.singSong ();
Star.dancing ();
}

    / /...
}

And in the actual development, these enhancements can also be read from the configuration file (like Spring).
This agent inAOP (Orient Programming: Aspect aspect oriented programming)Be becomeAOP agent, the AOP proxy contains all the methods of the target object, but there are differences between the method of the AOP agent and the target object: for example, you can insert some common processing before / after the execution of the target method.


Agent scene

  • When Client needs to call an object, the client does not careWhether it is accurate to get the object, Client is just an object that can provide the function, so we can return the object's agent (Proxy).agentIs the introduction of a certain degree of access to the objectIndirectWe can do a lot of work because of the indirect nature:
    1. Remote agent: providing an object in a different address spaceLocal representative, which can hide the fact that an object is present in different address spaces (Dubbo implementation);
    2. Security agent: shield the access to the real role, using agents to control access to real objects;
    3. Delayed loading: the first to load the lightweight proxy object, and then the real need to load the real object.

Reference resources
You should know the RPC principle.
Design pattern
Gao Qi stresses design patterns
Cui Xifan speak dynamic agent
Java agent mechanism
Application scenarios of commonly used design patterns
Author: hanqing280441589 published in 11:27:12 2015/12/27Text link
Read: 178 comments: 0View comments
]]>
[Java concurrent programming] - AQS (three): blocking, wake: LockSupport Http://prog3.com/sbdm/blog/chenssy/article/details/50411736 Http://prog3.com/sbdm/blog/chenssy/article/details/50411736 Chenssy 11:28:58 2015/12/27 In the last blog[Java concurrent programming] - AQS (two): get the lock, release the lockWhen a thread is added to the CLH queue, if not the first node is required to determine whether the node needs to be suspended; after the release of the lock, you need to wake up the thread's successor node

Lock method, called acquireQueued ():

If (shouldParkAfterFailedAcquire (P, node) and
ParkAndCheckInterrupt ())
Interrupted = true;

Call parkAndCheckInterrupt () in the acquireQueued () to suspend the current thread:

Final Boolean parkAndCheckInterrupt private () {
LockSupport.park (this);
Thread.interrupted return ();
}

Call LockSupport.park () method. aboutPark (): in order to thread scheduling, before the license can be used to disable the current thread.

After the release of the lock, it is necessary to wake up the thread successor node:

Final Boolean release public (Arg int) {
If (tryRelease (ARG)) {
H Node = head;
If (H! = null & & h.waitStatus! = 0)
UnparkSuccessor (H);
True return;
}
False return;
}

Call unparkSuccessor (in the release method) to wake up the successor node of the thread. Wake up by LockSupport.unpark () in the unparkSuccessor () method.Unpark (): if a given thread's permission is not available, it can be used.

LockSupport

LockSupport is used to create the basic thread blocking primitives for locks and other synchronization classes. Each thread that uses LockSupport will be associated with a license, if the license is available, and can be used in the process, the call park () will be returned immediately, otherwise it may be blocked. If the license is not available, you can call theUnparkMake it available. But note that the license can not be re entered, that is, only call a park () method, otherwise it will always block.

LockSupport.park (), LockSupport.unpark () is the role of blocking the thread and the lifting of the blocking thread, and Park () and unpark () will not encounter "Thread.suspend () and Thread.resume may cause the deadlock" problem. Of course, unpark (), Park () is used in pairs.

Park (): if the license is available, the permission is used, and the call returns immediately; otherwise, the thread is scheduled to disable the current thread, and before the occurrence of one of the following three cases, it is in a state of dormancy:

  • Some other thread will present the current thread as a target call.UnparkOr; or
  • Some other thread interrupts the current thread; or
  • The call is illogical (i.e., no reason) to return.

    Its source code is as follows:

    Static void Park Public () {
    Unsafe.park (false, 0L);
    }

    Unpark: if the license is not available for a given thread, it can be used. If the thread is blocked on the park, it will lift its blocking state. Otherwise, to ensure that the next call park will not be blocked. If a given thread has not been started, there is no guarantee that this operation has any effect.

    Its source code is as follows:

    Static void unpark public (thread Thread) {
    If (thread! = null) {
    Lock Object = unsafe.getObject (thread, lockOffset);
    Synchronized (lock) {
    If (thread.isAlive ()) {
    Unsafe.unpark (thread);
    }
    }
    }
    }

    Generally speaking, unpark (), Park () is in pairs, and unpark must be executed after the park, of course, is not to say that there is no call unpark thread will be blocked, park has a method, it with a time stamp (nanos long): in order to schedule the thread to disable the current thread, waiting for the maximum waiting time, unless the license is available.

     

    Reference material

    1,Park the basic use of unpark and LockSupport, as well as the response to the thread interrupt

  • Author: chenssy published in 11:28:58 2015/12/27Text link
    Read: 166 comments: 0View comments
    ]]>
    Android plug in (a): the use of improved dynamic load MultiDex APK assets Http://prog3.com/sbdm/blog/nupt123456789/article/details/50411581 Http://prog3.com/sbdm/blog/nupt123456789/article/details/50411581 NUPTboyZHB 10:41:47 2015/12/27 Android plug in (a): the use of improved dynamic load MultiDex APK assets

    brief introduction

    In order to solve the problem of excessive number of 65535 methods, Google recommended the use of MultiDex to load classes2.dex, classes3.dex and so on, the basic idea is to dynamically modify the ClassLoader at runtime, in order to achieve the purpose of dynamic loading class. In order to better understand the working principle of MultiDex, you can look at the working principle of [1]. ClassLoader and then see the PathClassLoader source code, of course, it inherited from the BaseDexClassLoader, the main source is in the BaseDexClassLoader. The process of MultiDex loading offline APK is as follows:
    MultiDex

    We can develop the Application method in the onCreate method or the attachBaseContext method of Activity.

    Dynamic loading of APK in assets

    According to the MultiDex source code, we can modify its install method, and then extract the assets resources from the need to load the APK file, and then call the installSecondaryDexes method, which is loaded into the current ClassLoader Application which, in the running time, you can find the current ClassLoader to the offline apk class.

    [AssetsMultiDexLoader.class]

    PackageNet.mobctrl.hostapk;
    
    ImportJava.io.File;
    ImportJava.io.FilenameFilter;
    ImportJava.io.IOException;
    ImportJava.lang.reflect.Array;
    ImportJava.lang.reflect.Field;
    ImportJava.lang.reflect.InvocationTargetException;
    ImportJava.lang.reflect.Method;
    ImportJava.util.ArrayList;
    ImportJava.util.Arrays;
    ImportJava.util.HashSet;
    ImportJava.util.List;
    ImportJava.util.ListIterator;
    ImportJava.util.Set;
    ImportJava.util.zip.ZipFile;
    
    ImportAndroid.content.Context;
    ImportAndroid.content.pm.ApplicationInfo;
    ImportAndroid.content.pm.PackageManager;
    ImportAndroid.content.pm.PackageManager.NameNotFoundException;
    ImportAndroid.os.Build;
    ImportAndroid.util.Log;
    ImportDalvik.system.DexFile;
    
    / * *
    *@AuthorHaibo Zheng
    *@MailMochuan.zhb@alibaba-inc.com
    *@CompanyGroup Alibaba
    *@PersonalWebsiteHttp://www.mobctrl.net
    *@versionAssetsDex.java V, 5:36:23 0.12015 years December 10th mochuan.zhb Exp $Id: $
    *@DescriptionClassLoader
    * /
    Public Class AssetsMultiDexLoader{
    
        Private Static FinalTAG String ="AssetsApkLoader";
    
        Private Static BooleanInstalled =False;
    
        Private Static Final IntMAX_SUPPORTED_SDK_VERSION =Twenty;
    
        Private Static Final IntMIN_SDK_VERSION =Four;
    
        Private Static FinalInstalledApk Set<String> =NewHashSet<String> ();
    
        Private AssetsMultiDexLoader(1)
    
    }
    
        / * *
    * install APK files in Assets
    *
    *@paramContext
    * /
        Public Static Void Install(context Context) {
    Log.i (TAG,"Install...");
            If(installed) {
                Return;
    }
            Try{
    ClearOldDexDir (context);
    }Catch(t Throwable) {
    Log.w (TAG,
                        "Went wrong when trying to clear Something old MultiDex extraction,"
    +"Without cleaning. continuing"T);
    }
    AssetsManager.copyAllAssetsApk (context);
    Log.i (TAG,"Install");
            If(Build.VERSION.SDK_INT < MIN_SDK_VERSION) {
                Throw NewRuntimeException ("DEX installation failed. SDK Multi"
    + Build.VERSION.SDK_INT
    +"Unsupported. Min SDK version is is"+ MIN_SDK_VERSION
    +"");
    }
            Try{
    ApplicationInfo ApplicationInfo = getApplicationInfo (context);
                If(applicationInfo = =Null{)
                    Like running on a test / Looks Context, so just return without
                    / / patching.
                    Return;
    }
                Synchronized(installedApk) {
    ApkPath String = applicationInfo.sourceDir;
                    If(installedApk.contains (apkPath)) {
                        Return;
    }
    InstalledApk.add (apkPath);
                    If(Build.VERSION.SDK_INT > MAX_SUPPORTED_SDK_VERSION) {
    Log.w (TAG,
                                "Is not guaranteed to work in SDK MultiDex version"
    + Build.VERSION.SDK_INT
    +"Version higher than SDK"
    + MAX_SUPPORTED_SDK_VERSION
    +"Be backed by should"
    +“内置multidex能力运行但它不是”
    +“在这里:爪哇,虚拟机。
    getProperty(+系统。“爪哇,虚拟机,版本”)
    +“\”);
    }
                    / *
    *补丁的类装入程序将是一个后代
    * dalvik.system.basedexclassloader。我们修改它
    * dalvik.system.dexpathlist pathlist场追加
    * DEX文件条目。
    *
    类装载器装载机;
                    试试看{
    装载机为背景。getclassloader();
    }抓住(RuntimeException e){
                        / *
    *忽略这些例外情况,以便我们不中断测试
    *依托语境像android.test.mock.mockcontext
    *或一个空座android.content.contextwrapper
    *上下文。
    *
    日志(标记,
                                “试图获得上下文类装入器时失败。”
    +“必须在测试模式下运行。跳过修补。”,
    );
                        返回;
    }
                    如果(装载机= =){
                        在运行时,上下文类装载程序是空的
                        / / robolectric试验。
    日志:电子标签,
                                “上下文类装入器是空的。必须运行在测试模式。”
    +“不打补丁。”);
                        返回;
    }
                    / /获取DEX文件列表
    文件dexdir =背景。getdir(assetsmanager.apk_dir,语境。mode_private);
    文件[ ] szfiles = dexdir listfiles(。新的filenamefilter() {
    
                        “重写”
                        公共 布尔 接受(文件目录、文件名字符串){
                            返回文件名。EndsWith(assetsmanager。file_filter);
    }
    });
    列出<文件>文件=新的ArrayList <文件>();
                    对于(文件:szfiles){
    日志,我(标签,“加载文件:”+ F getname());
    文件,添加(女);
    }
    日志,我(标签,“装载机前:”+上下文getclassloader());
    installsecondarydexes(装载机,dexdir,文件);
    日志,我(标签,“装载机结束:”+上下文getclassloader());
    }
    }抓住(例外){
    日志:电子标签,“multidex安装失败”,电子;
                 新的RuntimeException(“多组安装失败(“
    getmessage() + + E.“)。);
    }
    安装=真正的;
    日志,我(标签,“安装完成”);
    }
    
        私人 静态applicationinfogetapplicationinfo(上下文上下文)
                抛出namenotfoundexception {
    PackageManager PM;
    字符串packagename;
            试试看{
    PM = getpackagemanager()上下文;
    getpackagename() packagename =上下文;
    }抓住(RuntimeException e){
                / *
    *忽略这些例外,这样我们就不依赖于依赖于
    *背景像android.test.mock.mockcontext或
    *零基础背景android.content.contextwrapper。
    *
    日志(标记,
                        “失败而试图从语境中获取applicationinfo。”
    +“必须在测试模式下运行。跳过修补。”,电子;
                返回 ;
    }
            如果(下午= =| | packagename = =){
                这是最有可能的一个模拟的背景下,所以刚刚返回
                / /修补。
                返回 ;
    }
    applicationinfo applicationinfo = PM。getapplicationinfo(packagename,
    get_meta_data)器;
            返回applicationinfo;
    }
    
        私人 静态 无效 installsecondarydexes(ClassLoader装载机,文件dexdir,
    列表<文件>文件)抛出时,
    非法存取异常,nosuchfieldexception,
    invocationtargetexception,调用不存在方法异常,IOException {
            如果(!文件。isempty()){
                如果(build.version.sdk_int > =十九){
    V19。安装(程序,文件,dexdir);
    }其他的 如果(build.version.sdk_int > =十四){
    V14。安装(程序,文件,dexdir);
    }其他的{
    V4安装(装载机,文件);
    }
    }
    }
    
        * * * *
    *在类继承层次结构中找到一个给定的域。
    *
    *@参数实例
    *一个对象来搜索该领域。
    *@参数名称
    *字段名称
    *“返回”字段对象
    *“扔”nosuchfieldexception
    *如果该字段不能位于
    *
        私人 静态findfield(对象实例,字符串名称)
                抛出nosuchfieldexception {
            对于(班级?> clazz = getclass();类的实例!=类=类;
    getsuperclass()){。
                试试看{
    场=类getdeclaredfield(名字);
    
                    如果(!领域。isaccessible()){
    领域。setAccessible(真正的);
    }
    
                    返回田野;
    }抓住(nosuchfieldexception e){
                    / /忽略和搜索下一个
    }
    }
    
             新的nosuchfieldexception(“场”+名称+“未找到”
    getclass())+实例;
    }
    
        * * * *
    *在类继承层次结构中的任何地方找到一个给定的方法。
    *
    *@参数实例
    *一个对象来搜索的方法。
    *@参数名称
    *方法名称
    *@参数parametertypes
    *方法参数类型
    *“返回”方法对象
    *“扔”调用不存在方法异常
    *如果该方法不能位于
    *
        私人 静态方法findmethod(对象实例,字符串名称,
    班级<?>…parametertypes)抛出调用不存在方法异常{
            对于(班级?> clazz = getclass();类的实例!=类=类;
    getsuperclass()){。
                试试看{
    方法=类getdeclaredmethod(名称、parametertypes);
    
                    如果(!方法。isaccessible()){
    方法。setAccessible(真正的);
    }
    
                    返回方法;
    }抓住(调用不存在方法异常e){
                    / /忽略和搜索下一个
    }
    }
    
             新的调用不存在方法异常(“方法”+名称+“参数”
    +阵列。asList(parametertypes)+“未找到”
    getclass())+实例;
    }
    
        * * * *
    *替换一个包含非空数组的字段的值,由一个新数组
    *包含原始数组的元素,加上元素
    * extraelements。
    *
    *@参数实例
    *需要修改该字段的实例。
    *@参数字段名
    *现场修改。
    *@参数extraelements
    *元素在数组的结尾追加。
    *
        私人 静态 无效 expandfieldarray(对象实例,字符串字段名,
    对象[ ] extraelements)抛出nosuchfieldexception,
    时,非法存取异常{
    场jlrfield = findfield(例如,字段名);
    对象[ ]原=(对象[ ])jlrfield得到(实例);
    对象[ ]组合=(对象[ ])阵列。newInstance(getclass()原。
    。getcomponenttype(),original.length + extraelements长度);
    arraycopy(原系统,,结合,,原始长度);
    arraycopy(extraelements系统,,结合,original.length,
    extraelements长度);
    jlrfield集(实例,结合);
    }
    
        私人 静态 无效 clearolddexdir(上下文上下文)抛出例外{
    文件dexdir =背景。getdir(assetsmanager.apk_dir,语境。mode_private);
            如果(dexdir。isdirectory()){
    日志,我(标签,“清算旧二Dex目录(“+ dexdir。getpath()
    +“)。);
    文件[ ] = dexdir listfiles()文件;
                如果(文件= =){
    日志(标记,“没有列出目录内容二DEX(”
    dexdir getpath() + +。“)。);
                    返回;
    }
                对于(文件覆盖旧的文件:文件){
    日志,我(标签,“试图删除旧文件”+ getpath()覆盖旧的文件。
    +“大小”+覆盖旧的文件。length());
                    如果(!覆盖旧的文件。delete()){
    日志(标记,“未能删除旧文件”+覆盖旧的文件。getpath());
    }其他的{
    日志,我(标签,“删除旧文件”+覆盖旧的文件。getpath());
    }
    }
                如果(!dexdir。delete()){
    日志(标记,
                            “无法删除二Dex目录”
    + dexdir getpath());
    }其他的{
    日志,我(标签,“删除旧的二Dex目录”+ dexdir getpath());
    }
    }
    }
    
        * * * *
    *安装平台版本19。
    *
        私人 静态 最后  V19{
    
            私人 静态 无效 安装(ClassLoader装载机,
    列表<文件> additionalclasspathentries,文件optimizeddirectory)
                    抛出时,非法存取异常,
    nosuchfieldexception,invocationtargetexception,
    调用不存在方法异常{
                / *
    *补丁的类装入程序将是一个后代
    * dalvik.system.basedexclassloader。我们修改它
    * dalvik.system.dexpathlist pathlist场追加DEX
    *文件项。
    *
    场pathlistfield = findfield(装载机,“pathlist”);
    对象dexpathlist = pathlistfield得到(装载机);
    ArrayList < IOException > suppressedexceptions =新的ArrayList < IOException >();
    expandfieldarray(
    dexpathlist,
                        “dexelements”,
    makedexelements(dexpathlist,新的ArrayList <文件>(
    additionalclasspathentries),optimizeddirectory,
    suppressedexceptions));
                如果(suppressedexceptions size() >。){
                    对于(IOException e:suppressedexceptions){
    日志(标记,“makedexelement”例外,电子;
    }
    场suppressedexceptionsfield = findfield(装载机,
                            “dexelementssuppressedexceptions”);
    IOException [ ] dexelementssuppressedexceptions =(IOException [ ])suppressedexceptionsfield
    (装载机);
    
                    如果(dexelementssuppressedexceptions = =){
    dexelementssuppressedexceptions = suppressedexceptions
    toArray(。新的[ suppressedexceptions IOException
    size() ]);
    }其他的{
    IOException [ ]结合=新的[ suppressedexceptions IOException
    dexelementssuppressedexceptions长度]。size() +;
    suppressedexceptions toArray(组合);
    arraycopy(dexelementssuppressedexceptions系统,,
    结合,suppressedexceptions。size(),
    dexelementssuppressedexceptions长度);
    dexelementssuppressedexceptions =组合;
    }
    
    suppressedexceptionsfield集(装载机,
    dexelementssuppressedexceptions);
    }
    }
    
            * * * *
    *一个包装器
    * { @代码静态最终Dalvik。系统。dexpathlist # makedexelements }
    *。
    *
            私人 静态对象[ ]makedexelements(对象dexpathlist,
    ArrayList <文件>文件,文件optimizeddirectory,
    ArrayList < IOException > suppressedexceptions)
                    抛出非法存取异常,invocationtargetexception,
    调用不存在方法异常{
    方法makedexelements = findmethod(dexpathlist,“makedexelements”,
    arraylist.class,file.class,ArrayList类);
    
                返回(对象[ ])makedexelements调用(dexpathlist,文件,
    optimizeddirectory,suppressedexceptions);
    }
    }
    
        * * * *
    * 18、16、17、15和14平台版本的安装程序。
    *
        私人 静态 最后  V14{
    
            私人 静态 无效 安装(ClassLoader装载机,
    列表<文件> additionalclasspathentries,文件optimizeddirectory)
                    抛出时,非法存取异常,
    nosuchfieldexception,invocationtargetexception,
    调用不存在方法异常{
                / *
    *补丁的类装入程序将是一个后代
    * dalvik.system.basedexclassloader。我们修改它
    * dalvik.system.dexpathlist pathlist场追加DEX
    *文件项。
    *
    场pathlistfield = findfield(装载机,“pathlist”);
    对象dexpathlist = pathlistfield得到(装载机);
    expandfieldarray(
    dexpathlist,
                        “dexelements”,
    makedexelements(dexpathlist,新的ArrayList <文件>(
    additionalclasspathentries),optimizeddirectory));
    }
    
            * * * *
    *一个包装器
    * { @代码静态最终Dalvik。系统。dexpathlist # makedexelements }
    *。
    *
            私人 静态对象[ ]makedexelements(对象dexpathlist,
    ArrayList <文件>文件,文件optimizeddirectory)
                    抛出非法存取异常,invocationtargetexception,
    调用不存在方法异常{
    方法makedexelements = findmethod(dexpathlist,“makedexelements”,
    arraylist.class,文件类);
    
                返回(对象[ ])makedexelements调用(dexpathlist,文件,
    optimizeddirectory);
    }
    }
    
        * * * *
    *安装平台版本4至13。
    *
        私人 静态 最后  V4{
            私人 静态 无效 安装(ClassLoader装载机,
    列表<文件> additionalclasspathentries)
                    抛出时,非法存取异常,
    nosuchfieldexception,IOException {
                / *
    *补丁的类装入程序将是一个后代
    * dalvik.system.dexclassloader。我们修改的字段mpaths,
    * mfiles,mzips和mdexs追加额外的DEX文件条目。
    *
                intextrasize = additionalclasspathentries。size();
    
    场pathfield = findfield(装载机,“路径”);
    
    StringBuilder路径=新的StringBuilder(
    (字符串)pathfield得到(装载机));
    字符串extrapaths = []新的extrasize弦[ ];
    文件extrafiles = []新的文件[ extrasize ];
    要extrazips = []新的要extrasize ] [;
    dexfile [ ] extradexs =新的dexfile [ extrasize ];
                对于(= additionalclasspathentries迭代器listIterator <文件>
    。listiterator();迭代器。hasnext();){
    文件additionalentry = next()迭代器;
    additionalentry getabsolutepath()字符串导入路径=;
    路径。':')添加(导入路径);
                    int指数= previousindex()迭代器;
    extrapaths [索引] =导入路径;
    extrafiles [索引] = additionalentry;
    extrazips [索引] =新的zip文件(additionalentry);
    extradexs [索引] = dexfile loaddex(导入路径,导入路径。
    +“敏捷”);
    }
    
    pathfield。集(装载机、路径。tostring());
    expandfieldarray(装载机,“mpaths”,extrapaths);
    expandfieldarray(装载机,“mfiles”,extrafiles);
    expandfieldarray(装载机,“mzips”,extrazips);
    expandfieldarray(装载机,“mdexs”,extradexs);
    }
    }
    
    }
    

    [ assetsmanager Java ]。

    net.mobctrl.hostapk;
    
    进口java.io.file;
    进口java.io.fileoutputstream;
    进口java.io.inputstream;
    进口java.io.outputstream;
    
    进口android.content.context;
    进口android.content.res.assetmanager;
    进口android.util.log;
    
    * * * *
    *作者郑海波
    *@邮件mochuan.zhb@alibaba-inc.com
    *@公司阿里巴巴集团
    *“个人网站http://www.mobctrl.net
    *@版本身份:assetsmanager.java美元,V 0.1 2015 12 11年月日下午4:41:10美元mochuan.zhb口
    *“描述
    *
    公共  assetsmanager{
    
        公共 静态 最后字符串标记=“assetsapkloader”/ /从资产复制出去的APK的目标目录
        公共 静态 最后字符串apk_dir =“third_apk”/ /文件结尾过滤
        公共 静态 最后字符串file_filter =“apk”* * * *
    *将资源文件中的APK文件拷贝到私有目录中
    *
    *@参数语境
    *
        公共 静态 无效 copyallassetsapk(上下文上下文){
    
    财富管理财富管理为背景。getassets();
            currenttimemillis() StartTime =系统;
            试试看{
    Dex文件为背景。getdir(apk_dir,语境。mode_private);
    mkdir() DEX;
    [ ]文件名的字符串列表(=财富管理。“”);
                对于(字符串的文件名:文件名){
                    如果(!文件名。EndsWith(file_filter)){
                        返回;
    }
    InputStream =;
    OutputStream =;
    在财富管理的开放(文件名);
    文件=新的文件(dex文件);
                    如果(F exists() & F. length() = =,available()){
    日志。我(标签,文件名+“没有变化”);
                        返回;
    }
    日志。我(标签,文件名+“chaneged”);
    =新的FileOutputStream(F);
                    字节缓冲=新的 字节二千零四十八];
                    int读;
                    ((读)(缓冲))!=—){
    写(缓冲区,,读);
    }
    在();
    在=;
    flush()出来;
    出来。();
    =;
    日志。我(标签,文件名+“复制”);
    }
    日志,我(标签,“# # # copyassets时间=“+(系统。currenttimemillis() -开始时间));
    }抓住(例外){
    E. printstacktrace();
    }
    
    }
    }
    

    以上就是从资产中加载APK的核心代码。

    演示运行

    打开bundleapk项目,编译成APK。然后将bundleapk .apk文件拷贝到hostapk项目的资产目录,在hostapk的MainActivity方法的onCreate当中,调用assetsmultidexloader。安装(getapplicationcontext());加载bundleapk .apk。然后我们就可以通过如下两种方式调用bundleapk中的类:

    • Class.forName
      由于我们的hostapk没有bundleapk类的引用,所以我们需要用反射的方式调用。
    私人 无效 loadClass(){
            试试看{
    班级<?>类类forName(=。“净。mobctrl。正常的.apk FileUtils”);
    
    构造函数<?> getconstructor() =类构造函数;
    bundleutils = newinstance()对象的构造函数;
    
    方法的基本方法(printsummethod =。“打印”,上下文,类,字符串类);
    printsummethod setAccessible(。真正的);
    printsummethod调用(bundleutils,
    getapplicationcontext(),“你好”);
    }抓住(例外){
    E. printstacktrace();
    }
    
    }
    • loadClass
      我们也可以直接获取当前的classloader对象,然后调用其loadClass方法
    “targetapi(建造。version_codes。ice_cream_sandwich)
        私人 无效 loadapk(){
            试试看{
    班级<?> clazz = getclassloader()
    loadClass(。“净。mobctrl。正常。APK工具”);
    构造函数<?> getconstructor() =类构造函数;
    bundleutils = newinstance()对象的构造函数;
    
    方法的基本方法(printsummethod =。“printsum”,context.class,
                        int类,int类,字符串类);
    printsummethod setAccessible(。真正的);
    整数金额=(整数)printsummethod调用(bundleutils,
    getapplicationcontext(),二十“计算结果”);
    系统,println(。“调试:和=”+和);
    }抓住(ClassNotFoundException e){
    E. printstacktrace();
    }抓住(SecurityException e){
    E. printstacktrace();
    }抓住(调用不存在方法异常e){
    E. printstacktrace();
    }抓住(时e){
    E. printstacktrace();
    }抓住(instantiationexception e){
    E. printstacktrace();
    }抓住(非法存取异常e){
    E. printstacktrace();
    }抓住(invocationtargetexception e){
    E. printstacktrace();
    }
    }

    参考文章

    [ 1 ]。类加载器的工作原理
    [ 2 ]。pathclassloader源码
    [ 3 ]。multidex源码

    作者:nuptboyzhb发表于2015 / 12 / 27 10:41:47原文链接
    阅读:204评论:0查看评论
    ]]>
    iptables防火墙原理详解 http://prog3.com/sbdm/blog/alonesword/article/details/50411579 http://prog3.com/sbdm/blog/alonesword/article/details/50411579 alonesword 2015 / 12 / 27 10:41:55 原文地址:http://seanlook.com/2014/02/23/iptables-understand/

    1。与iptables防火墙

    Netfilter is proposed by Russell Linux Rusty 2.4 core firewall framework, the framework is simple and flexible, can achieve security policy applications in many functions, such as packet filtering, packet processing, address mask, transparent agent, dynamic network address translation (Address Translation Network, NAT), as well as user and media access control (Access Control Media, MAC) address filtering and state based filtering, packet rate restrictions, etc.. Iptables/Netfilter of these rules can be a flexible combination, forming a very many functions, covering all aspects, which is due to its excellent design ideas.

    Netfilter is a data packet processing module in the core layer of the Linux operating system. It has the following functions:

    • Network address translation (Address Translate Network)
    • Packet content modification
    • Firewall, packet filtering, firewall

    Netfilter platform developed a packet of five hardpoints (hook point, we can understand callback function, packet arrived at these locations will be initiative we call the function, enable us to have the opportunity to in the data packet routing change their direction and content), the five hardpoints arePRE_ROUTING,INPUT,OUTPUT,FORWARD,POST_ROUTING.

    Netfilter set the rules are stored in the kernel memory, and iptables is an application layer application, it is released through the Netfilter interface to the storage in the kernel memory XXtables (Netfilter configuration table) to modify. This XXtables consists of a tableTablesChainChainsRulesRulesComposition, iptables is responsible for modifying the rule file in the application layer. Similar applications and firewalld.

    Iptables-netfilter

    1.1 filter, NAT, mangle and other rules table

    Filter table

    Mainly used for the data packet filtering, according to the specific rules determine whether the release of the data packets (such as ACCEPT, REJECT, DROP, LOG). The kernel module corresponding to the filter table is iptable_filter, which contains three rule chains:

    • INPUTChain: INPUT is a local package for those destinations.
    • FORWARDChain: FORWARD filter is not locally generated and the destination is not local (that is, the machine is only responsible for forwarding) the package
    • OUTPUTChain: OUTPUT is used to filter all locally generated packets

    Table nat

    Mainly used to modify the IP address and port number of the data packet (network address translation, such as SNAT, DNAT, MASQUERADE, REDIRECT). Belongs to a stream of packets (because of the package.
    The size limit of the data may be divided into multiple data packets will only go through this table once. If the first package is allowed to do NAT or Masqueraded, the remaining packets are automatically done the same, that is to say, the rest of the package will not pass the table again. Table corresponds to the kernel module for the iptable_nat, including the three chain:

    • PREROUTINGChain: the function is to change the packet's destination address when it reaches the firewall.
    • OUTPUTChain: change the destination address of the locally generated package.
    • POSTROUTINGChain: before the package is to leave the firewall to change its source address

    Mangle table

    TOS (Of Service Type, service type), (To TTL), (), (Time Live), and data packet set up Mark tag, to achieve Qos (Of Service Quality, quality of service) adjustment and policy routing applications, due to the need for the corresponding routing device support, so the application is not extensive. Contains five rule chain - PREROUTING, POSTROUTING, INPUT, OUTPUT, FORWARD.

    Table raw

    1.2.9 is a new version of the iptables after the addition of the table, mainly used to determine whether the data packet is processed by the state tracking mechanism. When matching data packets, the rules of the raw table should be preferred to other tables. Includes two rule chain - OUTPUT, PREROUTING

    Data packets in iptables and 4 different states of the 4 tracked connections:

    • NEW: the package wants to start a connection (reconnect or redirect the connection).
    • RELATEDThe package is a new connection established for an already established connection. For example: FTP data transmission connection is connected to control the connection RELATED out of the connection.--icmp-type 0(Ping response) is--icmp-type 8(Ping request) out of the RELATED.
    • ESTABLISHED: as long as the sending and receiving a response, a data connection from NEW to ESTABLISHED, and the state will continue to match the connection of the subsequent data packets.
    • INVALID: packets can not be identified belong to which connection or no state, such as memory overflow, ICMP do not know which connection is not connected to the error message, the general should be DROP this state of any data.

    1.2 INPUT, FORWARD and other rules chain and rules

    When processing all kinds of data packets, according to the different time of the firewall rule, iptables is used to involve 5 kinds of default rule chain, from the point of view of applying time point to understand these chains:

    • INPUTChain: when receiving a data packet (inbound) at the local address of the firewall, apply the rules in this chain.
    • OUTPUTChain: when the firewall of the machine to send data packets out (outbound), the application of the rules in the chain.
    • FORWARDChain: apply the rules in this chain when receiving data packets that need to be sent to other addresses through a firewall.
    • PREROUTINGChain: before the data packets are routed, the rules in this chain, such as DNAT.
    • POSTROUTINGChain: after the data packets for routing, the application of the rules in this chain, such as SNAT.
    One
    Two
    Three
    Four
    Five
    Six
    Seven
    Eight
    Nine
    Ten
    -->PREROUTING-->[ROUTE]-->FORWARD-->POSTROUTING-->
    MangleMangle ^ mangle ^.
    NatFilter nat
    | |
    | |
    V|
    OUTPUT INPUT
    Mangle ^ mangle ^.
    Filter nat
    ------>local-------> VFilter

    Among them, INPUT, OUTPUT chain more applications in the "host firewall", that is, the main server for the security control of the machine out of the data; and FORWARD, PREROUTING, POSTROUTING chain more applications in the "network firewall", especially the use of the firewall server as a gateway.

    Method of firewall processing data packets (rules):

    • ACCEPTAllows data packets to pass
    • DROP: discard packets directly, do not give any response information
    • REJECT: to reject a packet of data, it is necessary to send the data to the end of a response message.

    • SNATSource address translation. Before entering the routing level of route, re rewrite the source address, destination address unchanged, and in the machine to establish NAT table entry, when the data returns, according to the NAT table will be the destination address data for data sent out when the source address, and sent to the host. To solve the Internet with a public address user problem.
      MASQUERADE, is a special form of SNAT, applicable to such a temporary ADSL will change as IP

    • DNATTarget address translation. In contrast to IP, SNAT package after route, the local network stack before the RE modification of the target address, source address unchanged, in the machine to establish NAT table entry, when the data returned, according to the NAT table will be the source address for data sent over the target address, and distributed to the remote host. Can hide the real address of the backend server.
      REDIRECT: is a special form of DNAT, the network will be forwarded to the local host (no matter what the IP header specified destination address is), to facilitate the machine to do port forwarding.

    • LOGRecord the log information in the /var/log/messages file, and then pass the packet to the next rule

    Except for the last oneLOG, the first 3 rules matching data packets, the packet will not continue to match, so the rules of the preparation of the key.

    2 Linux packet routing principle

    We already know the architecture and the role of Netfilter and Iptables, and learn the structure of the Xtables table that controls the behavior of Netfilter, then how does this Xtables table play a role in the packet routing of the kernel protocol stack?

    Network data packets received by the underlying NIC NIC, by unpacking of data link layer (removal data link header), entered the TCP / IP protocol stack (essentially a process network packets in the kernel driver) and Netfilter mixed data packet processing flow in the. Data packets receiving, processing, forwarding process constitute a finite state vector machine, after some of the kernel processing functions, as well as Hook Netfilter points, the last is forwarded, or the application of this layer to digest. It's time to look at this picture:
    Iptables-routing

    From the above, we can sum up the following rules:

    • When a packet enters the network card, the data packet first into the PREROUTING chain, in the PREROUTING chain we have the opportunity to modify the data packet DestIP (IP), and then the kernel of the "routing module" according to the "data packet IP" and "kernel routing table" to determine whether the need to transfer out (note that this time the data packet DestIP may have been modified by us)
    • If the packet is to enter the machine (that is, the packet's destination IP is the machine's network port IP), the data packet will move down the map, reaching the INPUT chain. After the packet arrives at the INPUT chain, any process will receive it.
    • The machine running the program can also send data packets, the packets through the OUTPUT chain, and then arrive at the POSTROTING chain output (note, this time the data packet SrcIP may have been modified by us)
    • If the packet is to be forwarded out (that is, the destination IP address is no longer in the current sub network), and the kernel allows forwarding, the packet will move to the right, through the FORWARD chain, and then arrive at the POSTROUTING chain output (select the corresponding subnet of the network to send out)

    When we write the Iptables rules, we should always keep in mind this route sequence diagram, according to the different Hook points, flexible configuration rules.

    3 iptables writing rules

    Command format:
    Iptables-cli

    • [-t table name]: which table operation of the rules, you can use NAT, filter, etc., if not specified, the default is filter
    • -A: add a new rule to the last line of the list of the rules
    • -I: insert a rule, the original position of the rules will be moved backwards, no specified number is 1
    • -D: remove a rule from the chain, either enter the complete rule, or specify the rule number to be deleted.
    • -RReplacement of a rule, the rule change will not change the order, and must specify the number.
    • -PThe default action of a rule chain
    • -nL:-L,-n, view the list of firewall rules that are currently running
    • Chain name: specify which chain of the table, such as INPUT, OUPUT, FORWARD, PREROUTING, etc.
    • Rule numberInsert, delete, replace the rules with,--line-numbersDisplay number
    • [-i|o network card name]I is the specified data package from which to enter the network card, O is the specified data package from which the card output
    • [-p protocol type]: you can specify the rules of application of the agreement, including TCP, UDP and ICMP, etc.
    • [-s source IP address]Source host IP address or subnet address
    • [--sport source port number]Source port number of the IP package.
    • [-d target IP address]Target host's IP address or subnet address
    • [--dport target port number]The target port number of the IP packet.
    • -mMatches extend, this option is used to provide more matching parameters, such as:
      • State state - ESTABLISHED -m, RELATED
      • TCP dport - -m 22
      • Multiport dports - -m 808080
      • ICMP icmp-type - -m 8
    • <-j action >: the action of processing the data package, including ACCEPT, DROP, REJECT, etc.

    Specific examples, please refer toCommon examples of iptables for reference.

    Reference resources


    Author: AloneSword published in 10:41:55 2015/12/27Text link
    Read: 24 comments: 0View comments
    ]]>
    Linux platform firewall iptables principle (turn) Http://prog3.com/sbdm/blog/alonesword/article/details/50411559 Http://prog3.com/sbdm/blog/alonesword/article/details/50411559 AloneSword 10:36:05 2015/12/27 Original address: http://www.cnblogs.com/ggjucheng/archive/2012/08/19/2646466.html

    Iptables profile

    Netfilter/iptables (referred to as iptables) consisting of Linux platform of the packet filter firewall, and most of the Linux software, the packet filter firewall is free, it can replace the expensive commercial firewall solution, complete packet filtering, packet redirection and network address translation (NAT) and other functions.

    Iptables basis


    Rule (rules) is in fact the network administrator predefined conditions, the rule is generally defined as if the data Baotou in line with the conditions, so to deal with the data package". Rules are stored in the kernel space information packet filter table, these rules specify the source address, destination address, transport protocol (such as TCP, UDP, ICMP) and service types (such as HTTP, FTP, and SMTP). When a packet is matched to a rule, iptables processes the data packets, such as release (accept), reject (reject), and discard (drop), as defined by the rules. The main task of configuring a firewall is to add, modify, and delete these rules.

    Relationship between iptables and netfilter:

    This is the first place to say, the relationship between Iptables and Netfilter is a very easy to make people do not clear the problem. A lot of know iptables but don't know netfilter. In fact, Linux is just the iptables firewall management tools, located in /sbin/iptables. The real function of the firewall is Netfilter, which is the inner structure of the packet filter in the Linux kernel.

    Process of iptables data packet transmission

    When a packet enters the network card, it first enters the PREROUTING chain, the kernel according to the packet IP to determine whether the need to transfer out.
    If the packet is to enter the machine, it will move down the chart, reaching the INPUT chain. Packets to the INPUT chain, any process will receive it. The program running on the machine can send data packets, the packets will go through the OUTPUT chain, and then arrive at the POSTROUTING chain output.
    If the packet is to be forwarded, and the kernel allows forwarding, the data packets will be shown to the right as shown in the figure, after the FORWARD chain, and then arrive at POSTROUTING chain output.




    Iptables rule table and chain:

    Table (tables) to provide specific functions, iptables built-in 4 tables, that is, filter table, NAT table, mangle table and raw table, respectively, for packet filtering, network address translation, packet reconstruction (modified) and data tracking.

       Chain (chains) is the path of packet transmission, each chain is actually a number of rules in the list of checks, each chain can have one or several rules. When a packet arrives at a chain, iptables begins to check the first rule in the chain to see if the packet satisfies the conditions defined by the rule. If satisfied, the system will be processed according to the method defined by the rule; otherwise iptables will continue to check the next rule. If the data package does not conform to any of the rules in the chain, iptables will process the data packets according to the predefined default policy defined in the chain.

    Iptables uses the hierarchical structure of "table" and "chain". In REHL4 is the three table five chain. Now REHL5 has become the four table five chain, but more out of the table is not too much, so basically the same as before. Here are a list of these four tables and five chain. Attention must be aware of the relationships and roles of these tables and chains.



    Rule table:

    1.filter table - three chains: INPUT, FORWARD, OUTPUT
    Function: filter packet kernel module: iptables_filter.
    2.Nat table - three chains: PREROUTING, POSTROUTING, OUTPUT
    Function: used for network address translation (IP, port) kernel module: iptable_nat
    3.Mangle table - five chains: PREROUTING, POSTROUTING, INPUT, OUTPUT, FORWARD
    Function: modify the packet's service type, TTL, and can configure the route to achieve the QOS kernel module: iptable_mangle (do not look at this table so much trouble, we set up a policy will almost never use it)
    4.Raw table - two chains: OUTPUT, PREROUTING
    Role: to determine whether the data packet is processed by the state tracking mechanism kernel module: iptable_raw
    This is not the REHL4, but do not have to fear, with not much

    Rule chain:


    1.INPUT -- the strategy of using the data packet in this rule chain
    2.OUTPUT - the strategy of applying this rule chain to the outgoing packets
    3.FORWARD -- the strategy of applying this rule chain to forward data packets
    4.PREROUTING - apply the rules in this chain to the data packets before routing
    (remember! All data packets in time by the chain processing)
    5.POSTROUTING - Rules for the application of the chain after the data packets are routed
    (all data packets out when the first chain processing)


    Precedence between rule tables:

    Raw -- mangle -- filter -- nat
    The order of precedence among regular chains (in three cases):

    First case: inbound data flow

    From the outside of the firewall to the data packet, the first PREROUTING rule chain processing (whether to modify the data packet address, etc.), after the route selection (to determine where the data packets should be sent), if the target host is a data packet firewall native (such as Internet users access the web server firewall host data packets), then the kernel will be transmitted to the INPUT chain processing (decide whether to allow), through the subsequent delivery system to the upper level applications (such as Apache server) response.

    Second impulse: forwarding data flow

    From the outside of the packet to reach the firewall, the first PREROUTING rule chain processing, after the route selection, if the destination address is other external addresses (such as local area network users to access the QQ site data packets), then the kernel will be transmitted to the FORWARD chain processing (whether to forward or intercept), and then to the POSTROUTING rule chain (whether to modify the address of the packet, etc.).

    Third kinds of situation: the station data flow
    The firewall machine to the external address to send the data packet (such as in the host firewall test public DNS server), the first to be output chain rule processing, routing, and then passed to the postrouting chain rules (whether to amend the packet address, etc.) are.

    Manage and set iptables rules

     



    Article reference

    Iptables http://netfilter.org/ official website
    Iptables http://www.linux.gov.cn/netweb/iptables.htm configuration manual
    Http://man.chinaunix.net/
    Iptables http://man.chinaunix.net/network/iptables-tutorial-cn-1.1.19.html configuration manual
    Http://prog3.com/sbdm/blog/thmono/archive/2010/04/08/5462043.aspx
    Http://netsecurity.51cto.com/art/200512/14457.htm
    Http://blog.sina.com.cn/s/blog_40ba724c0100jz12.html
    Http://qiliuping.blog.163.com/blog/static/1023829320105245337799/

    Author: AloneSword published in 10:36:05 2015/12/27Text link
    Read: 170 comments: 0View comments
    ]]>
    C++ standard 14 cancel decltype calculation function return type Http://prog3.com/sbdm/blog/csfreebird/article/details/50411524 Http://prog3.com/sbdm/blog/csfreebird/article/details/50411524 Sheismylife 10:25:46 2015/12/27

    One C++11 does not support the auto keyword before

    The following auto keyword is not supported in c++11

    Add auto (a int, B int) {
    I int = a + b;
    I return;
    }
    
    Main int (argc char, int * * argv) {
    {try
    Std:: cout "add (1,2)" std:: endl;
    } catch (std:: const &e exception) {
    Std:: cerr "E.what ()" std:: endl;
    }
    }
    

    Compiler clang++ 3.6 will be as follows:

    Warning:'auto'type specifier../src/main.cc:13:1: is a C++11 extension [-Wc++11-extensions]
    Add auto (a int, B int) {
    ^
    Error:'auto'not allowed../src/main.cc:13:1: in function return type
    Add auto (a int, B int) {
    ^~~~
    

    Two C++11 supports auto keyword

    Two point one But cannot automatically infer the function return type

    Or example of the above code, the compiler plus -std=c++11

    Error:'auto'../src/main.cc:13:1: return without trailing return type deduced return types are a C++14 extension
    Add auto (a int, B int) {
    ^
    1 generated. error
    

    Here clang++ error, said auto did not follow the instructions to keep up with the return type, or the use of c++14 standard return types. deduced

    Two point two Use decltype to declare a return type >

    First look at the recommended practice C++11, in the back of the function with the strange syntax

    Auto add (int a, int b) - decltype (a + b) {
    

    Compile and pass.

    Three C++14 let things go back to simple

    - > decltype (a + b) the grammar people feel unlike C + +. But standard 14 as quick to follow up the standard 11, and the things pull back. - > decltype into short-lived transition scheme. Now completely abandon the No. After compiler option to add -std=c++14. The following code is through the

    Add auto (a int, B int) {
    I int = a + b;
    I return;
    }
    

    Four Which c++ version should we use

    Since the c++14 standard has been published, and the main compiler has been supported, so now is not the time to talk about c++11, but should directly use the c++14 standard. Here is the clang compiler to support the c++ standardFile At the same time, here is my example project: git@gitlab.com:newlisp/cppwizard.git, using my own builder c++ to compile the newlisp code only need to modify the debug_config.lsp file compiler option.

    ('compile-options -g "-std=c++14 set")
    

    Update c++ 17 or 1z is still in the development of the standard process, the current is not recommended.

    Dean Author:

    2015-12-27 10:23 Created:

    Validate

    Author: sheismylife published in 10:25:46 2015/12/27Text link
    Read: 197 comments: 0View comments
    ]]>
    Sexy Beach Chinese PR patch + tutorial 深圳prog3.com http:/ / / / /博客/文章/详细信息/ 50411505罗庄 深圳prog3.com http:/ / / / /博客/文章/详细信息/ 50411505罗庄 罗庄区 2015年:10/12/24 26 27 【遊戲廠商/ company】:幻想

    【發售日期/销售date】:2015年9月11


    它的〓补丁说明:
    ※本补丁为pr》汉化补丁illusion出品的《sexy海滩
    ※本补丁以自解压档发布,只包含本体汉化,使用前请备份好原文件
    ※本补丁禁止用于商业用途,因商业目的而造成的问题,本组一概不负任何责任
    ※本补丁由zodgame论坛原创制作,任何个人或组织转载时必须注明出处,并保留原贴的所有内容不得删改,否则本组保留一切追究权利
    它的〓安装须知:
    • 汉化补丁适用于1.02或以上的版本,基于1.11版进行测试
    • i社的更新补丁会调整部分文件位置,游戏中偶尔出现未汉化图标是正常现象
    • 汉化补丁未附带独立字体,游戏中出现字体粗细不均是正常现象
    • 理论上和外挂补丁,去码补丁,工作室汉化与之后的官方新补丁兼容,但建议卸载本体外挂补丁再安装
    它的〓安装方法:
    ○运行汉化补丁,设置安装路径为sbpr文件夹
    ○运行原始exe进入游戏
    汉化名单-它-它的
    感谢zodgame汉化组成员
    原文:kzczyx神乐_,看那,sedia420316,zilou,孤独的小莲,鸟文,贫乏神,牛奶,今昔何惜
    校对:翼无忧,鸟文
    美术:焚木,Linx,辩心
    技术支持:罗庄
    美监:BSL
    程序:八酷,罗庄,kilk
    测试:kilk,cq8k7234


    欢迎访问zodgame游戏论坛

    www.zodgame.us https://
    它的预览图——
    下载地址-它-它的


    巨型:http:///# mega.nz!3mpirrbq!pzjfqz7ivfdgwtamhul7lnwi3tw7ou2xiw0t1ri)

    让大家等了这么久,这次就不收酱油了,圣诞快乐!

    旧汉化补丁升级方法:


    以前汉化怎么升官方呢?


    以前以及本人发布的v2版本HF法
    1.用伊露官方升级补丁升级。
    2.删除plugin文件夹
    3.删除xxpatch.exe或者不要用这个exe启动
    4.安装官方汉化


    HF v0.8以后的汉化升官方:
    1.删除plugin文件夹
    2.安装官方汉化


    官方汉化基于hf 1.0版本,无需patch.exe。


    教程:
    大家好,我是大师♂罗庄,汉化补丁陆续出品,现在估计大家应该玩上游戏了吧?
    随着补丁的推出,论坛也多了很多新手问题,比如按esc退出、体力值怎么加,妹子怎么推




    本人决定继续小风头的重任,出品新手教程,教程并不按顺序写作,按常见问题分类来写游戏本身十分开放建议新手从头到尾看一遍很容易就入手了,,,。




    本教程文件格式为pdf,win8 win10自带pdf查看工具




    浏览pdf不需要密码,修改才需要密码.至于密码我都是随机生成的256位字符,我也不知道.
    pdf阅读器已经测试过:
    win8 win10自带
    PDF Xchange查看器
    都是无需密码直接阅读。
    下载:
    http://depositfiles.com /文件/ oi2lgx1kr

    作者:罗庄发表于2015/12/24 26 27::10原文链接
    阅读:32评论:0查看评论
    ]]>
    我对消息中间件的理解 深圳prog3.com http:/ / / / / /博客/文章/ 50411500 luckyzhoustar细节 深圳prog3.com http:/ / / / / /博客/文章/ 50411500 luckyzhoustar细节 zhouchaoqiang 2015年:07 11/12/27:41  

     什么是message队列?

    提到消息中间件,那么首先就必须理解一下所谓的message队列。


    在平常的开发中,应用开发人员完全可以通过发送和接受消息的方式来方便的与应用程序进行可靠的通信,并且消息的处理为我们提供了方便的消息传递和许多业务处理的可靠的防止故障的方法。


    但消息传递与传统的应用程序交互又有区别?最明显的区别就是实时性了.message queue不适合实时性要求比较高的场景,因为message queue通过异步的方式与server端进行交互,不用担心server端的长时间处理过程。


    For example, most of the application between the call is through the form of a burst of the interface between the call and the call, once the business complex, the management of the interface between the interface will be very troublesome. At this time, if the Queue Message method, as long as the need to send the message to the Manage Queue can be, this time Queue Message has become a bridge between the grafted system.


    Also mentioned above the real-time nature of the problem, such as a report generation function, in order to give the user a better experience, we can not allow users to wait for a long time, then you can handle the report of the use of MQ, the client only need to request the necessary statements and some necessary statements to the Queue processing, after processing, and then send a message to the user.


     The following also briefly introduces a few professional terminology?

    Message: a unit of data transmitted between two computers, such as a string, text, etc.


    Message queue: a container that holds a message in the message passing process and acts as a bridge between the source and the target. The purpose of the queue is to provide a route to ensure the delivery of the message.


    Message queuing network: refers to a group of computers that can send messages to each other. Different computers in the network play different roles in the process of message processing, some are the sender, and some are the recipients.


     Message oriented middleware?

    The message queue has a certain understanding, then the message oriented middleware using efficient and reliable message delivery mechanism for platform independent data exchange, and based on data communication to carry out the integration of distributed systems. By providing a message passing and message queuing model, we can extend the communication between processes in a distributed environment.

    So for the message oriented middleware, the role of the common generally have Producer (producer), Consumer (consumer), Broker (transfer role), there are so many major roles, then the message oriented middleware for us to bring those features?


     Priority 1.Message

    Producer sends messages to Broker to store, so we can sort the messages in the message queue to achieve different priorities. So as to meet the needs of our complex business.


     Order 2.Message

    Message ordering, and some of the processing of the message is to be processed in a certain order, such as the user's creation order, order payment, order fulfillment. So for consumers also need to follow this process to consume, otherwise there is no sense.


     Filter 3.Message


    In the message, you can also filter our message, such as in accordance with the message type and other conditions to filter


     Persistence 4.Message


    Message persistence, generally in the following ways

    (1) persistent to the database, such as MySQL

    (2) persistent ha to KV storage, such as redis

    (3) document form persistence

    Persistent messages, prevent the system hang up, can still be recovered from the previous backup.


     Buffer 5.Broker full of how to do?


    We know that Broker is used to store the messages that need to be processed. If the message is too much, what happens to the Buffer?

    At this time it will take a certain strategy to discard the existing news.


     6 transaction support


    As the operation of the order mentioned above, the message oriented middleware also provides support for distributed transactions.


     7 timing message


    In practical applications, sometimes it will also need the function of timing consumption, so the middleware, the message will be sorted, and then realize the timing of the business needs to send or consumer news.


     8 message retry

    Consider this problem, if the news consumer fails, how to do, is waiting to deal with the news? Or to allow consumers to spend a second? Usually, take the form of the latter, because in most cases, the reason for the failure of consumption lies in the message itself, if the consumer in this message, then there will be a failure, so usually take this message to send the message in this way.


     9 retrospective consumption

    What is back consumption? For the consumer has been the success of the news, is not in the Broker to discard the message? It is obvious that it is not possible, so the need for middleware support for this feature, support for the information has been consumed within the time period of storage, waiting for a moment the message will be re consumption may.







    Author: ZHOUCHAOQIANG published in 11:07:41 2015/12/27Text link
    Read: 160 comments: 0View comments
    ]]>
    The Oracle database tuning record 20151226 nested views Http://prog3.com/sbdm/blog/dreamcode/article/details/50411467 Http://prog3.com/sbdm/blog/dreamcode/article/details/50411467 Dreamcode 10:07:08 2015/12/27 1, query statement analysis

    Formatted on 2015/12/26 15:09:55 (QP5 / v5.163.1008.3004).
      SELECTSheetid,
    B*****,
    B*****,
    B*****,
    B*****,
    B*****,
    B*****,
    B*****
        FROMView_b2bsaleckex
       WHERESheetid ='151***************' 
    ORDER BYB*****
    

    (1) the reason for the slow query: the use of nested views, in which the view VIEW_B2BSALECK in the function fgetb2blsckdh (sheetid), resulting in sheetid index failure;
    (2) modify the recommendation: rewrite the SQL statement, no longer using the nested view and the function, or in the function to add function index, because the index may cause the system to run slowly, so it is recommended to add in the evening.
    (3) amended as follows:
    1) no longer use nested view statements to modify the following:

      SELECTSheetid,
    B*****,
    B*****,
    B*****,
    B*****,
    B*****,
    B*****,
    B*****
        FROMBoutdetail
       WHEREFGETB2BLSCKDH (sheetid) ='151***************' 
    ORDER BYB*****
    

    2) create function index

    Formatted on 2015/12/26 16:01:55 (QP5 / v5.163.1008.3004).
    CREATEIdx_boutdetail_fgetb2blsckdh INDEX
       ONBoutdetail (fgetb2blsckdh (sheetid));
    

    2, modify the process records

    (1) update the FGETB2BLSCKDH function, add the deterministic parameter

    CREATE OR REPLACED******.FGETB2BLSCKDH function (in_lsdhInVARCHAR2)
    VARCHAR2 deterministic returnIs
    VARCHAR2 l_lsckdh (Twenty);
    Begin
      Begin
    
    * * *
    
      End;
    L_lsckdh return;
    EndFGETB2BLSCKDH;
    /
    

    (2) create function index

    Formatted on 2015/12/26 16:01:55 (QP5 / v5.163.1008.3004).
    CREATEIdx_boutdetail_fgetb2blsckdh INDEX
       ONBoutdetail (fgetb2blsckdh (sheetid));
    
    Author: Dreamcode published in 10:07:08 2015/12/27Text link
    Read: 62 comments: 0View comments
    ]]>
    Deque 5.3.3 object Http://prog3.com/sbdm/blog/caimouse/article/details/50411422 Http://prog3.com/sbdm/blog/caimouse/article/details/50411422 Caimouse 9:50:10 2015/12/27 Collections.deque class ([iterable[, maxlen]])

    Returns a new bidirectional queue, which is added to the queue from left to right when there is an input iterator. If you do not have an input parameter, create an empty queue.

    DequeIs a data structure with stack and queue characteristics. It supports thread safety, memory optimization, and both ends of the pop-up, insert elements, both from the direction of the pop element isO(OneTime cost. In the built-in data typeListAlso supports related operations, but it is designed to operate on a fixed element, if an element is inserted and the memory operation time spent isO (n). If parametersMaxlenNot specified, or specified asNone, its length is arbitrary, if there is a specified length, you can not add the element more than the specified length. If the queue has reached the specified length, adding an element from one end, it will pop up an element from the other end, thus keeping the element unchanged. So it is very suitable for tracking the last active objects.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (1)

    Print (DQ)

    The results are as follows:

    Deque ([1], maxlen=5)

     

    DequeThe following methods are supported:

    Append (x)

    additional elementXTo the right of the queue.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (1)

    Dq.append (2)

    Dq.append (3)

    Print (DQ)

    The results are as follows:

    Deque ([1, 2, 3], maxlen=5)

     

    Appendleft (x)

    additional elementXTo the left of the queue.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.appendleft (1)

    Dq.appendleft (2)

    Dq.appendleft (3)

    Print (DQ)

    The results are as follows:

    Deque ([3, 2, 1], maxlen=5)

     

    Clear ()

    Clear all elements in the queue.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.appendleft (1)

    Dq.appendleft (2)

    Dq.appendleft (3)

    Print (DQ)

    Dq.clear ()

    Print (DQ)

    The results are as follows:

    Deque ([3, 2, 1], maxlen=5)

    Deque ([], maxlen=5)

     

    Count (x)

    To calculate whether the number of queue elements is equal to the number ofXIf more than or equal toTrue, otherwise returnFalse.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (1)

    Dq.append (2)

    Dq.append (3)

    Print (DQ)

    Print (dq.count (1))

    Print (dq.count (2))

    Print (dq.count (3))

    Print (dq.count (6))

    The results are as follows:

    Deque ([1, 2, 3], maxlen=5)

    One

    One

    One

    Zero

     

    Extend (Iterable)

    From the right side of the extended queue, the argument is an iterator object.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (1)

    Dq.append (2)

    Dq.append (3)

    Print (DQ)

    Dq.extend ([7, 8, 9])

    Print (DQ)

    The results are as follows:

    Deque ([1, 2, 3], maxlen=5)

    Deque ([2, 3, 7, 8, 9], maxlen=5)

     

    Extendleft (Iterable)

    Add an element from the left to the left. Note that the addition of the order is exactly the opposite of the sequence of iterations.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (1)

    Dq.append (2)

    Dq.append (3)

    Print (DQ)

    Dq.extendleft ([7, 8, 9])

    Print (DQ)

    The results are as follows:

    Deque ([1, 2, 3], maxlen=5)

    Deque ([9, 8, 7, 1, 2], maxlen=5)

     

    (POP)

    Remove an element from the right and return the element to the. If the queue is empty, throw an exception.IndexError.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (1)

    Dq.append (2)

    Dq.append (3)

    Print (DQ)

    Dq.pop ()

    Print (DQ)

    The output results are as follows:

    Deque ([1, 2, 3], maxlen=5)

    Deque ([1, 2], maxlen=5)

     

    Popleft ()

    Remove an element from the left, and return this element to the. If it is an empty queue, an exception is thrown.IndexError.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (1)

    Dq.append (2)

    Dq.append (3)

    Print (DQ)

    Dq.popleft ()

    Print (DQ)

    The results are as follows:

    Deque ([1, 2, 3], maxlen=5)

    Deque ([2, 3], maxlen=5)

     

    Remove (value)

    Delete the specified valueValueThe elements, if not found, will throw an exceptionIndexError.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (9)

    Dq.append (2)

    Dq.append (3)

    Dq.append (8)

    Print (DQ)

    Dq.remove (9)

    Print (DQ)

    The results are as follows:

    Deque ([9, 2, 3, 8], maxlen=5)

    Deque ([2, 3, 8], maxlen=5)

     

    Reverse ()

    Reverse order all elements, returnNone.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (9)

    Dq.append (2)

    Dq.append (3)

    Dq.append (8)

    Print (DQ)

    Dq.reverse ()

    Print (DQ)

    The results are as follows:

    Deque ([9, 2, 3, 8], maxlen=5)

    Deque ([8, 3, 2, 9], maxlen=5)

     

    Rotate (n)

    whenNIs positive, then pops the element from the right, and inserts it to the left,NIs representative of the operation several times. whenNIs a negative value, just the opposite, that is, from the left side of the pop-up element, insert to the right. Roughly equal toD.appendlef (d.pop ()).

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (9)

    Dq.append (2)

    Dq.append (3)

    Dq.append (8)

    Print (DQ)

    Dq.rotate (2)

    Print (DQ)

    Dq.rotate (-2)

    Print (DQ)

    The results are as follows:

    Deque ([9, 2, 3, 8], maxlen=5)

    Deque ([3, 8, 9, 2], maxlen=5)

    Deque ([9, 2, 3, 8], maxlen=5)

     

    DequeClass provides a read - only property:

    Maxlen

    Returns the maximum length allowed, if not set backNone.

    Example

    #python 3.4

    Collections import

     

    DQ = collections.deque (maxlen = 5)

    Dq.append (9)

    Dq.append (2)

    Dq.append (3)

    Dq.append (8)

    Print (dq.maxlen)

    The results are as follows:

    Five

     

    DequeClass support iteration, selection,Len (d),Reversed (d),Copy.copy (d),Copy.deepcopy (d)And other operations, but also supportInOperator to use indexD[-1]Operation.



    Cai Junsheng QQ:9073204 Shenzhen

    Author: caimouse published in 9:50:10 2015/12/27Text link
    Read: 219 comments: 0View comments
    ]]>
    Can cure all sentient beings? But the Buddha to save sentient beings! Http://prog3.com/sbdm/blog/opengl_es/article/details/50411309 Http://prog3.com/sbdm/blog/opengl_es/article/details/50411309 Sleks 8:57:16 2015/12/27

    Can cure all sentient beings? But the Buddha to save sentient beings!

    The sun Vulcan (the beauty of lifeHttp://prog3.com/sbdm/blog/opengl_es)

    This paper follows"Signed - non-commercial use - keep in line"Creation of public agreement

    Please keep this sentence:The sun Vulcan beautiful life - focus on this blogAgile development and mobile and physical equipment research: iOS, Android, Html5, Arduino, pcDuino,Otherwise, the article from the blog to reprint or reprint, thank you for cooperation.



    Please don't comment, thank you.

    ----------------------------

    Occupy a position, hope in the lifetime, can at least this piece of writing.

    Cancer, it's terrible!

    However, it is not terrible, as long as you find it.


    Maybe I found it, but I don't know if it will be enough.

    That is the mentality.

    To maintain a good attitude, Confucianism, taoism... Around the great circle, only Buddhism was directly, empty and color, think and do not want to, although can not change the reality, and can change it in your heart as the heart and Zhizheng to you influential doesn't actually exist, but the formation of this heart.


    There are about our generation to see nine zero after the "no" mentality, I want to correct for this generation of people, they are right, only they can adapt to the mentality of this era.

    And we are born under the red flag of the generation, excessive responsibility, not only can not solve the problem, will produce a ring of tangled, and they do not know.

    Put down, put down the tangle, and do your best.


    Again, I have been holding the learning attitude of Buddhism, Buddhist superstition has been that many.

    Today, correct again, in fact, Buddhist like recite ancient poetry as, only infiltrating into every detail of you to change your mindset, which may is the relationship between the quantitative change and qualitative change, can also be used to "read a hundred times the meaning from now" to explain it.


    Three years ago, I learn the table tennis, physical exercise on the verge of collapse, and I began learning Buddhism, only Heart Sutra and Vajrayana by, then feel Dharma is very good, but I missed an opportunity, is to make it my chance infiltration, only invasion, in order to achieve change.

    Nearly three years, and a lot of Buddhist communication, they to understand my Buddha agreed, however understanding speak only to listen to others, indeed, no infiltration of their own, why Du himself, even have their own du not, why Du others!

    Something is actually to do, the formation of unconscious, playing table tennis, too, I use three years time to study the various movements and gestures, but the game never connected to the ball, nearly a month, I put down the play ball with the head, is to practice, practice consciousness, then the game, beat a sweep, the ball past the, JiaoHaoSheng constantly. Yes, the difference between human and animal, that is, people have thinking, and thinking, such as software, ability, but the speed is much slower than the much more, or back to the hardware to do it, practice into consciousness, the consciousness is hardware, some emergency situations, you can do things, so you are surprised, because it is not subject to your mind control, is under the control of consciousness.


    People have been digging the brain, has been in the exercise of thinking, in fact, under the consciousness is the most exercise, and the subconscious is a part of the subconscious, is an instinctive action, the so-called instinct is to practice the formation of habits. The subconscious mind can do things, more complex, including the thinking way, that is, to the problem, such as met a thing, you are instinctively from one side of the sun to interpret, or from the dark side to interpret, this fact is not thinking things, thinking only responsible for to think, and in what direction to is subconscious things, this with the consciousness is also different, which can be called thinking consciousness, more vividly and thinking consciousness is a piece of electric version, you plug in the electric version, after the power supply, your thinking is in what way to think about the problem.


    However, the heart is involved in the wisdom of the part, this seems to have a conclusion, but how many will have an impact, especially blood, this has not been considered.


    When it comes to here, that is to say, people's thinking is a double-edged sword, is not easy to use, let their own blood stagnation, what disease to the. When you need to use again, and then, put up, this is the role of thinking.

    People more is subliminally, in control of doing things, and when the swap direction, this is the thinking of things. They both influence each other and change.


    Buddhist, must be "superstition", namely the ubiquitous influence their own good. However, it is not a negative factor that can affect your normal life, study and work.

    Now, this time, I'm so to say, because fear will be abetting others, you think about it, everyone with a mobile phone, cell phone fans of wild, it might as well be Buddha fan, at least the Buddha teaches people to perform good deeds, Buddha teach a person easily.


    The Buddha said, people to cross the river and find a boat to cross to the other side, don't ship the how to deal with to worry about, let it continue to go their own way.

    The Buddha said that Buddha must be so, not to mention other things, the Buddha is warned people who believed in Buddhism to at times, in the heart is good, not endless, like playing with a mobile phone as, "sleepless nights". That's not good.

    The Buddha said, put down his site, no matter what time, as long as no longer tangled, put it down, immediately become a buddha.

    World there are innumerable Buddhas, as long as can do put down two words, and Buddha is because first did, was known as the Buddha, the Buddha said.

    The Buddha said, newborn babies are Buddha, and "Tathagata" name is a newborn baby has reached the realm of.


    The power of Dharma, Buddha's compassion, goodness!




    Author: sleks published in 8:57:16 2015/12/27Text link
    Read: 223 comments: 0View comments
    ]]>
    To my CSDN blog and background music - Gao Dashang's "Heart Sutra" background music Http://prog3.com/sbdm/blog/opengl_es/article/details/50411295 Http://prog3.com/sbdm/blog/opengl_es/article/details/50411295 Sleks 7:37:52 2015/12/27

    To my CSDN blog and background music - Gao Dashang's "Heart Sutra" background music

    The sun Vulcan (the beauty of lifeHttp://prog3.com/sbdm/blog/opengl_es)

    This paper follows"Signed - non-commercial use - keep in line"Creation of public agreement

    Please keep this sentence:The sun Vulcan beautiful life - focus on this blogAgile development and mobile and physical equipment research: iOS, Android, Html5, Arduino, pcDuino,Otherwise, the article from the blog to reprint or reprint, thank you for cooperation.


    I do not know the other blog, anyway, tall and still CSDN can do, as follows:

    Source code is as follows:

    <audio src="http://你的.mp3" controls="controls" autoplay="autoplay" loop="loop">
    Your browser does not support the HTML5 audio tag.
    </audio>


    The usage and meaning of each attribute of the specific component.HereScreenshot below:





    The following reproduced fromHere, you need a friend, you can change the reward.


    Read the chant chant "Diamond Sutra" MP3 album series "MP3 audio formatDownload address
    Download the method: the mouse moved to the set number of the download address above, and then click on the right click "use the thunder download" or choose "target save as"):

    ===========================================
    "Diamond Sutra" Ren Dan mage led chanting
    ===========================================
    "Diamond Sutra chanting Buddha Mountain
    ===========================================
    "Diamond Sutra" monks chanting Muyu
    ===========================================
    "Diamond Sutra" Huilvfashi chant
    ===========================================
    "Diamond Sutra chanting Temple Edition
    ===========================================
    "Diamond Sutra chanting Manjusri Hall
    ===========================================
    "Diamond Sutra" Hui Ping mages chant
    ===========================================
    "Diamond Sutra" bhiksuni Muyu version
    ===========================================
    "Diamond Sutra" chant. "Diamond Sutra chant under
    ===========================================
    "Diamond Sutra" Yan Cantonese chant master wheel
    ===========================================
    "Diamond Sutra" Shida could master chanting
    ===========================================
    "Diamond Sutra" Ke Zhu chant month wind
    ===========================================
    "King Kong Jing" Huang Huiyin music accompaniment singing
    ===========================================

    Related download:
    Economic group master "King Kong Jing"  "Diamond Sutra chanting Buddha Mountain
    Dream old monk "King Kong Jing" 2007  "Diamond Sutra" Huilvfashi chant
    "Diamond Sutra" to read and recite Buddhist records  The mage "enterprise Diamond Sutra"
    Grand Master Kong  The concept of master "King Kong by interpretation"
    The grand master "Diamond Sutra Dayi"  The heart of the master "practical" of the King Kong
    Wonderful Chinese master "diamond heart is how to practice"  Can master of "Diamond Sutra chanting
    Economic group master "Diamond Sutra" meaning (audio)  Wonderful Chinese master "to realize the King Kong Jing"
    Field interpretation of "Diamond Sutra" careless mage  Jingbo mage "Diamond Sutra"
    8000 Buddhist video software download


    Author: sleks published in 7:37:52 2015/12/27Text link
    Read: 286 comments: 0View comments
    ]]>
    A question for beginners to answer Http://prog3.com/sbdm/blog/sxhelijian/article/details/50411289 Http://prog3.com/sbdm/blog/sxhelijian/article/details/50411289 Sxhelijian 7:04:10 2015/12/27 This article from the reader to my blog comments. When active thinkers, the active thinking problem, the old he is very excited.
    Complete dialogue"C language and programming practice reference - n=a! +b! +c!"Comments on the two floor.
      
    [question]
    Teacher, I try to #&%...... %...... , but the program has become more, so that it will improve efficiency?
    [answer]
    I am glad that you can ask such questions, this kind of initiative thinking, the students in my class is really not much. This involves our multidimensional understanding of efficiency.
    In most cases, efficiency refers to the efficiency of the computer, to be divided into time efficiency (as little as possible) and space efficiency (less memory space in operation). While focusing on the time efficiency of the majority. Thus, the number of lines of the source code, and not the key to a high time efficiency, as long as the ultimate goal of the code, so that the computer implementation of the operation, the time point of view is naturally fast. And another dimension of efficiency, we also need to realize that it is the efficiency of people. Computer systems are integrated by computers and people, in fact, people's efficiency is more valuable, which is now in the case of increased labor costs, a number of companies are very important. For the problem is not too complicated, or low efficiency of the computer, but also to meet the needs of the case, as the developer of the "people", do not have to spend too much effort on the efficiency of the computer. The key link in a system, affect the system performance of the "bottleneck" part, it is worth to spend a lot of manpower, and clever head, to pursue the computer efficiency. This is a lot of junior level members can not understand the need to learn the algorithm (although a good beginner programmers, algorithm literacy is no time to play a role). Your solution, it is obvious that the efficiency of the computer is high, and the efficiency of the people is low. Even worse is that the algorithm is complicated, and the possibility of an error is even greater. Any engineering, following the "simple and beautiful" rule.
    Answer such a question, happy, say a few words.
    Of course, as learners, especially beginners, you this kind of "low efficiency", just from the perspective of learning is the highest efficiency, the value of the training of thinking is quite large. Continue with this kind of thinking and questioning!

    Author: sxhelijian published in 7:04:10 2015/12/27Text link
    Read: 301 comments: 0View comments
    ]]>
    2015: open down year Http://prog3.com/sbdm/blog/yuanmeng001/article/details/50411280 Http://prog3.com/sbdm/blog/yuanmeng001/article/details/50411280 Yuanmeng001 6:11:05 2015/12/27 2015: open down year
    Going past 2015, to tell the truth, 2015 is the year of open source. Why?
    In 2015, in the past each other, "top cow" (arch) opponent (rivals), for example, apple, Microsoft, open the fist products, under the banner of open source work together. But back to our country, still do not trust them, don't respect them and harbingers of homebred software "flagman", not afraid to let people laugh.
    First, apple (Apple) open source goes
    Biggest The story Apple of the year goes to which open sourced their programming language Swift. In the s PR team went so far as to first major computer company to Apple the make open source a key part of its strategy. This plainly The true. not open source community pushed back and Apple changed the wording. a major story as Swift is a is programming great and language open it sourcing it this allows was developers to use Still Apple process call freely. it.
    Two, Microsoft (Microsoft) open source goes
    The With leadership change and new market dynamics Microsoft started to embrace open source. In a surprising company open sourced some of technologies core its the including Visual and.NET Studio to get developer mindshare. Both projects are released under the MIT open source license. The company even developed a Linux-based operating system for move a Azure cloud. networking its on switch
    We should pay attention to is: "the company even developed a Linux based operating system for a networking switch on its azure cloud." has said that the use of Microsoft system unsafe, it is nonsense nonsense eyes closed!
    New year is approaching, I wish you all a happy new year!
    Yuan Meng December 27th

    Author: yuanmeng001 published in 6:11:05 2015/12/27Text link
    Read: 36 comments: 0View comments
    ]]>