开源软件许可协议 – GPL

GNU通用公共许可协议

(英语:GNU General Public License,简称 GNU GPL、GPL)是广泛使用的免费软件许可证,可以保证终端用户得自由运行,学习,共享和修改软件。许可证最初由GNU项目的自由软件基金会 (FSF)的理查德·斯托曼(Richard Matthew Stallman)撰写,并授予计算机程序的收件人自由软件定义的权利。 GPL是一个Copyleft许可证,这意味着派生作品只能以相同的许可条款分发。 这与许可免费软件许可证有所区别 ,其中BSD许可证和MIT许可证是广泛使用的示例。 GPL是第一个普遍使用的Copyleft许可证。
历史上,GPL许可证系列一直是免费和开源软件领域最受欢迎的软件许可之一。根据GPL许可的优异自由软件程序的例子有Linux内核和GNU编译器集合 (GCC)。 David A. Wheeler认为,GPL提供的Copyleft对于基于Linux的系统的成功至关重要,给予向内核贡献的程序员保证他们的工作将有益于整个世界并保持自由,而不至于被不提供回馈给社区的不肖软件公司所剥削。
2007年,发布了第三版许可证(GNU GPLv3),以解决在长期使用期间发现的第二版(GNU GPLv2)所发生的一些困扰。 为了使许可证保持最新状态,GPL许可证包含一个可选的“并延伸到未来版本”条款,允许用户在FSF更新的原始条款或新版本之间进行选择。 有些开发人员在软件授权使用时,选择省略它; 例如,Linux内核已经在GPLv2下获得许可,就不需包括“并延伸到未来版本”的声明。

GPL授予程序接受人以下权利,或称“自由”,或称“copyleft”:
* 以任何目的运行此程序的自由;
* 再复制的自由;
* 改进此程序,并公开发布改进的自由(前提是能得到源代码)。
相反地,随版权所有软件的最终用户许可证几乎从不授予用户任何权利(除了使用的权利),甚至可能限制一些法律允许的行为,比如逆向工程。
GPL与其他一些更“许可的”自由软件许可证(比如BSD许可证)相比,主要区别就在于GPL寻求确保上述自由能在复制软件及派生作品中得到保障。它通过一种由斯托曼发明的叫Copyleft的法律机制实现,即要求GPL程序的派生作品也要在GPL之下。相反,BSD式的许可证并不禁止演绎作品变成专有软件。
GPL是自由软件和开源软件的最流行许可证。到2004年4月,GPL已占Freshmeat上所列的自由软件的约75%,SourceForge的约68%。类似的,2001年一项关于Red Hat Linux 7.1的调查显示一般的代码都以GPL发布。著名的GPL自由软件包括EMACS,Linux核心(并非所有Linux发行版的核心都是开源的)和GCC。

Share

在Windows 环境中使用 Dig 工具

Dig 在Linux 里一般是在 bind-utils这个包里的。

作者Windows 环境用的模拟终端为 Babun https://github.com/babun/babun 是基于Cygwin的。可惜,没有提供dig的二进制包。可惜。

好,其实解决方法很简单,去网上直接下个dig.exe放到Windows path里就好了=)  

重点 ### 此方法适用于所有Windows 命令行

A)下载:

下载地址 [ftp://ftp.nominum.com/pub/isc/bind9/]

拉到最下面找最新版本的

下这个

A1) 准备:

解压后在目录里找到C++安装文件,双击安装

)

B) 安装DLL文件

把目录里lib*.dll拷贝到 C:\WINDOWS\System32\ 目录下

B1)安装dig.exe

把目录里的dig.exe 也拷贝到 C:\WINDOWS\System32\ 目录下

C)完成! 测试!

babun

powershell

Share

小谢同学写的linux 服务器调优脚本

modify_sysctl.py

# -*- coding: utf-8 -*-
'''
Created on 2015-1-21

@author: xie
'''
'''
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 30000
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_max_tw_buckets = 6000
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.ip_local_port_range = 9000 65535
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
'''
import re,commands
SYSCTL_CONFIG = '/etc/sysctl.conf'
class SetSysctl():
def __init__(self):
self._sysctls = []
self._sysctls.append('net.ipv4.tcp_rmem = 4096 87380 16777216')
self._sysctls.append('net.ipv4.tcp_wmem = 4096 65536 16777216')
self._sysctls.append('net.core.wmem_default = 8388608')
self._sysctls.append('net.core.rmem_default = 8388608')
self._sysctls.append('net.core.rmem_max = 16777216')
self._sysctls.append('net.core.wmem_max = 16777216')
self._sysctls.append('net.core.netdev_max_backlog = 30000')
self._sysctls.append('net.core.somaxconn = 65535')
self._sysctls.append('net.ipv4.tcp_max_syn_backlog = 262144')
self._sysctls.append('net.ipv4.tcp_max_tw_buckets = 6000')
self._sysctls.append('net.ipv4.tcp_tw_recycle = 1')
self._sysctls.append('net.ipv4.tcp_tw_reuse = 1')
self._sysctls.append('net.ipv4.tcp_fin_timeout = 30')
self._sysctls.append('net.ipv4.ip_local_port_range = 9000 65535')
self._sysctls.append('net.ipv4.tcp_syncookies = 1')
self._sysctls.append('net.ipv4.tcp_max_orphans = 262144')
self._sysctls.append('net.ipv4.tcp_synack_retries = 2')
self._sysctls.append('net.ipv4.tcp_syn_retries = 2')
self._sysctls.append('')
self._sysctls.append('kernel.core_pattern = /home/core/core.%p')
self._create_core()
self._read_sysctl()
self._write_sysctl()

def _read_sysctl(self):
network = open(SYSCTL_CONFIG, 'r')
self._lines = []
for line in network:
flag = False
for sysctl in self._sysctls:
regex_str = sysctl.split('=')[0]
ma = re.match(r'^'+regex_str+'.*?', line, re.IGNORECASE)
if ma:
flag = True
break;
if not flag:
self._lines.append(line)
network.close()

def _write_sysctl(self):
sysctls = open(SYSCTL_CONFIG, 'w')
self._lines.extend(self._sysctls)
sysctls.write('\n'.join(self._lines))
sysctls.close()
commands.getoutput('sysctl -p')

def _create_core(self):
commands.getoutput('mkdir /home/core')
commands.getoutput('chown -R mc-ops:mc-ops /home/core')

if __name__ == '__main__':
SetSysctl()

modify_ulimit.py

<br /># -*- coding: utf-8 -*-
#!/usr/bin/env python2.7
'''
Created on 2013-5-6

@author: xie
'''
import commands, re,os

LIMIT_CONF = '/etc/security/limits.conf'
SOFT_NOFILE = '* soft nofile 1048576\n'
HAND_NOFILE = '* hard nofile 1048576\n'
SOFT_NPROC = '* soft nproc 1048576\n'
HAND_NPROC = '* hard nproc 1048576\n'
PROFILE_CONF = '/etc/profile'
ULIMIT_NOFILE = 'ulimit -HSn 1048576\n'

NPROC_LIMIT_CONF = '/etc/security/limits.d/90-nproc.conf'

def modify_ulimit():
lines = []
ulimit = open(LIMIT_CONF, 'r')
for line in ulimit:
ma = re.match(r'.*?soft *?', line, re.IGNORECASE)
mx = re.match(r'.*?hard *?', line, re.IGNORECASE)
if ma or mx:
continue
lines.append(line)
ulimit.close()

lines.append(SOFT_NOFILE)
lines.append(HAND_NOFILE)
lines.append(SOFT_NPROC)
lines.append(HAND_NPROC)

ulimit = open(LIMIT_CONF, 'w')
ulimit.write(''.join(lines))
ulimit.close()

commands.getoutput('ulimit -HSn 1048576')
if not isCentos7():
modify_nproc_ulimit()
writeProfile()

def modify_nproc_ulimit():
lines = []
if os.path.exists(NPROC_LIMIT_CONF):
ulimit = open(NPROC_LIMIT_CONF, 'r')
for line in ulimit:
ma = re.match(r'.*?soft *?', line, re.IGNORECASE)
if ma:
continue
lines.append(line)
ulimit.close()

lines.append('* soft nproc 1048576\n')
lines.append('root soft nproc unlimited\n')

ulimit = open(NPROC_LIMIT_CONF, 'w')
ulimit.write(''.join(lines))
ulimit.close()

def writeProfile():
lines = []
flag = False
profile = open(PROFILE_CONF, 'r')
for line in profile:
ma = re.match(r'.*?ulimit -HSn 1048576.*', line, re.IGNORECASE)
if ma is not None:
flag = True
lines.append(line)
profile.close()
if flag == False:
lines.append(ULIMIT_NOFILE)
profile = open(PROFILE_CONF, 'w')
profile.write(''.join(lines))
profile.close()

def isCentos7():
mage = commands.getoutput('cat /etc/redhat-release').split('\n')
#CentOS Linux release 7.1.1503 (Core)
#CentOS release 6.6 (Final)
cP = re.compile(r'.*\s+(?P\d+).*', re.IGNORECASE)
for mess in mage:
ma = cP.match(mess)
if ma is not None:
ip = ma.group('release')
if ip == '7':
return True
return False
pass

if __name__ == '__main__':
modify_ulimit()

Share

How to configure client proxy server settings by using a registry file

SUMMARY

This article describes how to create a Windows registry file
to configure the proxy server settings on a client computer that is running
Microsoft Internet Explorer or Windows Internet Explorer.

MORE INFORMATION

You can automatically configure the proxy server settings on
a client computer by updating the client computer registry. To do this, create
a registry file that contains the registry settings you want to update, and
then distribute it to the client computer by using a batch file or logon
script.

Important This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:

322756 How to back up and restore the registry in Windows

To configure the proxy server settings on a client computer,
create the following .reg file to populate the registry with the proxy server
information:

Regedit4

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]
"MigrateProxy"=dword:00000001
"ProxyEnable"=dword:00000001
"ProxyHttp1.1"=dword:00000000
"ProxyServer"="http://ProxyServername:80"
"ProxyOverride"="<local>"

In this file, ProxyServername is the name of
your proxy server.

You can also use the Internet Explorer
Administration Kit (IEAK) to configure proxy server settings on client
computers. For additional information about IEAK, visit the following Microsoft
Web site:

http://technet.microsoft.com/en-us/ie/bb219520.aspx

        Properties

Article ID: 819961 – Last Review: 09/11/2011 07:27:00 – Revision: 2.0

    <span>Applies to</span>
    <p>
        Windows 7 Enterprise, Windows 7 Enterprise N, Windows 7 Home Basic, Windows 7 Home Premium, Windows 7 Home Premium N, Windows 7 Professional, Windows 7 Professional N, Windows 7 Starter, Windows 7 Starter N, Windows 7 Ultimate, Windows 7 Ultimate N, Windows Internet Explorer 8, Microsoft Internet Explorer 6.0, Windows Internet Explorer 7 for Windows XP, Windows Internet Explorer 7 for Windows Server 2003



    <span>Keywords: </span>
    <ul><li>
            kbisa2004yes kbinfo KB819961 
        </li></ul>


    <h5>Feedback</h5>



            <span>Was this information helpful?</span>

        </p>
Share

Node.js Application as a Windows Service (With registry fix) – Measuring programming progress by lines of code is like measuring aircraft building progress by weight.

npm install

In my case, command nssm install MyWebService… was unsuccessful, the problem was that app.js can’t find config.json file.

First you will need:

  1. Node.js application (project) which you want to run as a Windows Service
  2. Node.js
  3. NSSM

1 step: Set your Node.js application as Windows Service

Download nssm.exe and put file into you node.js project folder

Put nssm.exe file into you node.js project folder

Run Windows Command Processor (cmd.exe) as administrator and go to your node.js project folder

Your node.js project folder

Run command npm install

npm install

Run command node src\app.js and allow access through Windows firewall

Allow access through Windows firewall

Run these two commands
nssm.exe install MyWebService "C:\Program Files\nodejs\node.exe" "C:\Service\src\app.js"
net start MyWebService

net start MyWebService

Now we need to fix this error.

2 step: Edit registry

Open registry editor (regedit.exe) and go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\MyWebService\Parameters

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\MyWebService\Parameters

Now we need to change AppDirectory from C:\Program Files\nodejs to C:\Service

Change AppDirectory from C:\Program Files\nodejs to C:\Service

Restart computer and don’t forget to run Apache, MySQL or any other necessary servers for your project after restart.

Node.js Application as a Windows Service

Share

supervisord usage in Centos7.x (via: systemd)

  1. yum install python-setuptools python-pip
  2. pip install supervisor
  3. echo_supervisord_conf > /etc/supervisord.conf
  4. create init script in : /usr/lib/systemd/system/supervisord.service
    “`
    [Unit]
    Description=supervisord – Supervisor process control system for UNIX
    Documentation=http://supervisord.org
    After=network.target
    [Service]
    Type=forking
    ExecStart=/usr/bin/supervisord -c /etc/supervisord.conf
    ExecReload=/usr/bin/supervisorctl reload
    ExecStop=/usr/bin/supervisorctl shutdown
    User=root</li>
    </ol>

    [Install]
    WantedBy=multi-user.target

    <pre><code>“`

    Share

OSX创建 Dock Stack

打开终端

defaults write com.apple.dock persistent-others -array-add &#039;{ &quot;tile-data&quot; = { &quot;list-type&quot; = 1 ; }; &quot;tile-type&quot; = &quot;recents-tile&quot;; }&#039;

然后 killall Dock

Share

TrafficServer源码:the possible operations or msg types sent from remote client to TM

// trafficserver/mgmt/api/NetworkMessage.h
typedef enum
{
  FILE_READ,
  FILE_WRITE,
  RECORD_SET,
  RECORD_GET,
  PROXY_STATE_GET,
  PROXY_STATE_SET,
  RECONFIGURE,
  RESTART,
  BOUNCE,
  EVENT_RESOLVE,
  EVENT_GET_MLT,
  EVENT_ACTIVE,
  EVENT_REG_CALLBACK,
  EVENT_UNREG_CALLBACK,
  EVENT_NOTIFY,                 /* only msg sent from TM to client */
  SNAPSHOT_TAKE,
  SNAPSHOT_RESTORE,
  SNAPSHOT_REMOVE,
  SNAPSHOT_GET_MLT,
  DIAGS,
  STATS_RESET_NODE,
  STATS_RESET_CLUSTER,
  STORAGE_DEVICE_CMD_OFFLINE,
  RECORD_MATCH_GET,
  API_PING,
  SERVER_BACKTRACE,
  UNDEFINED_OP /* This must be last */
} OpType;

Share