在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

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

letsencrypt.org 1st. step

https://letsencrypt.org/

屏幕快照 2016-01-20 14.37.41

这是一个由很多个互联网巨头攒起来的非营利性组织。

来瞥一眼有哪些巨头:

屏幕快照 2016-01-20 14.39.39

 

好了,简单来说就一句话:提供免费的秒生web 证书!!!!!!!!!(此处省略n个!)

 

我就拿来测试了。

假设我们要给 ssl.humen1.net 生成证书 。生成证书的server ip 为 11.11.11.11

  • 先将 ssl.humen1.net A 11.11.11.11
  • 在server上配置nginx

server {
 listen 80;
 listen 443 ssl;
 server_name ssl.humen1.net;

ssl_certificate /etc/letsencrypt/live/ssl.humen1.net/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/ssl.humen1.net/privkey.pem;

location / {
 root /data/letsencrypt;
 index index.html;
 }
}

  • 安装letsencrypt

$ git clone https://github.com/letsencrypt/letsencrypt
$ cd letsencrypt
$ ./letsencrypt-auto --help

  • ./letsencrypt-auto certonly –webroot -w /data/letsencrypt -d ssl.humen1.net

 

 

Share

package.json 里的依赖怎么写

Dependencies
可选字段,指示当前包所依赖的其他包。

{ “dependencies” :
{ “foo” : “1.0.0 – 2.9999.9999”
, “bar” : “>=1.0.2 <2.1.2”
, “baz” : “>1.0.2 <=2.3.4”
, “boo” : “2.0.1”
, “qux” : “<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0”
, “asd” : “http://asdf.com/asdf.tar.gz”
, “til” : “~1.2”
, “elf” : “~1.2.3”
, “two” : “2.x”
, “thr” : “3.3.x”
}
}
版本格式可以是下面任一种:

version 完全匹配

version 大于这个版本
=version大于或等于这个版本
=version1 <=version2.
range1 || range2 满足任意一个即可
git… Git地址
user/repo
devDependencies
可选字段。如果只需要下载使用某些模块,而不下载这些模块的测试和文档框架,放在这个下面比较不错。

peerDependencies
可选字段。兼容性依赖。如果你的包是插件,适合这种方式。

bundledDependencies
可选字段。发布包时同时打包的其他依赖。

optionalDependencies
可选字段。如果你想在某些依赖即使没有找到,或则安装失败的情况下,npm都继续执行。那么这些依赖适合放在这里。

Share

wndr4300 刷openwrt 科学上网

刷机 基础配置

参考文件入口
需要的刷机文件@百度网盘

shadowsocks-spec

chinadns-openwrt

luci-app-shadowsocks

luci-app-chinadns

初始安装软件

@win

&lt;br /&gt;C:\Users\seven\Documents\wdnr4300&gt;pscp.exe *.ipk root@192.168.1.1:/opt/
2015/07/23 14:38 27,161 ChinaDNS_1.3.1-1_ar71xx.ipk
2015/07/23 14:38 2,592 luci-app-chinadns_1.3.1-1_all.ipk
2015/07/23 14:38 3,131 luci-app-shadowsocks-spec_1.3.2-1_all.ipk
2015/07/23 14:38 117,469 shadowsocks-libev-spec_2.2.2-1_ar71xx.ipk

@4300

# opkg install ip ipset libopenssl resolveip iptables-mod-tproxy

# cd /opt
# opkg install ./*.ipk

问题:

C:\Users\seven\Documents\wdnr4300&gt;pscp.exe *.ipk root@192.168.1.1:/opt/
root@192.168.1.1&#039;s password:
ash: /usr/libexec/sftp-server: not found
Fatal: Received unexpected end-of-file from server

解决:

# opkg update
# opkg install openssh-sftp-server

修改4300 LAN IP 192.168.7.1

DNS

#vim /etc/config/sec_resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 114.114.114.114

无线和有线设置

忽略了,直接在web界面设置就好主要是设密码什么的

pdnsd搭建DNS服务器@centos 服务器

从 http://members.home.nl/p.a.rombouts/pdnsd/dl.html 下载pdnsd最新的rpm包

然后 yum localinstall pdnsd-x.x.x-par_sl6.x86_64.rpm

配置见:
https://cokebar.info/archives/720
http://leeraw.com/?p=3621

搭建shadowsocks服务@centos 服务器

  1. 先安装git
  2. 从github上拉源码 https://github.com/shadowsocks/shadowsocks-libev
  3. cd shadowsocks-libev
  4. ./configure
  5. make && make install
  6. 启动
    > nohup /usr/local/bin/ss-server -s SERVER_IP -p SERVER_PORT -k PASSWD -m aes-256-cfb &
    > 将上面的启动命令加到rc.local开机自启
  7. 配置

进阶

https://cokebar.info/archives/850

交换机截图

chinaDNS

shadowsocks

dhcp-dns

dncp-dns

Share

在shell 脚本里嵌入python

#!/bin/bash
function pytest() {
python - $@ <<EOT
import sys,datetime
print 'Current Time is %s' % datetime.datetime.now()
print sys.argv
EOT
}


RT=$(pytest $@)
echo my python script says: $RT

Share

snmp via python [IF-MIB]

依赖 pysnmp pysnmp-mibs

# -*- coding: utf-8 -*-
'''
Created on 14/11/20.
@author: seven
'''

from pysnmp.entity.rfc3413.oneliner import cmdgen

cmdGen = cmdgen.CommandGenerator()

errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
    cmdgen.CommunityData('community_str'),
    cmdgen.UdpTransportTarget(('211.xx.169.xx', 161)),
    cmdgen.MibVariable('IF-MIB', 'ifNumber'),
    cmdgen.MibVariable('IF-MIB', 'ifDescr'),
    cmdgen.MibVariable('IF-MIB', 'ifType'),
    cmdgen.MibVariable('IF-MIB', 'ifMtu'),
    cmdgen.MibVariable('IF-MIB', 'ifSpeed'),
    cmdgen.MibVariable('IF-MIB', 'ifPhysAddress'),

    lookupValues=True
)

if errorIndication:
    print(errorIndication)
else:
    if errorStatus:
        print('%s at %s' % (
            errorStatus.prettyPrint(),
            errorIndex and varBindTable[-1][int(errorIndex) - 1] or '?'
        )
        )
    else:
        for varBindTableRow in varBindTable:
            for name, val in varBindTableRow:
                print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
Share

Whoosh 开始

Whoosh is a fast, featureful full-text indexing and searching library implemented in pure Python.

whoosh 是一个纯python实现的快速,多功能的全文索引和搜索库。

Programmers can use it to easily add search functionality to their applications and websites.

程序员可以轻松的给应用和网站添加搜索功能。

Every part of how Whoosh works can be extended or replaced to meet your needs exactly.

whoosh的每个部分都可以扩展或者替换以迎合你的需求。

Some of Whoosh’s features include:

  • Pythonic API.
  • Pure-Python. No compilation or binary packages needed, no mysterious crashes.
  • Fielded indexing and search.
  • Fast indexing and retrieval — faster than any other pure-Python search solution I know of.
  • Pluggable scoring algorithm (including BM25F), text analysis, storage, posting format, etc.
  • Powerful query language.
  • Production-quality pure Python spell-checker (as far as I know, the only one).

whoosh的一些功能包括:

  • python化的API.
  • 纯Python. 不需要编译或者二进制包,没有神秘的崩溃.
  • 派出索引和搜索
  • 快速索引和取回 — 比我知道的任何一个纯python搜索方案都快
  • 可插拔的评分算法 (包括 BM25F), 文本分析, 存储, 发帖格式, 等.
  • 强大的查询语句.
  • 产品级的纯python拼写检查 (我所知的最快的,没有之一).

 

 

Share

Python timelib

可以通过pip安装这个库

 

我是为了要使用和php中的 strtotime函数才用到的,很实用

获取上周的时间戳


from timelib import strtotime
from datetime import date
if __name__=='__main__':
 print date.fromtimestamp(strtotime('-2 week Monday'))

Share