分类 【操作系统】 下的文章

OS X 10.9.x Mavericks 去除登录窗口中的 其他… 用户

运行【终端】,输入以下命令并回车,输入管理员密码验证后,可去除其他用户选择。

    sudo defaults write /Library/Preferences/com.apple.loginwindow SHOWOTHERUSERS_MANAGED -bool FALSE

运行【终端】,输入以下命令并回车,输入管理员密码验证后,可添加其他用户选择。

    sudo defaults write /Library/Preferences/com.apple.loginwindow SHOWOTHERUSERS_MANAGED -bool TRUE

Python 2.7安装setuptools时的UnicodeDecodeError解决办法

操作系统:Windows 7 64位
Python:Python 2.7.6 64位
Setuptools:2.1
症状:

Traceback (most recent call last):
  File "c:\docume~1\admini~1\locals~1\temp\tmpbg7qjrpycharm-management\setuptools-1.1.5\setup.py", line 17, in <module>
    exec(init_file.read(), command_ns)
  File "<string>", line 8, in <module>
  File "c:\docume~1\admini~1\locals~1\temp\tmpbg7qjrpycharm-management\setuptools-1.1.5\setuptools\__init__.py", line 11, in <module>
    from setuptools.extension import Extension
  File "c:\docume~1\admini~1\locals~1\temp\tmpbg7qjrpycharm-management\setuptools-1.1.5\setuptools\extension.py", line 5, in <module>
    from setuptools.dist import _get_unpatched
  File "c:\docume~1\admini~1\locals~1\temp\tmpbg7qjrpycharm-management\setuptools-1.1.5\setuptools\dist.py", line 15, in <module>
    from setuptools.compat import numeric_types, basestring
  File "c:\docume~1\admini~1\locals~1\temp\tmpbg7qjrpycharm-management\setuptools-1.1.5\setuptools\compat.py", line 19, in <module>
    from SimpleHTTPServer import SimpleHTTPRequestHandler
  File "C:\Python27\lib\SimpleHTTPServer.py", line 27, in <module>
    class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  File "C:\Python27\lib\SimpleHTTPServer.py", line 208, in SimpleHTTPRequestHandler
    mimetypes.init() # try to read system mime.types
  File "C:\Python27\lib\mimetypes.py", line 358, in init
    db.read_windows_registry()
  File "C:\Python27\lib\mimetypes.py", line 258, in read_windows_registry
    for subkeyname in enum_types(hkcr):
  File "C:\Python27\lib\mimetypes.py", line 249, in enum_types
    ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd7 in position 9: ordinal not in range(128)

排查半天未果,GOOGLE之,发现是Python 2.7的Bug,确切的说是Python安装目录下的Lib/mimetypes.py下的BUG,解决方案见地址:http://bugs.python.org/review/9291/diff/1663/Lib/mimetypes.py

记得将源文件备份哦,还有记得将mimetypes.pyc清除
2014年1月22日补充:
哎,刚刚从pip的安装手册上发现这么一段:

Beginning with v1.5.1, pip does not require setuptools prior to running get-pip.py. Additionally, if setuptools (or distribute) is not already installed, get-pip.py will install setuptools for you.

蛋疼啊,不仔细读手册的结果。。。白折腾了。官方的手册地址:http://www.pip-installer.org/en/latest/installing.html

Mac OS X下显示dd命令进度

Linux一般会向USR1发送kill信号来即时的显示dd当前进度,Mac OS X下发了信号真的就把dd给kill掉了,可以先使用brew安装pv,之后使用以下的命令来实现进度条的显示:
(需要切换到root用户执行)

pv -cN source < xxx.iso | dd of=/dev/disk2 bs=4m

Outlook 2013始终添加密送-VBA版

需求是这样的,我有多台电脑,而且经常需要查看我自己发出去的邮件,外加最近重装系统比较频繁,所以我希望由我发出的邮件都能够自动的密送到一个邮箱中做备份。

Mac下的Outlook 2011能够很方便的设置始终密送给某一个地址,Windows版本的一直未找到如何设置(也许是我太笨了),Google之后找到以下解决方案:

1.在Outlook唤起的状态下,按Alt+F11键,呼出宏编辑器

2.依次点开左侧资源浏览器中的Project1 -> Microsoft Outlook 对象 -> ThisOutlookSession(双击)

3.在右侧的编辑区插入以下代码

    Option Explicit
     
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Dim oItem As MailItem
        Dim oRecipient As Recipient
        Set oItem = Item
     
        Set oRecipient = oItem.Recipients.Add("需要密送的邮件地址")
        oRecipient.Type = Outlook.olBCC
     
        
        oItem.Recipients.ResolveAll
        oItem.Save
        Set oRecipient = Nothing
        Set oItem = Nothing
    End Sub

4.保存并关闭宏编辑器

5.依次点击Outlook的文件 -> 选项 -> 信任中心 -> 信任中心设置 -> 宏设置 -> 勾选“启用所有宏(不推荐;可能运行危险代码)”

6.点击确认后退出

然后就是每次正常发送邮件,妈妈再也不用担心我忘记哪台电脑发送的邮件啦……