走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-11-14 08:53:12

使用 ls -dm */ 生成以逗号分隔的目录列表。 -d 将仅返回目录,-m 将输出到以逗号分隔的列表。

然后,您可以将输出存储在变量中并将其作为参数传递:

#!/bin/bash
MY_DIRECTORY=/some/directory
FOLDERS=`ls -dm $MY_DIRECTORY/*/ | tr -d ' '`
phpdoc -d $FOLDERS

Use ls -dm */ to generate a comma-separated list of directories. -d will return directories only and -m will output to a comma-separated list.

You could then store the output in a variable and pass it along as an argument:

#!/bin/bash
MY_DIRECTORY=/some/directory
FOLDERS=`ls -dm $MY_DIRECTORY/*/ | tr -d ' '`
phpdoc -d $FOLDERS

获取所有目录(以逗号分隔)并将输出发送到其他脚本

走过海棠暮 2024-11-14 08:37:11

这个例程是我们游戏引擎中的一些实用程序代码。它可以运行可执行文件并可选择等待其退出。它将返回其退出代码:

function TSvUtils.FileExecute(ahWnd: Cardinal; const aFileName, aParams, aStartDir: string; aShowCmd: Integer; aWait: Boolean): Integer;
var
  Info: TShellExecuteInfo;
  ExitCode: DWORD;
begin

  Result := -1;
  FillChar(Info, SizeOf(Info), 0);
  Info.cbSize := SizeOf(TShellExecuteInfo);
  with Info do begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := ahWnd;
    lpFile := PChar(aFileName);
    lpParameters := PChar(aParams);
    lpDirectory := PChar(aStartDir);
    nShow := aShowCmd;
  end;

  if ShellExecuteEx(@Info) then
  begin
    if aWait then
    begin
      repeat
        Sleep(1);
        Application.ProcessMessages;
        GetExitCodeProcess(Info.hProcess, ExitCode);
      until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
      CloseHandle(Info.hProcess);
      Result := ExitCode;
    end;
  end
end;

以下是一些可以检查进程是否存在的代码。所以...当前应用程序调用更新程序并终止。更新程序可以检查旧应用程序是否已终止并执行操作(重命名、更新、删除等):

function TSvUtils.ProcessExists(const aExeFileName: string; aBringToForgound: Boolean=False): Boolean;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
begin

  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  Result := False;
  while Integer(ContinueLoop) <> 0 do
  begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
      UpperCase(aExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
      UpperCase(aExeFileName))) then
    begin
      if aBringToForgound then
        EnumWindows(@BringToForgroundEnumProcess, FProcessEntry32.th32ProcessID);
      Result := True;
    end;
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);
end;

This routine is some utils code in our game engine. It can run an executable and optionally wait for it to exit. It will return its exit code:

function TSvUtils.FileExecute(ahWnd: Cardinal; const aFileName, aParams, aStartDir: string; aShowCmd: Integer; aWait: Boolean): Integer;
var
  Info: TShellExecuteInfo;
  ExitCode: DWORD;
begin

  Result := -1;
  FillChar(Info, SizeOf(Info), 0);
  Info.cbSize := SizeOf(TShellExecuteInfo);
  with Info do begin
    fMask := SEE_MASK_NOCLOSEPROCESS;
    Wnd := ahWnd;
    lpFile := PChar(aFileName);
    lpParameters := PChar(aParams);
    lpDirectory := PChar(aStartDir);
    nShow := aShowCmd;
  end;

  if ShellExecuteEx(@Info) then
  begin
    if aWait then
    begin
      repeat
        Sleep(1);
        Application.ProcessMessages;
        GetExitCodeProcess(Info.hProcess, ExitCode);
      until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
      CloseHandle(Info.hProcess);
      Result := ExitCode;
    end;
  end
end;

Here is some code that can check to see if a process exists. So... current app calls the updater and terminates. The updater can check to see if old app has terminated and do it's thing (rename, update, delete, etc):

function TSvUtils.ProcessExists(const aExeFileName: string; aBringToForgound: Boolean=False): Boolean;
var
  ContinueLoop: BOOL;
  FSnapshotHandle: THandle;
  FProcessEntry32: TProcessEntry32;
begin

  FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
  ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
  Result := False;
  while Integer(ContinueLoop) <> 0 do
  begin
    if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
      UpperCase(aExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
      UpperCase(aExeFileName))) then
    begin
      if aBringToForgound then
        EnumWindows(@BringToForgroundEnumProcess, FProcessEntry32.th32ProcessID);
      Result := True;
    end;
    ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
  end;
  CloseHandle(FSnapshotHandle);
end;

在执行 ShellExecute 之前等待?

走过海棠暮 2024-11-14 07:37:29

我为此构建了一个相当便宜的 API,实际上是为了解析电子邮件和电子邮件链签名中的联系人数据。它被称为 SigParser。您可以在此处查看 Swagger 文档。

基本上,您向它发送一个带有 JSON 正文的标头“x-api-key”,如下所示,它会解析电子邮件回复链中的所有联系人。

{
  "subject": "Thanks for meeting...",
  "from_address": "[email protected]",
  "from_name": "Bill Gates",
  "htmlbody": "<div>Hi, good seeing you the other day.</div><div>--</div><div>Bill Gates</div><div>Cell 777-444-8888</div><a href=\"https://www.linkedin.com/in/williamhgates/\">LinkedIn</a><a href=\"https://twitter.com/BillGates\">Twitter</a>",
  "plainbody": "Hi, good seeing you the other day. \r\n--\r\nBill Gates\r\nCell 777-444-8888",
  "date": "Mon, 28 May 2018 23:33:40 +0000 (UTC)"
}

I built a pretty cheap API for this actually to parse the contact data from signatures of emails and email chains. It's called SigParser. You can see the Swagger docs here for it.

Basically you send it a header 'x-api-key' with a JSON body like so and it parses all the contacts in the reply chain of an email.

{
  "subject": "Thanks for meeting...",
  "from_address": "[email protected]",
  "from_name": "Bill Gates",
  "htmlbody": "<div>Hi, good seeing you the other day.</div><div>--</div><div>Bill Gates</div><div>Cell 777-444-8888</div><a href=\"https://www.linkedin.com/in/williamhgates/\">LinkedIn</a><a href=\"https://twitter.com/BillGates\">Twitter</a>",
  "plainbody": "Hi, good seeing you the other day. \r\n--\r\nBill Gates\r\nCell 777-444-8888",
  "date": "Mon, 28 May 2018 23:33:40 +0000 (UTC)"
}

如何解析电子邮件文本中的<称呼><正文><签名><回复文本>等组件ETC?

走过海棠暮 2024-11-14 07:16:02

据我阅读 calendar.getTimeInMillis();返回以毫秒为单位的 UTC 时间。我使用了以下代码,并将其与本网站 http://www.xav.com/time 中的纪元进行了比较.cgi

public int GetUnixTime()
{
    Calendar calendar = Calendar.getInstance();
    long now = calendar.getTimeInMillis();
    int utc = (int)(now / 1000);
    return (utc);

}

乔拉

As far as I read the calendar.getTimeInMillis(); returns the UTC time in millis. I used the following code and compared it to the Epoch in this site http://www.xav.com/time.cgi.

public int GetUnixTime()
{
    Calendar calendar = Calendar.getInstance();
    long now = calendar.getTimeInMillis();
    int utc = (int)(now / 1000);
    return (utc);

}

Giora

使用 Android 获取 GMT 时间

走过海棠暮 2024-11-14 06:06:33
$this->title = "Edit album";
$this->headTitle($this->title);
$this->title = "Edit album";
$this->headTitle($this->title);

Zend:如何在 Bootstrap.php 中获取视图?

走过海棠暮 2024-11-14 05:18:43

我喜欢 @lbsweek 的解决方案,但我有点担心只是为了转换而分配 UIView,而是尝试了下面的方法

- (UIImage *)rotateImage:(UIImage *)sourceImage byDegrees:(float)degrees
{
    CGFloat radian = degrees * (M_PI/ 180);
    CGRect contextRect = CGRectMake(0, 0, sourceImage.size.width, sourceImage.size.height);
    float newSide = MAX([sourceImage size].width, [sourceImage size].height);
    CGSize newSize =  CGSizeMake(newSide, newSide);
    UIGraphicsBeginImageContext(newSize);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGPoint contextCenter = CGPointMake(CGRectGetMidX(contextRect), CGRectGetMidY(contextRect));
    CGContextTranslateCTM(ctx, contextCenter.x, contextCenter.y);
    CGContextRotateCTM(ctx, radian);
    CGContextTranslateCTM(ctx, -contextCenter.x, -contextCenter.y);
    [sourceImage drawInRect:contextRect];
    UIImage* rotatedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return rotatedImage;
}

I liked the solution by @lbsweek but I was bit worried about alloc ing UIView just for transform, instead I tried the below

- (UIImage *)rotateImage:(UIImage *)sourceImage byDegrees:(float)degrees
{
    CGFloat radian = degrees * (M_PI/ 180);
    CGRect contextRect = CGRectMake(0, 0, sourceImage.size.width, sourceImage.size.height);
    float newSide = MAX([sourceImage size].width, [sourceImage size].height);
    CGSize newSize =  CGSizeMake(newSide, newSide);
    UIGraphicsBeginImageContext(newSize);
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGPoint contextCenter = CGPointMake(CGRectGetMidX(contextRect), CGRectGetMidY(contextRect));
    CGContextTranslateCTM(ctx, contextCenter.x, contextCenter.y);
    CGContextRotateCTM(ctx, radian);
    CGContextTranslateCTM(ctx, -contextCenter.x, -contextCenter.y);
    [sourceImage drawInRect:contextRect];
    UIImage* rotatedImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return rotatedImage;
}

旋转图像上下文 (CGContextRotateCTM) 导致其变为空白。为什么?

走过海棠暮 2024-11-14 03:50:28

看看这些:

http://msdn .microsoft.com/en-us/library/ms750564%28v=vs.85%29.aspx

特别是 WrapPanel

编辑:

ItemsControl 控件有一个 ItemsPanel 属性,您可以将其设置为使用 WrapPanel:

http://msdn.microsoft.com/en-us/library /system.windows.controls.itemscontrol.itemspanel.aspx

Have a look at these:

http://msdn.microsoft.com/en-us/library/ms750564%28v=vs.85%29.aspx

Specifically the WrapPanel

Edit:

The ItemsControl control has a ItemsPanel Property which you canset to use a WrapPanel:

http://msdn.microsoft.com/en-us/library/system.windows.controls.itemscontrol.itemspanel.aspx

WPF 中的 FlowLayout ItemsControl

走过海棠暮 2024-11-14 02:50:40

对于这样的情况,您可以使用 LinkableBehavior。它专为您想要的结果而设计。如果您不想使用它,则必须在标签控制器上进行查询:

$this->Tag->find('all', array('conditions' => array('Tag.name' => 'ruby')));

For conditions like this you can use the LinkableBehavior. It's designed for exact your wanted result. In case you don't want to use it, you have to do a query on the tag controller:

$this->Tag->find('all', array('conditions' => array('Tag.name' => 'ruby')));

CakePHP 条件查询与控制器“hasAndBelongsToMany”

走过海棠暮 2024-11-13 20:29:33

编辑 - 添加左连接

var accounts =
    from account in context.Accounts
    from owner in account.AccountOwners
    join business in context.Businesses
        on account.CreditRegistryId
        equals business.RegistryId
    join astatus in context.AccountStatuses
        on account.AccountStatusId
        equals astatus.AccountStatusId     
    join LS in context.LegalStatuses
        on account.LegalStatusId 
        equals LS.LegalStatusId
    from accountType in context.AccountTypes
                               .Where(at => at.AcountTypeCode == account.AccountType)
                               .DefaultIfEmpty()
    where !excludeTypes.Contains(account.AccountType)               
    select new AccountsReport
    {
        AccountTypeDescription = accountType.Abbreviation == null ? account.AccountType : accountType.Abbreviation,  
        AccountNumber = 1, 
        AccountStatus = "aasd", 
        CreditorAddress = "address", 
        CreditorCity = "my city", 
        CreditorName = "creditor name", 
        CreditorState = "my state", 
        LegalStatus = "my status", 
        RegistryId = 121323
    };

Edit - Adding a left join

var accounts =
    from account in context.Accounts
    from owner in account.AccountOwners
    join business in context.Businesses
        on account.CreditRegistryId
        equals business.RegistryId
    join astatus in context.AccountStatuses
        on account.AccountStatusId
        equals astatus.AccountStatusId     
    join LS in context.LegalStatuses
        on account.LegalStatusId 
        equals LS.LegalStatusId
    from accountType in context.AccountTypes
                               .Where(at => at.AcountTypeCode == account.AccountType)
                               .DefaultIfEmpty()
    where !excludeTypes.Contains(account.AccountType)               
    select new AccountsReport
    {
        AccountTypeDescription = accountType.Abbreviation == null ? account.AccountType : accountType.Abbreviation,  
        AccountNumber = 1, 
        AccountStatus = "aasd", 
        CreditorAddress = "address", 
        CreditorCity = "my city", 
        CreditorName = "creditor name", 
        CreditorState = "my state", 
        LegalStatus = "my status", 
        RegistryId = 121323
    };

在 Linq 中使用函数

走过海棠暮 2024-11-13 13:51:59

取决于几件事。但一种方法是确保当你想要香蕉时你只吃香蕉。我确信类型之间存在差异,因此您可以对此进行断言(例如,断言所有对象的名称仅是“banana”)。

Depends on few things. But one way would be just to make sure you only have banana when you expect a banana. I'm sure there are differences between types, so you can assert on that (eg. assert names of all objects are "banana" only).

如何开始 C# 单元测试?

走过海棠暮 2024-11-13 10:02:49

您可以从 STL 集中实现priority_queue。

实现可迭代的优先级队列C++

You can implement a priority_queue out of an STL set.

Implementing a priority queue that can be iterated over in C++

如何配置 std::priority_queue 以忽略重复项?

走过海棠暮 2024-11-13 09:37:35

您有 3 个选项,您的选择取决于您的技能以及您愿意投入多少时间:

基本身份验证

让您的用户在应用程序中输入用户名和密码,然后仅使用 HTTP BasicAuth 标头来访问网站。 Plone 支持开箱即用的 Basic auth 身份验证。

这不是最安全的方法;密码基本上都是以 base64 编码发送的,因此您可能希望使用 HTTPS 与服务器通信。无论如何,对于身份验证来说,这都是一个好主意。

Cookie 身份验证

将包含 __ac_name__ac_password 项的 POST 请求发送到 Plone 站点上的“/login_form”,并捕获 Set-Cookie 标头响应,包含 __ac cookie。这是一个 tk-auth 身份验证令牌,您可以在任何后续请求中使用。这是一个安全的 cookie,但任何嗅探 HTTP 通信流的攻击者都可以重复使用它,因此 HTTPS 再次成为安全的通信方式。

OAuth

Plone(尚)不支持开箱即用的 OAuth,但与 python-oauth 集成应该是微不足道的。这很可能需要编写 PluggableAuthSystem (PAS) 插件。

You have 3 options, and what you choose is dependent on what your skills are and how much time you are willing to invest:

Basic auth

Have your user enter a username and password into the app, and just use HTTP BasicAuth headers to access the site. Plone supports Basic auth authentication out of the box.

This is not the most secure method; passwords are basically sent base64-encoded, so you may want to use HTTPS to communicate with the server. A good idea in any case for authentication anyway.

Cookie authentication

Send a POST request with __ac_name and __ac_password items to '/login_form' on your Plone site, and capture the Set-Cookie header on the response, containing the __ac cookie. That's a tk-auth authentication token you can use on any subsequent request. This is a secure cookie, but any attacker sniffing the HTTP communication stream could re-use this, so again HTTPS is the secure way to communicate.

OAuth

Plone does not (yet) support OAuth out of the box, but integrating with python-oauth should be trivial. This would most likely require a PluggableAuthSystem (PAS) plugin to be written.

使用 Plone 对移动设备上的用户进行身份验证

走过海棠暮 2024-11-13 05:22:43

好吧,我不是要解释为什么;) - 但你可以反过来做,只给 非 IE 浏览器 提供 border-radius 样式.. 事实上通过条件注释的组合,您可以为 IE9 和其他浏览器提供边框半径样式,我不知道您的意思是哪个脚本发生冲突,但也许您也可以将脚本提供给需要它的浏览器?

这是一个示例(不使用 border-radius 但希望您能明白这个想法..)

<style type="text/css" media="screen">
div {
padding: 40px;
color: #fff;
}
</style>

<!--[if IE]>
<style type="text/css" media="screen">
div  {background: #00f}
</style>
<![endif]-->

<!--[if (!IE)|(gt IE 7)]><!-->
<style type="text/css" media="screen">
div  {background: #f00}
</style>
<!--<![endif]-->

HTML:

<div>
   <p>background is red in non-IE browsers,and IE gt 7  - but background is blue in other IE's</p>
</div>

关于上述条件注释..

第一个是常规样式,

第二个是“传统”隐藏条件注释,只有 IE 才能看到

第三个是显示注释,所有浏览器都可以看到,但 IE 仍然读取

您将通用规则放在普通工作表中的参数,以及边框半径里面的规则在第三个样式注释中的一个表中,

您可以更改第三个注释的参数,它基本上是说 if NOT IE OR is gt IE7

有关参数的更多信息:关于条件评论

Ok mine is not to reason why ;) - but you can do this the other way around and only give the border-radius styles to NON-IE browsers.. in fact with a combination of Conditional comments you can give the border radius styles to IE9 and other browsers, I don't know which script you mean is clashing but maybe you can also just give the script to the browsers that need it?

here's an example (not using border-radius but hopefully you may get the idea..)

<style type="text/css" media="screen">
div {
padding: 40px;
color: #fff;
}
</style>

<!--[if IE]>
<style type="text/css" media="screen">
div  {background: #00f}
</style>
<![endif]-->

<!--[if (!IE)|(gt IE 7)]><!-->
<style type="text/css" media="screen">
div  {background: #f00}
</style>
<!--<![endif]-->

HTML:

<div>
   <p>background is red in non-IE browsers,and IE gt 7  - but background is blue in other IE's</p>
</div>

About the above conditional comments..

the first is a regular style

the second is a "traditional" hidden conditional comment which Only IE sees

the third is a revealed comment which all browsers see but IE still reads the arguments

you would put the common rules in a normal sheet, and the border radius rules inside a sheet in the third style comment

you can change the argument of the third comment it's basically saying if NOT IE OR is gt IE7

More Information on arguments: About Conditional Comments

删除 IE 特定样式表中的 border-radius 样式

走过海棠暮 2024-11-13 05:01:06

关于将OpenCV连接到Qt GUI类,这里是一个示例代码 QtOpenCV 1 .它获取内容 ipmage ,IIRC 转换为 rgb32 并在 PaintEvent(QPaintEvent*) 中将其绘制在 QWidget 上;

About connecting OpenCV to Qt GUI classes , here is an example code QtOpenCV 1 . It takes content ipmage ,IIRC converts into rgb32 and paints it over a QWidget in paintEvent(QPaintEvent*);

将 opencv 连接到 qtcreator

走过海棠暮 2024-11-13 01:40:20
from urllib import pathname2url
pathname2url('foo,bar.mp3')
from urllib import pathname2url
pathname2url('foo,bar.mp3')

使用 python 正确编码文件路径

更多

推荐作者

娇女薄笑

文章 0 评论 0

biaggi

文章 0 评论 0

xiaolangfanhua

文章 0 评论 0

rivulet

文章 0 评论 0

我三岁

文章 0 评论 0

薆情海

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文