Archive | 网络技术

Tags: , ,

使用JavaScript控制HTML元素的显示和隐藏

Posted on 10 2 月 2023 by simon

利用来JS控制页面控件显示和隐藏有四种方法,两种方法分别利用HTML的style中的两个属性,两种方法的不同之处在于控件隐藏后是否还在页面上占空位。

方法一:
document.getElementById(“EleId”).style.visibility=”hidden”;
document.getElementById(“EleId”).style.visibility=”visible”;
利用上述方法实现隐藏后,页面的位置还被控件占用,显示空白。

方法二:
document.getElementById(“EleId”).style.display=”none”;
document.getElementById(“EleId”).style.display=”inline”;
利用上述方法实现隐藏后,页面的位置不被占用。

方法三:设置元素的透明级别

document.getElementById(“EleId”).style.opacity = 0,  
设置后元素完全透明,还占位置

document.getElementById(“EleId”).style.opacity = 1,  
设置后元素完全不透明(显示)

方法四:
显示元素进行隐藏

document.getElementById(“ID名”).hidden=ture;
根据页面元素ID名获得页面元素值,进而将其属性设置成隐藏。

将隐藏元素进行显示
对于已经隐藏的页面元素如果要将其再次显示,不是将document.getElementById(“ID名”).hidden=false;
而是将其隐藏属性删除 
document.getElementById(“ID名”).removeAttribute(“hidden”);
 

示例:

 //控制显示与不显示

    if (srcjs.hysum == null || srcjs.hysum.length == 0) {

        document.getElementById(“hysumTable”).hidden = true;

    } else {

        document.getElementById(“hysumTable”).removeAttribute(“hidden”);

        for (var i = 0; i < srcjs.hysum.length; i++) {

            var hyvo = srcjs.hysum[i];

            hysumAddRow(“hysum”, hyvo);

        }

    }

Comments (1)

3proxy 使用教程(转)

Posted on 06 11 月 2018 by simon

转自:3proxy 使用指北 (by wsgzao)

Comments (1)

Tags: ,

RESTful API 最佳实践(转)

Posted on 10 10 月 2018 by simon

一、URL 设计

1.1 动词 + 宾语

RESTful 的核心思想就是,客户端发出的数据操作指令都是”动词 + 宾语”的结构。比如,GET /articles这个命令,GET是动词,/articles是宾语。

动词通常就是五种 HTTP 方法,对应 CRUD 操作。

  • GET:读取(Read)
  • POST:新建(Create)
  • PUT:更新(Update)
  • PATCH:更新(Update),通常是部分更新
  • DELETE:删除(Delete)

根据 HTTP 规范,动词一律大写。

Continue Reading

Comments (0)

Tags: , ,

linux系统禁ping及改ssh端口

Posted on 25 10 月 2017 by simon

#禁ping操作#

1、修改文件

echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all

即可

如果需要ping通则输入:

echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all

该命令重启后会失效,所以应该让其开机后自动运行

echo "echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all" >>/etc/rc.d/rc.local

2、也可以通过iptables来配置

①允许PING设置

iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
iptables -A OUTPUT -p icmp --icmp-type echo-reply -j ACCEPT

或者也可以临时停止防火墙操作的。

service iptables stop

②禁止PING设置

iptables -A INPUT -p icmp --icmp-type 8 -s 0/0 -j DROP

#修改ssh端口#

1、修改文件

vim /etc/ssh/sshd_config

找到#Port 22,将其修改为其他端口,不建议使用常用端口,80 21 443 3306等等。

2、然后后重启服务,

Centos6.x系统,

/etc/init.d/sshd restart

Centos7.x系统,

systemctl restart sshd.service

Comments (0)

密码保护:出场教程

Posted on 24 10 月 2017 by simon

此内容受密码保护。如需查阅,请在下方输入密码。

要查看留言请输入您的密码。

Tags: , ,

winhttp api和com对象版区别

Posted on 10 5 月 2017 by simon

到底该用哪个接口,微软这么说,api方式:功能齐全,不过调用复杂些;com接口,调用简单,属于一个封装,有部分功能缺失。https://msdn.microsoft.com/zh-cn/library/aa383158(v=vs.85).aspx

C/C++ API COM interface
Advantages
  • Responses can be processed in chunks, which is more efficient.
  • POST operations can also be processed in chunks, speeding processing time.
  • AutoProxy support.
  • Access to the full feature set of WinHTTP.
  • Binary data can easily be handled.
  • Creating an application is easy and requires fewer lines of code than the C/C++ API.
  • The interface can be used by scripting languages.
Disadvantages
  • Processing is more complex.
  • The C/C++ API requires more steps than the COM interface to perform the same actions.
  • Setting up a request takes more code.
  • The COM interface does not provide access to the full feature set of WinHTTP.
  • It is difficult to handle binary data types in some scripting languages, such as VBScript and JScript.
  • The COM interface does not support AutoProxy.
  • Applications must use the COM APARTMENT_THREADED model.
  • Before a response can begin being processed, the entire response must first be received and buffered.

Comments (0)

Tags:

密码保护:Mindjet MindManager2016 可用版

Posted on 06 3 月 2017 by simon

此内容受密码保护。如需查阅,请在下方输入密码。

密码保护:Mindjet MindManager2016 可用版已关闭评论

Tags: , ,

lnmp下mysql 5.6内存占用过高解决方法

Posted on 02 11 月 2015 by simon

最新的lnmp一键包1.2里,可以选择mysql5.6版本安装,但是最近发现mysql有时候会出现挂掉的情况,看一下mysql错误日志,应该是内存占满导致的,1G内存的vps是伤不起的。。

重启mysql服务后,top一下发现这一个mysql服务就占用了500多MB内存。。

Google一番,贴一下记录:

mysql5.6的默认配置是不适合小型站点的,win的话在my.ini里修改、linux则在/etc/my.cnf里修改performance_schema_max_table_instances参数,有就修改,没有就追加:

performance_schema_max_table_instances=400
table_definition_cache=400
table_open_cache=256

修改完毕后,重启mysql服务,service mysql restart,然后top后发现内存占用少了一半,应该还有很大优化空间,鉴于内存基本够用了,就不继续折腾了。

Comments (3)

Tags: , , , ,

excel中批量添加带图片批注的vba宏命令

Posted on 04 6 月 2015 by simon

应用场景:

1、在excel中,有很多型号的产品名称,需要鼠标悬浮到某产品型号上自动在excel中显示对应的图片,用来对比筛选

2、公司举行某活动,需要对用户反馈的图片进行人工甄选、审查等等,具体用途可以拓展。

使用方法:

为下面宏命令添加快捷键,可将其导出为加载宏,在excel中调用该加载宏,使用快捷键即可批量快速给目标单元格加上图片批注。

宏命令如下:


'***************************************************
'* 加载宏:excel图片批量添加批注功能
'* 功能描述:对本地文档里图片,自动进行对应至excel中单元格
'* 作 者:simon
'* 作者博客:sunweiwei.com
'* 日 期:2015-6-4
'* 版 本:V1.0.0
'***************************************************
'整行注释的为在读取图片尺寸时不需要的文件头信息
'BMP文件头
Private Type BitmapFileHeader
bfType As Integer '标识 0,1 两个字节为 42 4D 低位在前,即 19778
bfReserved2 As Integer
bfOffBits As Long
bfReserved1 As Integer
bfSize As Long
End Type
Private Type BitmapInfoHeader
biSize As Long
biWidth As Long '宽度 18,19,20,21 四个字节,低位在前
biHeight As Long '高度 22,23,24,25 四个字节,低位在前
' biPlanes As Integer
' biBitCount As Integer
' biCompression As Long
' biSizeImage As Long
' biXPelsPerMeter As Long
' biYPelsPerMeter As Long
' biClrUsed As Long
' biClrImportant As Long
End Type
'JPEG(这个好麻烦)
Private Type LSJPEGHeader
jSOI As Integer '图像开始标识 0,1 两个字节为 FF D8 低位在前,即 -9985
jAPP0 As Integer 'APP0块标识 2,3 两个字节为 FF E0
jAPP0Length(1) As Byte 'APP0块标识后的长度,两个字节,高位在前
' jJFIFName As Long 'JFIF标识 49(J) 48(F) 44(I) 52(F)
' jJFIFVer1 As Byte 'JFIF版本
' jJFIFVer2 As Byte 'JFIF版本
' jJFIFVer3 As Byte 'JFIF版本
' jJFIFUnit As Byte
' jJFIFX As Integer
' jJFIFY As Integer
' jJFIFsX As Byte
' jJFIFsY As Byte
End Type
Private Type LSJPEGChunk
jcType As Integer '标识(按顺序):APPn(0,1~15)为 FF E1~FF EF; DQT为 FF DB(-9217)
'SOFn(0~3)为 FF C0(-16129),FF C1(-15873),FF C2(-15617),FF C3(-15361)
'DHT为 FF C4(-15105); 图像数据开始为 FF DA
jcLength(1) As Byte '标识后的长度,两个字节,高位在前
'若标识为SOFn,则读取以下信息;否则按照长度跳过,读下一块
jBlock As Byte '数据采样块大小 08 or 0C or 10
jHeight(1) As Byte '高度两个字节,高位在前
jWidth(1) As Byte '宽度两个字节,高位在前
' jColorType As Byte '颜色类型 03,后跟9字节,然后是DHT
End Type
'PNG文件头
Private Type LSPNGHeader
pType As Long '标识 0,1,2,3 四个字节为 89 50(P) 4E(N) 47(G) 低位在前,即 1196314761
pType2 As Long '标识 4,5,6,7 四个字节为 0D 0A 1A 0A
pIHDRLength As Long 'IHDR块标识后的长度,疑似固定 00 0D,高位在前,即 13
pIHDRName As Long 'IHDR块标识 49(I) 48(H) 44(D) 52(R)
Pwidth(3) As Byte '宽度 16,17,18,19 四个字节,高位在前
Pheight(3) As Byte '高度 20,21,22,23 四个字节,高位在前
' pBitDepth As Byte
' pColorType As Byte
' pCompress As Byte
' pFilter As Byte
' pInterlace As Byte
End Type
'GIF文件头(这个好简单)
Private Type LSGIFHeader
gType1 As Long '标识 0,1,2,3 四个字节为 47(G) 49(I) 46(F) 38(8) 低位在前,即 944130375
gType2 As Integer '版本 4,5 两个字节为 7a单幅静止图像9a若干幅图像形成连续动画
gWidth As Integer '宽度 6,7 两个字节,低位在前
gHeight As Integer '高度 8,9 两个字节,低位在前
End Type
Public Function PictureSize(ByVal picPath As String, ByRef Width As Long, ByRef Height As Long) As String
Dim iFile As Integer
Dim jpg As LSJPEGHeader
Width = 0: Height = 0 '预输出:0 * 0
If picPath = "" Then PictureSize = "null": Exit Function '文件路径为空
If Dir(picPath) = "" Then PictureSize = "not exist": Exit Function '文件不存在
PictureSize = "error" '预定义:出错
iFile = FreeFile()
Open picPath For Binary Access Read As #iFile
Get #iFile, , jpg
If jpg.jSOI = -9985 Then
Dim jpg2 As LSJPEGChunk, pass As Long
pass = 5 + jpg.jAPP0Length(0) * 256 + jpg.jAPP0Length(1) '高位在前的计算方法
PictureSize = "JPEG error" 'JPEG分析出错
Do
Get #iFile, pass, jpg2
If jpg2.jcType = -16129 Or jpg2.jcType = -15873 Or jpg2.jcType = -15617 Or jpg2.jcType = -15361 Then
Width = jpg2.jWidth(0) * 256 + jpg2.jWidth(1)
Height = jpg2.jHeight(0) * 256 + jpg2.jHeight(1)
PictureSize = Width & "*" & Height
'PictureSize = "JPEG" 'JPEG分析成功
'Stop
Exit Do
End If
pass = pass + jpg2.jcLength(0) * 256 + jpg2.jcLength(1) + 2
Loop While jpg2.jcType <> -15105 'And pass < LOF(iFile)
ElseIf jpg.jSOI = 19778 Then
Dim bmp As BitmapInfoHeader
Get #iFile, 15, bmp
Width = bmp.biWidth
Height = bmp.biHeight
PictureSize = Width & "*" & Height
' PictureSize = "BMP" 'BMP分析成功
Else
Dim png As LSPNGHeader
Get #iFile, 1, png
If png.pType = 1196314761 Then
Width = png.Pwidth(0) * 16777216 + png.Pwidth(1) * 65536 + png.Pwidth(2) * 256 + png.Pwidth(3)
Height = png.Pheight(0) * 16777216 + png.Pheight(1) * 65536 + png.Pheight(2) * 256 + png.Pheight(3)
PictureSize = Width & "*" & Height
'PictureSize = "PNG" 'PNG分析成功
ElseIf png.pType = 944130375 Then
Dim gif As LSGIFHeader
Get #iFile, 1, gif
Width = gif.gWidth
Height = gif.gHeight
PictureSize = Width & "*" & Height
'PictureSize = "GIF" 'GIF分析成功
Else
PictureSize = "unknow" '文件类型未知
End If
End If
Close #iFile
End Function
'*************************
Sub 添加图片批注()
Dim 单元格
Dim w As Long, h As Long
Dim f As String '图片文件完成路径
Dim t As String
Dim Pwidth As Long, Pheight As Long
Dim Psize As String
On Error Resume Next
For Each 单元格 In Selection
单元格.AddComment
单元格.Comment.Shape.Fill.UserPicture ActiveWorkbook.Path & "\pic\" & Replace(单元格.Value, "[图片]", "") & ".jpg"
f = ActiveWorkbook.Path & "\pic\" & Replace(单元格.Value, "[图片]", "") & ".jpg" '图片文件完成路径
Psize = PictureSize(f, w, h) '运行宏,w,h就是对应图片的width height ,返回 width*height
If Len(Psize) > 0 Then
Pwidth = Val(Split(Psize, "*")(0)) '返回 图片 宽
Pheight = Val(Split(Psize, "*")(1)) '返回 图片 高
End If
单元格.Comment.Shape.Height = Pheight / 4
单元格.Comment.Shape.Width = Pwidth / 4
Next 单元格
End Sub

Comments (2)

Tags: ,

wininet,winhttp,xmlhttprequest,ServerXmlHttpRequest各版本区别

Posted on 22 5 月 2015 by simon

一、标准API接口WinINet(Microsoft Windows Internet)和WinHTTP(Microsoft Windows HTTP)

实现Http访问,微软提供了二套API:WinINet, WinHTTP(分别封装于system32目录下的wininet.dll和winhttp.dll内)
二者主要区别在于后者更为安全和稳定,可以说WinHTTP是WinINet的升级版
LZ所提的UDF WinHTTP.au3就是直接调用标准接口写成的自定义函数库文件

二、COM对象XMLHttpRequest和WinHttpRequest和ServerXMLHTTPRequest

XMLHttpRequest是基于WinInet封装的,
而WinHttpRequest和ServerXMLHTTPRequest则是基于WinHTTP封装的
所以三者的稳定性属XMLHttpRequest为最差
封装成COM形式主要是为了方便js vbs等脚本的调用,还具有易书写、降低开发难度等许多特点把

三、对象版本和封装位置

1、XMLHttpRequest对象版本和对应的封装dll文件
Microsoft.XMLHTTP 对应 msxml.dll
MSXML2.XMLHTTP 对应 msxml2.dll
MSXML2.XMLHTTP.3.0 对应 msxml3.dll
MSXML2.XMLHTTP.4.0 对应 msxml4.dll
MSXML2.XMLHTTP.5.0 对应 msxml5.dll(此版本是伴随office2007发布的,所以目录下可能找不到该版本的dll)
MSXML2.XMLHTTP.6.0 对应 msxml6.dll
如上各个dll的发布一般都是以补丁的形式发布,win7默认都集成了吧

2、ServerXMLHTTP对象版本和对应的封装dll文件
Msxml2.ServerXMLHTTP 对应 msxml2.dll(win7自带,下同!)
Msxml2.ServerXMLHTTP.3.0 对应 msxml3.dll
Msxml2.ServerXMLHTTP.4.0 对应 msxml4.dll
Msxml2.ServerXMLHTTP.5.0 对应 msxml5.dll
Msxml2.ServerXMLHTTP.6.0 对应 msxml6.dll

3、WinHttpRequest对象
WinHttp.WinHttpRequest.5.1 对应 Winhttp.dll

(如上高版本的通常稳定性会好一点)

四、对象成员(属性、方法、事件等),主要优缺点

XMLRequest成员参考
缺点:和浏览器挂钩,大多情况下会共享cookies,session,不支持单独设置代理
优点:和浏览器挂钩,大多情况下会共享cookies,session

ServerXMLHTTP成员参考
缺点:系统没有对应dll的情况下程序需要外挂一个dll文件
优点:脱离浏览器,使用代理方便

WinHttpRequest成员参考
缺点:暂无
优点:脱离浏览器,使用代理方便

Continue Reading

Comments (0)

斗牛SEO工具