小编EBG*_*een的帖子

按文件类型更改Vim缩进行为

有人可以用简单的语言向我解释根据文件类型更改Vim的缩进行为的最简单方法吗?例如,如果我打开一个Python文件,它应该缩进2个空格,但如果我打开一个Powershell脚本,它应该使用4个空格.

vim settings file indentation

364
推荐指数
10
解决办法
17万
查看次数

什么是最快的Python模板系统?

Jinja2和Mako显然都非常快.

这些比较如何(功能较少但可能对我正在做的事情足够好)string.Template?

python template-engine mako django-templates jinja2

52
推荐指数
2
解决办法
3万
查看次数

什么更好,ANTLR或JavaCC?

关注的是文档/可学习性,eclipse集成,工具,社区支持和性能(大致按此顺序).

antlr javacc

45
推荐指数
6
解决办法
2万
查看次数

PowerShell通用集合

我一直在推动PowerShell中的.NET框架,我遇到了一些我不理解的东西.这很好用:

$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$foo.Add("FOO", "BAR")
$foo

Key                                                         Value
---                                                         -----
FOO                                                         BAR
Run Code Online (Sandbox Code Playgroud)

然而,这不是:

$bar = New-Object "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
New-Object : Cannot find type [System.Collections.Generic.SortedDictionary`2[System.String,System.String]]: make sure t
he assembly containing this type is loaded.
At line:1 char:18
+ $bar = New-Object <<<< "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
Run Code Online (Sandbox Code Playgroud)

他们都在同一个集会,所以我错过了什么?

正如答案中指出的那样,这只是PowerShell v1的一个问题.

.net powershell powershell-1.0

36
推荐指数
2
解决办法
4万
查看次数

Google Reader API Unread Count

Google阅读器是否有API?如果是这样,我如何知道特定用户知道其用户名和密码的未读帖子数量?

api google-reader

26
推荐指数
3
解决办法
2万
查看次数

C#强制表格焦点

所以,在询问这个问题之前,我确实搜索了谷歌和SO.基本上我有一个DLL,它有一个编译成它的表单.表单将用于向屏幕显示信息.最终它将是异步的,并在dll中暴露了大量的自定义.现在我只想让它正确显示.我遇到的问题是我通过在Powershell会话中加载它来使用dll.因此,当我尝试显示表单并让它到达顶部并具有焦点时,显示在所有其他应用程序上没有问题,但我不能在我的生活中让它显示在Powershell窗口上.这是我目前用来尝试显示的代码.我确信,一旦我弄明白,大多数都不会被要求,这只是代表我通过谷歌找到的所有东西.

CLass Blah
{
        [DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
        public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);

        [DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        [DllImport("User32.dll", EntryPoint = "ShowWindowAsync")]
        private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
        private const int WS_SHOWNORMAL = 1;

    public void ShowMessage(string msg)
    {
            MessageForm msgFrm = new MessageForm();
            msgFrm.lblMessage.Text = "FOO";
            msgFrm.ShowDialog();
            msgFrm.BringToFront();
            msgFrm.TopMost = true;
            msgFrm.Activate();

            SystemParametersInfo((uint)0x2001, 0, 0, 0x0002 | 0x0001);
            ShowWindowAsync(msgFrm.Handle, WS_SHOWNORMAL);
            SetForegroundWindow(msgFrm.Handle);
            SystemParametersInfo((uint)0x2001, 200000, 200000, 0x0002 …
Run Code Online (Sandbox Code Playgroud)

c# winforms

22
推荐指数
2
解决办法
5万
查看次数

非Visual Studio F#IDE

有没有人知道用于F#开发的IDE不会让我卖掉300美元?我很乐意转到F#VS Express,如果他们发布了一个,但花钱开始使用新语言不在我的预算范围内.

ide f#

22
推荐指数
4
解决办法
9072
查看次数

等待超时的用户输入

我搜索过,但显然我的谷歌foo很弱.我需要的是一种在控制台中提示用户输入并在一段时间后请求超时并在没有输入的情况下继续执行脚本的方法.尽管我已经知道,Read-Host不提供这个功能.$ host.UI.PromptForChoice()也不是$ host.UI.RawUI.ReadKey().提前感谢任何指针.

编辑:非常感谢Lars Truijens找到答案.我已经采用了他指出的代码并将其封装到一个函数中.请注意,我实现它的方式意味着在用户点击密钥和脚本执行继续之间可能存在长达一秒的延迟.

function Pause-Host
{
    param(
            $Delay = 1
         )
    $counter = 0;
    While(!$host.UI.RawUI.KeyAvailable -and ($counter++ -lt $Delay))
    {
        [Threading.Thread]::Sleep(1000)
    }
}
Run Code Online (Sandbox Code Playgroud)

powershell

19
推荐指数
2
解决办法
2万
查看次数

编码标准和行长度

我见过的每个编码标准都对一行中的字符数有建议或绝对限制.在这个限制范围内有各种各样的工作方式,但我没有看到这方面的任何具体指导.

显然,如果可能的话,不要写过长的行.

但是,如果这不实用呢?如何处理长线?

这里有几个例子

if ($Stmt = $Mysqli->prepare("SELECT color, pattern, size,
                              manufacturer, mfgSku, storeLocation,
                              aisle, status
                              FROM tblItems WHERE ourSku = ?")) {
Run Code Online (Sandbox Code Playgroud)

要么

$flavors = array ('chocolate', 'strawberry', 'vanilla', 'cookie dough', 
                  'chocolate chip', 'mint chocolate chip', 'rocky road',
                  'peach', 'fudge brownie', 'coffee', 'mocha chip');
Run Code Online (Sandbox Code Playgroud)

要么

$Stmt->bind_result( $this->_firstName,
                    $this->_lastName,
                    $this->_BillToAddress->address1,
                    $this->_BillToAddress->address2,
                    $this->_BillToAddress->city,
                    $this->_BillToAddress->state,
                    $this->_BillToAddress->zip,
                    $this->_BillToAddress->country,
                    $this->_email,
                    $this->_status,
                    $this->_primaryPhone,
                    $this->_mobilePhone );
Run Code Online (Sandbox Code Playgroud)

在每个示例中,冗长代码的缩进是不同的.这样做有更好或更"标准"的方式吗?额外的行总是应该以相同的方式缩进.或者这样可以吗?

php coding-style

19
推荐指数
4
解决办法
1万
查看次数

有两种拉链压缩文件运行diff的安全方法吗?

似乎这不是一个确定性的事情,或者有没有办法可靠地做到这一点?

compression diff

19
推荐指数
4
解决办法
3万
查看次数