Blog entries with tag “Programming

PowerShell 6.1.0 (preview) messes verbs of directories, causing Previous Versions to open previous verions of a directory in PowerShell

Issue #6799 in PowerShell repository on GitHub raises the question why Previous Versions is opening previous versions of a directory in PowerShell, instead of File Explorer as expected. The reason is that PowerShell 6.1.0 (preview) installer creates a context menu to open the shell on any folder. However, it unfortunately names the verbs as open/runas, which is very dangerous since they are canonical and do not make much sense for a folder. Related is issue #7815, where shortcuts to a folder are opened in PowerShell.

用 Outlook 对象模型辅助学术日历管理

日历是一个很棒的时间管理工具,作为学生,一个常见的需求是把课程表导入日历。这就引出了好几个需要考虑的问题。我经过几个学期的摸索,实现了一个对自己完全够用的日历管理工具。

用 Outlook 对象模型辅助学术日历管理

Hosting a preview handler in WPF, correctly, part 2: interop

Continuing ‘Hosting a preview handler in WPF, part 1: UI and file associations’, we will do the major COM interop in this entry. Many people have failed to host the handler correctly because of careless implementation, so look carefully! Also, we will demonstrate some broken preview handlers, including ‘Adobe PDF Preview Handler for Vista’, ‘Microsoft Word previewer’ and ‘Microsoft PowerPoint previewer’.

如何在操统课 Bitcoin 大作业组间比赛歇菜

交叉信息研究院的本科生操作系统课程的大作业很奇特,并不是 4 个 NachOS 作业,而是两次 NachOS、两次分布式数据库。最后一次大作业是要写一个 Bitcoin 挖矿程序,而且还有组间比赛,各个小组的矿机和客户端会一起运行一段时间,最终获得最高手续费的矿机会获胜。

如何在操统课 Bitcoin 大作业组间比赛歇菜

Rethinking base ‘conversion’

Base conversion is the conversion between notations of number, and NOT the numbers themselves. I discuss a common mistake on methods of base conversion, and a common mistake in thinking about ‘base conversion’ in computer programs.

在 Windows 下用命令解压缩 ZIP 文件夹

姚栋想要知道如何在 Windows 中使用命令解压缩 ZIP 文件夹。他表示如果要用 .NET Framework 提供的 API,则需要 4.5,但环境要求 4.0;如果用 PowerShell Expand-Archive 命令,则需要 5.1,但环境只允许 2.0;想用 cmd,但不知道怎么做。然而应该时刻记住:Windows 自带的 GUI 实际上经常是 COM 的图形版,在 COM 中寻找几乎总是可以找到你想要的图形操作的命令版本。

C♯ 接口的一个小“坑”

正在转战 C++ 写密码学代码,然后突然想温习一下多重继承、虚拟继承,熟知公有虚拟继承是 C++ 实现“接口”语义的成语(idiom,惯用法);思想游荡到了 C♯ 的世界,CLR 也支持接口,而且 C♯ 还有一个为人称道的显式接口实现(有一半私有虚拟继承的感觉),但是这里面隐藏了一个小“坑”……

CRTP and non-type generic parameters in C♯

This entry explores an interesting case of CRTP (curiously recurring template pattern) in C♯ that allows us to use operators. The other topic is elegant implementation of generic parameters that are (semantically) values instead of types.

Windows PowerShell 的二进制管道

PowerShell 在众 shell 中最突出的特色就是面向对象;然而,世界上还有很多命名是专为字节流管道设计的(兼容性大坑)。PowerShell 对待字节流管道那是十分 nasty!我写的这个小工具可以在对象和字节流之间做完美的润滑。