有时,把旧项目转换成新版本项目时,旧版本项目里使用的 maxmin 宏无法在新版本中正常编译.

原因是: 新版本内有了新的函数 std::maxstd::min 函数来实现这一功能

这时可以尝试使用如下方案解决:

  1. 包含algorithm文件
#include <algorithm>
  1. 明确使用 std::max(a,b) 而非 max(a,b)
  2. 定义宏 NOMINMAX
#define NOMINMAX

在 Windows 里 DLL 卸载自身模块是无法通过字节调用 FreeLibrary 自己来实现的。

原因分析

在当前线程中调用 FreeLibrary 后,当前模块就会立即被释放掉,而当前线程还没有运行结束。所以程序就运行到了一块不可访问的内存里,产生异常从而导致程序崩溃。

解决方案

Windows 里面 提供了一条可以用来释放自身模块的函数 FreeLibraryAndExitThread 可以释放自身。

函数

VOID WINAPI FreeLibraryAndExitThread(_In_ HMODULE hLibModule, _In_ DWORD dwExitCode)

仅需一条命令

grep "Failed password for root" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | more

结果类似下面这样:

 4377 103.41.124.18
 4368 103.41.124.65
 3900 62.210.178.226
 2214 103.41.124.33
  409 62.210.142.105
  404 115.231.222.45
  152 122.225.97.91
   95 122.225.109.205
   81 109.195.69.233
   42 74.52.105.154
   21 87.106.184.62
   21 87.106.1.211
   21 82.165.154.23
   21 69.64.64.62
   21 67.226.156.239
   21 61.40.192.52
   21 60.213.190.98
   21 27.251.179.130
   21 222.77.190.33
   21 211.172.219.251
   21 210.249.105.10
   15 220.194.46.36
   12 203.184.128.106
    1 60.190.71.52
    1 193.104.41.58

这样我们就可以很清楚的了解有谁在尝试破解我们的密码了,之后做个相关安全策略就可以简单防治了

在升级win8.1之后,重新安装的Git虽然可以正常使用 但遇到https时会报“Unable to find remote helper for ‘https’”的错误

网络搜索了许久未果,于是自己研究

  1. 检查安装的文件 结果:所有文件均完整

  2. 检查文件的访问权限 结果:所有文件当前用户均可访问

  3. 为调用的git等exe文件授予管理员运行权限 结果:问题依旧存在

挣扎了半天,尝试重装解决。

在重装的时候选择了 管理员权限运行 结果意外的发现重装后,https可以正常使用了。

至此问题解决。

#!/usr/env python
"""
:license: MIT

Copyright (C) 2012 HustMoon

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from __future__ import with_statement

import zlib, sys

def b128encode(buf, escape=False):
    if not buf: return ''
    buf = bytearray(buf)
    res = bytearray((len(buf) * 8 + 6) / 7)
    p, s, i = 0, 1, 0
    for n in buf:
        res[i] = ((p << (8 - s) | (n >> s)) &amp; 0x7F) | 0x80; i += 1
        if s == 7:
            res[i] = n | 0x80; i += 1
            p, s = 0, 1
        else:
            p, s = n, (s + 1) % 8
    if s != 1:
        if s == 2 and p < 0x80:
            i -= 1
        else:
            p = (p << (8 - s)) &amp; 0x7F
        p = chr(p)
        if escape:
            p = p.encode('string-escape')
        res[i:] = p
    return str(res)

def dcode():
    code = r'''def code(__=code):
 (_______)=(globals)();del((_______)['code'])
 if(((_______).get('__doc__'))is((None))):
  (__)=(map)((ord),(__)[(339):]);(______)=[0]*(((((len)((__))+(1))*(7))/(8)));((___),(____),(_____))=((0),(0),(0))
  for((__))in((__)):
   if((__)<(128)):break
   if((____)==(0)):((___),(____))=((__),(1))
   else:
    (______)[(_____)]=((((___)<<(____))|(((__)&amp;(127))>>((7)-(____))))&amp;(255));(_____)+=(1);((___),(____))=((__),(((____)+(1))%(8)))
  if((__)<(128)):
   if((____)!=(0)):
    (__)=((((___)<<(____))|((__)>>((7)-(____))))&amp;(255))
   (______)[(_____):]=[((__))]
  elif((____)!=(0)):del((______)[(_____):])
  exec((''.join((map)((chr),(______))).decode('zlib')))in((_______))
  if(((_______).get('__doc__'))is((None))):(_______)['__doc__']=''
code()
'''
    return ''.join([c.encode('string-escape') if ord(c) < 128 else c
                    for c in zlib.compress(code, 9)])
dcode = dcode()

def encode(infile, outfile):
    with open(infile, 'rU') as fp:
        code = fp.read().rstrip('n') + 'n'
    code = b128encode(zlib.compress(code, 9), True)
    code = r'''# -*- coding: latin-1 -*-
code = '%s'
exec(code.decode('zlib'))
''' % (dcode + code)
    with open(outfile, 'wb') as fp:
        fp.write(code)

def decode(infile, outfile):
    with open(infile, 'rU') as fp:
        code = fp.read().rstrip('n') + 'n'
    code = code.replace("exec(code.decode('zlib'))", "exec(code.decode('zlib')"
        ".replace('exec','fp.write').replace('in((_______))',''))")
    with open(outfile, 'wb') as fp:
        eval(compile(code, 's', 'exec'), {'fp':fp})

def main():
    try:
        if sys.argv[1] == '-d':
            func = decode
            infile, outfile = sys.argv[2:4]
        else:
            func = encode
            infile, outfile = sys.argv[1:3]
    except ValueError:
        print >>sys.stderr, 'Usage: zipcode.py [-d] infile.py outfile.py'
        raise SystemExit(-1)
    func(infile, outfile)

if __name__ == '__main__':
    main()

不再需要导入atl.lib库了,直接包含以下头文件就可以了

#include <atlbase.h>
#include <atlcom.h>
#include <atlctl.h>

要使用 AtlAxAttachControl 等函数的话,则必须初始化ATL模块

CComModule _Module;
_pAtlModule = &_Module;

我们这里使用源码编译安装,直接按顺序执行下列命令就可以成功(我都是假设已经有root权限的情况下,所以执行之前请确认自己已有root权限):

yum install -y mercurial gcc-c++ gcc
mkdir /usr/local
cd /usr/local
hg clone -r release https://go.googlecode.com/hg/ go
cd /usr/local/go/src
chmox +x all.bash
./all.bash
mkdir /root/go
export GOROOT=/usr/local/go
export GOPATH=/root/go
export GOBIN=/usr/local/go/bin
export GOOS=linux
export PATH=.:$PATH:/usr/local/go/bin

现在应该已经可以执行go命令测试了:

[root@root]# go version
go version go1.3.3 linux/amd64

如果想要每次进入bash时都拥有go环境,则需要新建一个文件:/etc/profile.d/go.sh 并写入以下内容

export GOROOT=/usr/local/go
export GOPATH=/root/go
export GOBIN=/usr/local/go/bin
export GOOS=linux
export PATH=.:$PATH:/usr/local/go/bin

现在随时都可以执行go命令了。

:)