分类 Development 下的文章

https://docs.python.org/3/library/winreg.html#
https://stackoverflow.com/questions/15128225/python-script-to-read-and-write-a-path-to-registry

import winreg

REG_PATH = r"Control Panel\Mouse"

def set_reg(name, value):
    try:
        winreg.CreateKey(winreg.HKEY_CURRENT_USER, REG_PATH)
        registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, REG_PATH, 0, 
                                       winreg.KEY_WRITE)
        winreg.SetValueEx(registry_key, name, 0, winreg.REG_SZ, value)
        winreg.CloseKey(registry_key)
        return True
    except WindowsError:
        return False

def get_reg(name):
    try:
        registry_key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, REG_PATH, 0,
                                       winreg.KEY_READ)
        value, regtype = winreg.QueryValueEx(registry_key, name)
        winreg.CloseKey(registry_key)
        return value
    except WindowsError:
        return None

#Example MouseSensitivity
#Read value 
print (get_reg('MouseSensitivity'))

#Set Value 1/20 (will just write the value to reg, the changed mouse val requires a win re-log to apply*)
set_reg('MouseSensitivity', str(10))

#*For instant apply of SystemParameters like the mouse speed on-write, you can use win32gui/SPI
#http://docs.activestate.com/activepython/3.4/pywin32/win32gui__SystemParametersInfo_meth.html



最近在编程中遇到一个问题:字符串内定义了一个已知的变量名,需要得到变量的值。

例如:
已知 real 类型全局变量:TEST

定义一个字符串,并赋值:

DEF STRING[10] STR1
STR1="TEST"

想通过 STR1 来得到 TEST 变量的值。可以使用 EXECSTRING 来处理:

EXECSTRING("R0="<<STR1)

以上指令可以将 TEST 变量的值读入 R0


最近在学习 nginx 的反向代理,在处理请求和响应的时候,需要处理 header 头信息用到了很多 nignx 变量,但是在传递给代理服务器时,我不知道我设置的 proxy_set_header 等信息是否设置正确,以及其他用到的变量到底当前值是多少我也不知道。调试起来很费劲。

发现一个第三方 nginx 模块:echo,可以方便的输出信息,利用这一模块可以实现变量值读取到 html,调试方便了很多。

echo GitHub 主页:https://github.com/openresty/echo-nginx-module

阅读全文