想象一下,我有一个字符串,我想按如下方式转换:
一种方法是这样的:
(defn my-function
[s]
(let
[
clean-string1 (clojure.string/replace s " " "")
clean-string2 (clojure.string/replace clean-string1 "." "")
clean-string3 (clojure.string/lower-case clean-string2)
]
;; ...
)
)
Run Code Online (Sandbox Code Playgroud)
我怎样才能“链接”这些功能clojure.string/replace,clojure.string/lower-case以便
(clojure.string/replace s " " "")被馈送到(clojure.string/replace clean-string1 "." "") 并且它的输出被馈送到(clojure.string/lower-case clean-string2)这样我就不需要中间变量clean-string1和clean-string2?
我需要在Delphi中启动一个线程并使用以下代码:
function ThreadFunc(tp: PThreadParams): Integer;
var
I: Integer;
begin
OutputDebugString(PChar('ThreadFunc, 1'));
for I := 0 to 10000 do
begin
if (I MOD 100) = 0 then
begin
OutputDebugString(PChar('Sample Delphi DLL ' + IntToStr(I)));
end;
end;
Dispose(tp);
end;
procedure RunThread;
var
tp : PThreadParams;
Thread : THandle;
ThreadID : Cardinal;
ExitCode : Cardinal;
begin
New(tp);
OutputDebugString(PChar('RunThread, 1'));
Thread := BeginThread(nil, 0, @ThreadFunc, tp, 0, ThreadID);
OutputDebugString(PChar('RunThread, 2. ThreadID: ' + IntToStr(ThreadID)));
WaitForSingleObject(Thread, INFINITE);
GetExitCodeThread(Thread, ExitCode);
CloseHandle(Thread);
end;
Run Code Online (Sandbox Code Playgroud)
当我运行RunThread时,日志文件包含条目
RunThread,1
RunThread,2.ThreadID:...
但没有日志输出 …
我有一个Visual C ++ DLL项目(只是一个项目,没有父解决方案),需要构建DLL。
生成命令不会生成任何错误消息。在Debug文件夹中mylibrary.lib,但没有mylibrary.dll。
我查看了Visual Studio 2010 C ++ DLL项目-没有输出DLL文件!,但我的情况与此问题不同。在构建输出中,没有类似的消息
MFCInterop.vcxproj-> C:\ temp \ sotest \ Debug \ MFCInterop.dll
只要
MFCInterop.vcxproj-> C:\ temp \ sotest \ Debug \ MFCInterop.lib
我该怎么做才能生成DLL文件?
我有一个窗口,里面有两个文本字段.
如何使用WinAPI调用获取两个文本字段的句柄?
注意:两个文本框都属于不同的应用程序(我在应用程序A中进行WinAPI调用,文本框位于应用程序B中).
更新1:
我Invalid window handle在调用时收到消息GetClassName.
我想我的回调函数声明有问题.
EnumChildWindows从这样的方法之一调用TMyClass:
EnumChildWindows(handle, @TMyClass.CBList, 0);
Run Code Online (Sandbox Code Playgroud)
这是回调函数的代码.
function TMyClass.CBList(Win: THandle; lp: LPARAM): Boolean; stdcall;
var
ClassName:array [1..1024] of Char;
begin
GetClassName(Win, PChar(@ClassName), 1024);
OutputDebugString(PChar('SysErrorMessage(GetLastError): '));
result := true;
end;
Run Code Online (Sandbox Code Playgroud) 我收到一个字符串,显示'{'#0'S'#0'a'#0'm'#0'p'#0'l'#0'e'#0'-'#0'M'#0'e'#0's'#0's'#0'a'#0'g'#0'e'#0'}'#0在调试器中.
我需要在调试输出(OutputDebugString)中打印出来.
当我运行时OutputDebugString(PChar(mymsg)),只显示收到的字符串的第一个字符(可能是因为#0字符串结束标记).
如何将该字符串转换为OutputDebugString可以使用的字符串?
更新1:这是代码.我想打印变量的内容RxBufStr.
procedure ReceivingThread.OnExecute(AContext : TIdContext);
var
RxBufStr: String;
begin
with AContext.Connection.IOHandler do
begin
CheckForDataOnSource(10);
if not InputBufferIsEmpty then
begin
RxBufStr := InputBuffer.Extract();
end;
end;
end;
Run Code Online (Sandbox Code Playgroud) 我的 PostgresSQL 数据库中有一个表person,其中包含不同用户的数据。
我需要编写一个测试用例,确保某个例程确实修改用户1的数据,并且不修改用户2的数据。
为此,我需要
a) 计算用户1和用户2所有行的哈希码,
b) 然后执行被测操作,
c) 再次计算哈希码并
d) 比较步骤 a) 和 c) 中的哈希码。
我找到了一种计算单行哈希码的方法:
SELECT md5(CAST((f.*)AS text))
FROM person f;
Run Code Online (Sandbox Code Playgroud)
为了实现我的目标(找出用户 2 的行是否已更改),我需要执行如下查询:
SELECT user_id, SOME_AGGREGATE_FUNCTION(md5(CAST((f.*)AS text)))
FROM person f
GROUP BY user_id;
Run Code Online (Sandbox Code Playgroud)
我可以使用什么聚合函数来计算一组行的哈希码?
注意:我只想知道用户2的任何行是否被更改。我不想知道到底发生了什么变化。
I'm new to Django and currently write an application, where users can enter their opinions on some topic.
Every opinion A may have zero or more opinions, which support A and several (zero or more) opinions, which refute A.
I tried to create a model for this and wrote a models.py file like this:
from django.db import models
# Create your models here.
class Opinion(models.Model):
id = models.AutoField(primary_key=True)
contents = models.CharField(max_length=256)
source = models.CharField(max_length=256)
proArguments = models.ManyToManyField(Opinion, verbose_name="Pro arguments")
contraArguments …Run Code Online (Sandbox Code Playgroud) 我有两个Maven项目A和B。B依赖于A。
someFile.txt在A中,我的文件夹中有一个文件src/main/resources。
public class SomeAClass
{
public void someMethod()
{
final InputStream inputStream =
Thread.currentThread()
.getContextClassLoader()
.getResourceAsStream("someFile.txt");
final List<String> lines = IOUtils.readLines(inputStream);
...
}
}
Run Code Online (Sandbox Code Playgroud)
在 A 的测试中,这工作得很好。
现在假设我想在 B 中使用相同的代码,包括从src/main/resources/someFile.txt.
现在,SomeAClass.someMethod()从项目 B 调用会导致 NullPointerException,我怀疑这是因为src/main/resources/someFile.txt找不到。
如何更改获取输入流的代码,src/main/resources/someFile.txt以便它在 A 的单元测试和执行 B 时都有效(B 是基于 Spring Shell 的控制台应用程序)?
我有一个项目,它调用Postgres函数gen_random_bytes,声明如下:
CREATE OR REPLACE FUNCTION core.gen_random_bytes(integer) RETURNS bytea AS '$libdir/pgcrypto', 'pg_random_bytes' LANGUAGE c STRICT;
Run Code Online (Sandbox Code Playgroud)
只要我在本地机器上使用它,它工作正常.但是我无法在Heroku上创建该函数 - 我收到以下错误:
[WARNING ] CREATE OR REPLACE FUNCTION core.gen_random_bytes(integer) RETURNS bytea AS '$libdir/pgcrypto', 'pg_random_bytes' LANGUAGE c STRICT
ERROR: permission denied for language c
Run Code Online (Sandbox Code Playgroud)
似乎只有超级用户才能在C中声明函数.我找到了另一个答案,建议使用该命令
UPDATE pg_language SET lanpltrusted = true WHERE lanname LIKE 'c';
Run Code Online (Sandbox Code Playgroud)
我也没有该命令的权限:
ERROR: permission denied for relation pg_language
SQL state: 42501
Run Code Online (Sandbox Code Playgroud)
如何让我的代码在Heroku上运行?
我至少有以下选项:
core.gen_random_bytes用Postgres语言重写.core.gen_random_bytes,这不需要超级用户权限.现在,我只是为这个项目做原型设计.哪个选项最简单(包括我没有提及的内容)?
我已在 Google Cloud 中安装了 Alfresco Community Edition v201707-5。用户界面的语言是俄语。我想把它改成英文。文档说您可以在用户配置文件中执行此操作。这对我不起作用。
根据上面的页面,首先您需要选择“我的个人资料”菜单项。
此后,个人资料页面将打开,在我的例子中如下所示。
这里必须有一个标题为“语言”的页面。但我没有看到。
如何更改用户界面的语言?
delphi ×3
delphi-2009 ×2
postgresql ×2
alfresco ×1
c ×1
clojure ×1
django ×1
dll ×1
encoding ×1
heroku ×1
java ×1
maven ×1
python ×1
python-2.5 ×1
utf-8 ×1
visual-c++ ×1
winapi ×1