About neohope

一直在努力,还没想过要放弃...

Git01常用命令

Git基本没有主次仓库之分,十分适合团队开发;
Git的分支功能比SVN要强悍很多。

1.全局设置

#用户
git config --global user.name "your name" 
#邮箱
git config --global user.email "your email" 
#编辑器
git config --global core.editor "your editor path"

2.新建库
备份,并cd到项目目录

#初始化
git init
#添加文件
#忽略文件列表添加到文本文件.gitignore
git add .
#提交
git commit
#或快速提交
git commit -m "message"

3.提交更新

#添加文件
git add filename
#或添加所有文件
git add .
#提交
git commit -a

4.查看日志

#日志
git log
#详细日志
git log --stat --summary
#显示某一版本日志
git show vidhead
#显示某一版本前一个版本
git show vidhead^
#显示某一版本前4个版本
git show vidhead~4

5.版本恢复

#恢复某个文件
git reset vidhead filelist

6.克隆git库
cd到新的项目路径

git clone source-path

7.合并git库
cd到自己的项目路径

#将别人的库合并到自己的库
git pull source-path
#将自己的库合并到别人的库
git push target-path

8.建立赤裸仓库

git --bare init --shared

9.项目分支

#列出分支
git branch
#新建分支
git branch branchname
#切换分支
git checkout branchname
#合并分支
git merge branchname
#删除分支
git branch -d branchname
#强制删除分支
git branch -D branchname

Windows安装Bugzilla步骤

1.安装mysql
为Bugzilla新建一个Database,
新建用户bugs,为该用户分配Bugzilla的所需权限。

2.安装ActivePerl或StrawberryPerl
新手推荐ActivePerl,StrawberryPerl需要自己做一些配置

3.下载Bugzilla最新版,并解压
在cmd下,执行

    perl checksetup.pl

命令行会提示缺少的包,有可选的和必须的两种。

对于Strawberry你可以按提示安装所有包

    perl install-module.pl --all

也可以只安装必须的包。

对于ActivePerl,只需一条一条的执行安装即可。

   ppm install TimeDate
   ppm install DateTime
   ppm install DateTime-TimeZone
   ppm install Template-Toolkit
   ppm install Email-Send
   ppm install Email-MIME

4.再次运行

    perl checksetup.pl

在Bugzilla目录下会生成localconfig文件,
修改其中的数据库配置,

第三次运行

    perl checksetup.pl

会向你询问一些信息,并自动生成数据库中的表及初始数据

5.下载并安装Apache,修改conf/httpd.conf
将下面一行的注释去掉

    AddHandler cgi-script .cgi

并添加虚拟目录

    Alias /Bugzilla D:/BugZilla
    <Directory "D:/BugZilla"&#93;
        Options ExecCGI All
        AllowOverride All
        ScriptInterpreterSource Registry-Strict 
        Order allow,deny
        Allow from all
    </Directory>

在注册表中配置Perl路径

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.cgi\Shell\ExecCGI\Command]
@="D:\\Perl\\bin\\perl.exe -T"

6.重启Apache,查看http://localhost/Bugzilla
用户名为第5步中输入的邮箱地址

7.如果有问题,用Bugzilla下的脚本可以判断问题所在

    perl testserver.pl  http://127.0.0.1/Bugzilla

Python使用MySQL驱动

#!/usr/bin/python
# -*- coding: utf-8 -*-

import MySQLdb

db=MySQLdb.connect(host="127.0.0.1",port=3306,db="django",user="sa",passwd="sa")
cur=db.cursor()
cur.execute("select count(*) from djuser")
print("rowcount=",cur.rowcount)

rows=cur.fetchall()
for row in rows:
    print("%s" % (row[0]))

Python使用ODBC

#!/usr/bin/python
# -*- coding: utf-8 -*-

import ceODBC
con=ceODBC.connect('driver=MySQL ODBC 5.1 Driver;server=127.0.0.1;port=3306;database=django;uid=sa;pwd=sa;')
cur=ceODBC.Cursor(con)
cur.execute("SELECT count(*) FROM djuser")
rows=cur.fetchall()

for row in rows:
    print(row[0])

Python调用dll

1.Test.h

#ifndef TEST_INTADD_HEADER
#define TEST_INTADD_HEADER

extern "C" int WINAPIV IntAdd(int a,int b);

#endif

2.Test.cpp

#include <windows.h>
#include "Test.h"

BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpReserved)
{
  UNREFERENCED_PARAMETER(hinstDLL);
  UNREFERENCED_PARAMETER(lpReserved);

  switch(fdwReason) 
  { 
    case DLL_PROCESS_ATTACH:
      break;

    case DLL_THREAD_ATTACH:
      break;

    case DLL_THREAD_DETACH:
      break;

    case DLL_PROCESS_DETACH:
      break;
  }

  return TRUE;
}

extern "C" int WINAPIV IntAdd(int a,int b)
{
  return a+b;
}

3.Test.def

LIBRARY	"Test"

EXPORTS
	IntAdd

4.test_cdll.py

#test_cdll.py
#请用__cdecl调用约定而不是__stdcall

from ctypes import *

fileName="Test.dll"
Test=cdll.LoadLibrary(fileName)
print(Test.IntAdd(2,3))