我正在制作一个简单的 Windows 程序,但由于某种原因RegisterClass返回FALSE,我不知道为什么。
我设置了结构的lpszClassName、hInstance和成员。lpfnWndProcWNDCLASS
这是我的代码:
#include <windows.h>
#include <tchar.h>
template<typename T>
class BaseWindow {
public:
static LRESULT CALLBACK WndProc(HWND hwnd, UINT umsg, WPARAM wparam, LPARAM lparam) {
T* pThis = NULL;
if (umsg == WM_NCCREATE) {
CREATESTRUCT* pCreate = (CREATESTRUCT*)lparam;
pThis = (T*)pCreate->lpCreateParams;
SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)pThis);
pThis->m_hwnd = hwnd;
} else {
pThis = (T*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
}
return pThis->HandleMessage(umsg, wparam, lparam);
}
HWND m_hwnd;
BOOL cls_state = FALSE;
BOOL Init() …Run Code Online (Sandbox Code Playgroud) 我们在 POSTGRES 上有以下查询
SELECT DISTINCT Doctor
FROM Table
WHERE (LOWER(Doctor) SIMILAR TO 'dr[.,][ !^]ab%'
OR LOWER(Doctor) SIMILAR TO 'dr[., !^]ab%'
OR LOWER(Doctor) SIMILAR TO 'dr[., !^] _ ab%'
OR LOWER(Doctor) SIMILAR TO 'mr[.,][ !^]ab%'
OR LOWER(Doctor) SIMILAR TO 'mr[., !^]ab%'
OR LOWER(Doctor) SIMILAR TO 'mr[., !^] _ ab%'
OR LOWER(Doctor) SIMILAR TO 'ms[.,][ !^]ab%'
OR LOWER(Doctor) SIMILAR TO 'ms[., !^]ab%'
OR LOWER(Doctor) SIMILAR TO 'ms[., !^] _ ab%'
OR LOWER(Doctor) SIMILAR TO 'ab%')
Run Code Online (Sandbox Code Playgroud)
显然这是一个相当繁重的查询。我们在 Doctor 字段上有一个索引,但在大型数据集上这仍然需要 3-5 秒,这是一个问题(我们在搜索医生姓名时使用它来自动完成)。
有什么办法可以加快这个速度吗?
.menu-container {
}
.menu-container .menu-option {
}Run Code Online (Sandbox Code Playgroud)
<section class="menu-container">
<p id="option-one" class="menu-option">Option One</p>
<p id="option-two" class="menu-option">Option Two</p>
<p id="option-three" class="menu-option">Option Three</p>
<p id="option-foure" class="menu-option">Option Four</p>
</section>Run Code Online (Sandbox Code Playgroud)
我有四个带有这些 ID 的菜单元素(选项一、选项二、选项三、选项四)。
当有人将鼠标悬停在其中一个选项上时,他们会使用 JS 或 CSS 模糊其余选项,悬停元素之前或之后的选项都会被模糊,但悬停元素不会。
我正在使用 while(getline(...)) 结构将填充有许多制表符的字符串流分解为单独的块以进行数据处理。实际上执行中断的 while 循环对第一行正确运行,但随后不会进入数据集中任何其他行的执行,即使在使用 str() 更新字符串流时也是如此。
我目前正在解析数据集。因为数据集包含许多逗号,并且因为我知道 std::getline() 有一个使用唯一分隔符的参数,所以我选择将数据集导出为 .tsv 而不是通常的 .csv。我取一条线并将其分成每个单元格的逻辑遵循我几乎总是这样做的:
for (int i = 0; i < 4; i++) {
counter = 0;
getline(inputfile, tsvLine);
lineStream.str(tsvLine);
while(getline(lineStream, currentChunk, '\t')){
cout << "[Part: " << ++counter << "] ";
cout << currentChunk << endl;
}
}
Run Code Online (Sandbox Code Playgroud)
for 循环内的所有内容都是我用于分解 .tsv 行的代码。获取inputfile(一个 ifstream)并将其 getline 到tsvLine(一个字符串)中,使用该字符串来更新 stringstream lineStream。一旦lineStream更新,将其放入由制表符分隔的 while(getline()) 中,以将每个部分分解为 currentChunk (字符串)并将其打印出来。这适用于 .tsv 中的第一行,并正确计数 65 个块。
顶部的 for 循环只是作为占位符放置到位,以便我可以在文件的前四行上运行代码。但是,接下来的三行不会运行。调试显示 tsvLine 已正确更新,lineStream 也已正确更新(我已经完成cout …
我用 Rust 编写了一个简单的程序。这个程序可以编译。
use std::cell::{Ref, RefCell};
fn print_number(x: &i32) {
println!("x is {}", x);
}
fn main() {
let stack: i32 = 42;
let reference: &i32 = &stack;
let refcell: RefCell<&i32> = RefCell::new(reference);
let wrapped: Ref<'_, &i32> = refcell.borrow();
print_number(&wrapped);
print_number(*wrapped);
}
Run Code Online (Sandbox Code Playgroud)
我可以说出两者都有效的原因:
&有效,因为&wrapped的类型为&Ref<&i32>,可以被解引用强制为&&i32,也可以被解引用强制为&i32。*有效,因为*wrapped相当于*Deref::deref(&wrapped). 我们知道Deref::deref(&Ref<&i32>)结果为&&i32,因此*Deref::deref(&Ref<&i32>)结果为*&&i32,即&i32。似乎第二种方法(使用*)更直接,但是 Rust 编译器建议我使用第一种方法(使用&)。如果我添加一行:
print_number(wrapped);
Run Code Online (Sandbox Code Playgroud)
这当然不能编译。但我对编译器报告感兴趣:
error[E0308]: …Run Code Online (Sandbox Code Playgroud) 我不确定我问的问题是否正确,但我想知道 C 或 ASM 程序是否可以在虚拟地址 0x0 处写入?
我知道内核不允许在虚拟 0x0 处写入/读取,但我想知道是否有一些奇怪的方法可以做到这一点。可能使用我不知道的 ld 或 gcc 标志?
设置如下:
类似于如何获取Sqlite3数据库上的列名列表?,但仍然不同:
出于调试目的,我编写了一个转储 SQLite3 表的闭包。输出不是很漂亮,但它可以工作:
sub something($)
{
my $dbh = shift;
my $me = '_dump_tables';
my $sep = '-' x length($me);
my $dump_table = sub ($) { # dump specified table or view
if (defined(my $rows = $dbh->selectall_arrayref(
"SELECT * FROM $_[0]"))) {
my $nsep = '-' x length($_[0]);
print "$me: $_[0]\n";
print "${sep}--${nsep}\n";
foreach (@$rows) {
print join('|', map { $_ // 'NULL' } @$_), "\n";
}
} else {
print "$me: Houston, we have a problem! …Run Code Online (Sandbox Code Playgroud) 在 R 中,我有一个 data.frame 显示节点对之间的距离:
dl <- data.frame(
a = c('a','a','a','b','b','c'),
b = c('b','c','d','c','d','d'),
dist = c(1,2,3,2,1,2)
)
Run Code Online (Sandbox Code Playgroud)
我想将其转换为距离矩阵,对角线设置为零,上三角形设置为 NA,因为距离是对称的:
dm <- data.frame(
a = c(0,2,3,2),
b = c(NA, 0, 2, 1),
c = c(NA, NA, 0, 2),
d = c(NA, NA, NA, 0),
row.names = c('a','b','c','d')
) %>% as.matrix()
Run Code Online (Sandbox Code Playgroud)
我的真实数据非常大,所以计算效率是关键。我自己能想到的唯一解决方案涉及循环或使用igraph首先将列表转换为图形,然后将该图形转换为矩阵,考虑到我的数据大小,这并不是非常理想。输入是一个 data.frame,因为节点 ID 是文本,而距离是数字,并且所需的输出是一个矩阵,因为速度是关键。
我已经编译了 Qt\xc2\xa0static,但是当我运行我的应用程序时,出现此错误:
\nqrc:/files/particles/particles.qml:2:1: module "QtQuick.Particles" plugin "particlesplugin" not found\xc2\xa0\n\xc2\xa0 \xc2\xa0 \xc2\xa0import QtQuick.Particles 2.0\xc2\xa0\n\xc2\xa0 \xc2\xa0 \xc2\xa0^\nRun Code Online (Sandbox Code Playgroud)\n我与 QML 相关的导入如下:
\nimport QtQuick 2.5\nimport QtQuick.Particles 2.0\nRun Code Online (Sandbox Code Playgroud)\n我尝试遵循文档:
\nqrc:/files/particles/particles.qml:2:1: module "QtQuick.Particles" plugin "particlesplugin" not found\xc2\xa0\n\xc2\xa0 \xc2\xa0 \xc2\xa0import QtQuick.Particles 2.0\xc2\xa0\n\xc2\xa0 \xc2\xa0 \xc2\xa0^\nRun Code Online (Sandbox Code Playgroud)\n但我收到此编译错误:
\nimport QtQuick 2.5\nimport QtQuick.Particles 2.0\nRun Code Online (Sandbox Code Playgroud)\n我在源代码中搜索了导入此插件的正确方法,并在C:\\Qt\\6.6.0_static\\qtdeclarative\\src\\articles 中找到了它
\n在文件keywordsplugin_init.cpp中中:
\n#include <QtPlugin>\n\nint main(int argc, char *argv[])\n{\n\xc2\xa0 \xc2\xa0 QApplication a(argc, argv); \xc2\xa0\xc2\xa0 \xc2\xa0\n Q_IMPORT_PLUGIN(QtQuick2Plugin)\n \xc2\xa0 \xc2\xa0Q_IMPORT_PLUGIN(QtQuick2ParticlesPlugin) // <--- cause error\n \xc2\xa0 Q_IMPORT_PLUGIN(QtQmlMetaPlugin)\n\xc2\xa0 …Run Code Online (Sandbox Code Playgroud) 创建编辑器失败。参数不正确。(HRESULT 异常:0x80070057 (E_INVALIDARG))
\n\n脚本迁移 - 来自“PreviousMigration”
\n将 Visual Studio Community 2022 从版本 17.8.6 更新到 17.9.0 导致错误。
\n脚本迁移:调用 COM 组件返回了错误 HRESULT E_FAIL。
\n行:1 字符:1
\n**解决方案:
\n我尝试从系统文件夹中删除用户和框架的所有临时文件,但它对我不起作用,然后我将xc2xa0降级到以前的xc2xa0Visual Studio Community 2022 版本 17.8.6,它可以工作。
\n我尝试从系统文件夹中删除用户和框架的所有临时文件,但它对我不起作用,然后我将xc2xa0降级到以前的xc2xa0Visual Studio Community 2022 版本 17.8.6,它可以工作。
\nvisual-studio entity-framework-core entity-framework-migrations ef-core-6.0
c++ ×3
assembly ×1
c ×1
css ×1
dbi ×1
dereference ×1
ef-core-6.0 ×1
entity-framework-migrations ×1
gcc ×1
html ×1
javascript ×1
ld ×1
perl ×1
postgresql ×1
qml ×1
qt ×1
r ×1
rust ×1
sqlite ×1
windows ×1