AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / coding / 问题

全部问题(coding)

Martin Hope
Arthur Kexu-Wang
Asked: 2025-04-29 05:54:38 +0800 CST

在 Coq(或 Rocq)中,具有全称结论的引理不能应用于其他前提吗?

  • 6

当我用 Coq(或 Rocq)证明时,我发现有时如果一个假设是“P”而另一个假设是“P -> forall x, Q x”,我无法通过肯定前件将“forall x, Q x”变成一个新的前提。

以下是一个例子:

Theorem post_forall: forall (X: Type) (P: Prop) (Q: X -> Prop),
  (P -> forall x, Q x) -> forall x, P -> Q x.
Proof.

(* 
Here is a correct proof:

intros X P Q. 
intros H.
intros y.
intros H1.
generalize dependent y.
apply H.
apply H1. 
Qed.
*)


intros X P Q. 
intros H.
intros y.
intros H1.
generalize dependent y.
apply H in H1.
(** STUCK HERE, 

But Why cannot we do this???

They look the same.
*)
Admitted.

证明将停留在“在 H1 中应用 H”这一行,并且 Coq 返回“无法找到变量 x 的实例”。

但是“x”必须被实例化吗?这看起来没有必要。这两个证明有什么区别?

我咨询了DeepSeek和ChatGPT,但他们都没能给出令人满意的答案。

我还猜测这可能是先行句中变量出现的问题。但如果是这样,“泛化依赖”策略应该会失败。

logic
  • 3 个回答
  • 40 Views
Martin Hope
Skunka
Asked: 2025-04-29 05:50:12 +0800 CST

如何在 tailwind @theme 指令中使用 hsl() 函数

  • 6

hsl()我正在尝试在 Tailwind 4指令中使用 css 函数定义颜色变体,@theme但它不适用:

@theme {
    /* Colors */
    --color-primary: #006fa0;

    /* Darken colors */
    --theme-color-primary-darken: hsl(from var(--color-primary) h s calc(l - 5));

    /* Lighten colors */
    --theme-color-primary-lighten: hsl(from var(--color-primary) h s calc(l - 5));
}

加深和变浅的颜色变体与原始颜色完全相同。

我看了一些现有的答案,例如how-to-use-hsl-custom-color-in-tailwind-in-react,但他们都说要使用tailwind.config.js,但 Tailwind 4 现在有了一种zero-config方法,所以我想知道如何直接在 css 文件中实现我的颜色变化?

css
  • 1 个回答
  • 26 Views
Martin Hope
Tiago Peres
Asked: 2025-04-29 05:29:48 +0800 CST

Sentry Logger [警告]:由于缺少或非字符串释放而被丢弃的会话

  • 5

根据 React FE 项目的 Sentry 设置指南

React 中的 Sentry 设置指南

import * as Sentry from "@sentry/react";

Sentry.init({
  dsn: "SOME_SENTRY_DNS",
  // Setting this option to true will send default PII data to Sentry.
  // For example, automatic IP address collection on events
  sendDefaultPii: true
});

const container = document.getElementById(“app”);
const root = createRoot(container);
root.render(<App />);

我已经调整为

const SENTRY_DSN = process.env.REACT_APP_SENTRY_DSN;
const SENTRY_ENV = process.env.REACT_APP_SENTRY_ENVIRONMENT || "development";

Sentry.init({
  dsn: SENTRY_DSN,
  environment: SENTRY_ENV,
  sendDefaultPii: true,
  debug: true,
  autoSessionTracking: false,
  beforeSend(event) {
    console.log("Sentry about to send event:", event);
    return event;
  },
});

但仍然不断

Sentry Logger [warn]: Discarded session because of missing or non-string release

在此处输入图片描述

javascript
  • 1 个回答
  • 38 Views
Martin Hope
Eric Wang
Asked: 2025-04-29 04:52:15 +0800 CST

根据一个父维度定义两个元素维度

  • 5

:root {
    --success: #0c0;
}

button {
    border: 2px solid;
    border-radius: 10px;
    cursor: pointer;
    margin: 1em 0.5em;
    padding: 10px 15px;
    transition: transform 1s;
}

button:active {
    transform: scale(90%);
}

button.animated {
    background-color: transparent;
    overflow: hidden;
    position: relative;
    transition: color 1s, border-color 1s, transform 0.2s;
    z-index: 1;
}

button.animated:hover {
    border-color: transparent;
}

button.animated::after {
    border: 0;
    border-radius: 50%;
    content: "";
    height: 150%;
    left: -25%;
    opacity: 0;
    position: absolute;
    top: -25%;
    transform: scale(0.1);
    transform-origin: center;
    transition: all 1s;
    width: 150%;
    z-index: -1;
}

button.animated:hover::after {
    opacity: 1;
    transform: scale(1);
}

.text,
button.animated.background::after {
    background-color: white;
}

.background,
button.animated.text:hover{
    color: white;
}

button.animated.text {
    border-color: var(--muted);
}

.success.text,
button.animated.success.background:hover {
    color: var(--success);
}

.success.background,
button.animated.success.text::after {
    background-color: var(--success);
}

button.animated.success.text:hover,
button.animated.success.background {
    border-color: var(--success);
}
<button class="animated success background">Button</button>
<button class="animated success background">Longer button</button>

上面代码片段中的按钮具有椭圆形的背景效果,当您将鼠标悬停在按钮上时,该效果就会出现。目前,椭圆的尺寸与按钮的尺寸成比例。我希望椭圆是圆形,其宽度是按钮长边的 141.4%,或者,如果不可能的话,是按钮的宽度。我该如何实现?

html
  • 2 个回答
  • 45 Views
Martin Hope
Nickknack
Asked: 2025-04-29 04:21:55 +0800 CST

在.NET中运行时应用多个环境配置文件

  • 7

我想在我的 .NET 微服务中创建多个appsettings.<environment>.json文件,并且当我运行我的应用程序时,我想指定要使用的环境配置文件并让它们appsettings按照指定的顺序应用。

例如,我希望拥有appsettings.Development.json运行应用程序的默认本地开发属性,但我还希望将其覆盖为 hsql 数据库的appsettings.Hsqldb.jsonDB 属性。appsettings.Development.json

launch.json我在vs Code中有以下文件:

{
    "configurations": [
    {
        "name": "C#: App Debug",
        "type": "coreclr",
        "request": "launch",
        "program": "${workspaceFolder}/API/API.csproj",
        "env": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
    }
    ]
}

我想要做的是"ASPNETCORE_ENVIRONMENT": "Development,Hsqldb"。这样它就会先应用第一个属性Development,Hsqldb然后再应用覆盖它的属性。但这似乎不可能。

可以同时设置两个环境吗?有什么好办法吗?

c#
  • 1 个回答
  • 68 Views
Martin Hope
kelin
Asked: 2025-04-29 04:09:37 +0800 CST

WeatherKit - 当前天气自动更新

  • 5

随着时间的推移,变量会WeatherKit.Weather.currentWeather根据每日和每小时的预测自动更新吗?还是它是一个静态值,一旦收到就保持不变?

  • 1 个回答
  • 62 Views
Martin Hope
Isaiah Desrosiers
Asked: 2025-04-29 04:07:05 +0800 CST

是否存在一些 useEffect 和 useState 行为可以解释为什么只有其中一个实例起作用?

  • 5

我用它useEffect来获取数据。这些数据会被传递给一个状态,然后作为组件的 prop 进行相应的渲染/填充。以下是可以运行的代码:

const [projects, setProjects] = useState([]);

useEffect(() => {
  const q = query(collection(db, "projects"), orderBy("update", "desc"));
  const unsubscribe = onSnapshot(q, (QuerySnapshot) => {
    const fetched = [];
    QuerySnapshot.forEach((doc) => {
      fetched.push({ ...doc.data(), id: doc.id });
    });
    const sortedProjects = fetched.sort((a, b) => a.update - b.update);
    setProjects(sortedProjects);
  });
  return () => unsubscribe;
}, []);

上面的代码正确地获取了数据,然后将其传递给一个组件,该组件随后使用 map 显示项目列表。为了简化流程,我想看看是否可以对简历数据做同样的处理。代码如下:

const [edu, setEducation] = useState([]);

useEffect(() => {
  const q = query(
    collection(db, "resume/resume/education"),
    orderBy("startDate")
  );
  const unsubscribe = onSnapshot(q, (QuerySnapshot) => {
    const fetched = [];
    QuerySnapshot.forEach((doc) => {
      fetched.push({ ...doc.data(), id: doc.id });
    });
    const sortedEdu = fetched.sort(
      (a, b) => a.startDate.nanoseconds - b.startDate.nanoseconds
    );
    setEducation(sortedEdu);
  });
  return () => unsubscribe;
}, []);

这个不知为何不起作用。我检查了数据是否正在被检索(确实如此),并且useEffect和useState似乎正常工作。我甚至在组件中添加了登录信息,数据确实从登录端显示了出来,但仍然出现 map 错误,提示数组未定义,导致 React 无法渲染。我还知道,当我尝试直接输入数据时,这些组件是可以正常工作的。这可能是什么原因造成的?

我直接复制粘贴了这些值,然后调整了一下,问题依然存在。为了清晰起见,以下是问题组件:

export const ResumeItemLister = ({ items, sectionTitle }) => {
  return (
    <div>
      <h2 className="text-xl text-left">{sectionTitle}</h2>
      <hr />
      <table>
        {items.map(({ title, location, date, bullets }) => (
          <tr className="pt-10">
            <div className="grid grid-cols-3">
              <td className="text-left">{date}</td>
              <td className="col-span-2">
                <div className="text-left">
                  {title ? (
                    <p>
                      <bold className="font-bold">{title}</bold>, {location}
                    </p>
                  ) : (
                    <p>{location}</p>
                  )}
                  <ul>
                    {bullets.map((text) => (
                      <li className="list-disc list-inside"> {text}</li>
                    ))}
                  </ul>
                </div>
                <br />
              </td>
            </div>
          </tr>
        ))}
      </table>
    </div>
  );
};

只要我在父组件中明确设置了这些项,就可以正常工作。但是,使用获取到的状态,我得到:

Uncaught TypeError: Cannot read properties of undefined (reading 'map')

我理解这意味着 items 未定义,但正如我提到的,情况并非如此。任何帮助我都非常感谢。

javascript
  • 1 个回答
  • 67 Views
Martin Hope
user3624334
Asked: 2025-04-29 04:04:16 +0800 CST

如何为 Typescript 函数参数指定独占类型[重复]

  • 6
这个问题已经有答案了:
如何在 TypeScript 中使用否定类型? (2 个回答)
昨天关闭。

有没有办法声明一个 Typescript 函数,如果传入的值是静态已知为特定类型的,则会导致 tsc 拒绝对它的调用,否则接受调用?

在下面的示例中,我有一个包装传递值的函数,但如果传入的值已被包装,我希望该函数静态拒绝调用。

此时,我能做到的最好的事情是,如果传入了包装值,则使静态分析器期望函数返回的值为“从不”。

class WrappedValue<T> {
    constructor(readonly value:T) {}
}

function wrap<T>( value:T) : WrappedValue<T> {
    return new WrappedValue(value)
}

type SingleWrapped<RR> = RR extends WrappedValue<unknown> ? never : WrappedValue<RR>;

function wrap_strict<TT>(retvalIn:TT) : SingleWrapped<TT> {
    if (retvalIn instanceof WrappedValue) {
        throw new Error('strict failure')
    } else {
        //@ts-expect-error   TODO: How do we avoid the error below:   TS2322: Type 'WrappedValue<TT>' is not assignable to type 'SingleWrapped<TT>'.
        let retval  : SingleWrapped<TT> =  wrap<TT>(retvalIn);
        return retval;
      }
}

const xx1 = wrap_strict(2)
xx1.value
const xx2 = wrap_strict(wrap(3))
// TODO: is there a way to cause tsc to complain on the line above rather than the line below?
xx2.value   // tsc complains about this line because xx2  is of type  never
typescript
  • 1 个回答
  • 54 Views
Martin Hope
Jay Askren
Asked: 2025-04-29 03:55:20 +0800 CST

如何使用下拉菜单更改 Vega 可视化中的字段

  • 6

在 Vega 或 Vega Lite 中,我想创建一个堆叠面积图,并可以更改用于为可视化着色的字段。 这是一个可视化示例。在此示例中,我希望能够在“气缸”、“马力”和“加速度”分组之间切换。这是我尝试操作的简化版本,但足以说明要点。我尝试将该字段设置为附加到下拉菜单的信号,但似乎不起作用:

"fill": {
  "scale": "color_by_cylinders",
  "field": {"signal": "Group_By"}
},

即使它确实有效,我仍然需要根据下拉菜单更改颜色比例。我还需要更改聚合的字段。有没有办法在 Vega 或 Vega Lite 中做到这一点?

{
  "$schema": "https://vega.github.io/schema/vega/v6.json",
  "autosize": {"type": "fit-x", "contains": "padding"},
  "background": "white",
  "padding": 5,
  "height": 250,
  "style": "cell",
  "data": [
    {"name": "Group_By_store"},
    {
      "name": "source_0",
      "url": "data/cars.json",
      "format": {"type": "json"},
      "transform": [
        {
          "type": "aggregate",
          "groupby": ["Origin", "Cylinders"],
          "ops": ["count"],
          "fields": [null],
          "as": ["__count"]
        },
        {
          "type": "stack",
          "groupby": ["Origin"],
          "field": "__count",
          "sort": {"field": ["Cylinders"], "order": ["descending"]},
          "as": ["__count_start", "__count_end"],
          "offset": "zero"
        }
      ]
    }
  ],
  "signals": [
    {
      "name": "width",
      "init": "isFinite(containerSize()[0]) ? containerSize()[0] : 300",
      "on": [
        {
          "update": "isFinite(containerSize()[0]) ? containerSize()[0] : 300",
          "events": "window:resize"
        }
      ]
    },
    {
      "name": "unit",
      "value": {},
      "on": [
        {"events": "pointermove", "update": "isTuple(group()) ? group() : unit"}
      ]
    },
    {
      "name": "Group_By",
      "value": null,
      "bind": {
        "input": "select",
        "options": ["Cylinders", "Horsepower", "Acceleration"],
        "labels": ["Cylinders", "Horsepower", "Acceleration"]
      }
    }
  ],
  "marks": [
    {
      "name": "marks",
      "type": "rect",
      "style": ["bar"],
      "interactive": true,
      "from": {"data": "source_0"},
      "encode": {
        "update": {
          "fill": {
            "scale": "color_by_cylinders",
            "field": {"signal": "Group_By"}
          },
          "ariaRoleDescription": {"value": "bar"},
          "description": {
            "signal": "\"Origin: \" + (isValid(datum[\"Origin\"]) ? datum[\"Origin\"] : \"\"+datum[\"Origin\"]) + \"; Number of Cars: \" + (format(datum[\"__count\"], \"\")) + \"; Cylinders: \" + (isValid(datum[\"Cylinders\"]) ? datum[\"Cylinders\"] : \"\"+datum[\"Cylinders\"])"
          },
          "x": {"scale": "x", "field": "Origin"},
          "width": {"signal": "max(0.25, bandwidth('x'))"},
          "y": {"scale": "y", "field": "__count_end"},
          "y2": {"scale": "y", "field": "__count_start"}
        }
      }
    }
  ],
  "scales": [
    {
      "name": "x",
      "type": "band",
      "domain": {"data": "source_0", "field": "Origin", "sort": true},
      "range": [0, {"signal": "width"}],
      "paddingInner": 0.1,
      "paddingOuter": 0.05
    },
    {
      "name": "y",
      "type": "linear",
      "domain": {
        "data": "source_0",
        "fields": ["__count_start", "__count_end"]
      },
      "range": [{"signal": "height"}, 0],
      "nice": true,
      "zero": true
    },
    {
      "name": "color_by_horsepower",
      "type": "ordinal",
      "domain": {"data": "source_0", "field": "Cylinders", "sort": true},
      "range": "category"
    },
    {
      "name": "color_by_acceleration",
      "type": "ordinal",
      "domain": {"data": "source_0", "field": "Cylinders", "sort": true},
      "range": "category"
    },
    {
      "name": "color_by_cylinders",
      "type": "ordinal",
      "domain": {"data": "source_0", "field": "Cylinders", "sort": true},
      "range": "category"
    }
  ],
  "axes": [
    {
      "scale": "y",
      "orient": "left",
      "gridScale": "x",
      "grid": true,
      "tickCount": {"signal": "ceil(height/40)"},
      "domain": false,
      "labels": false,
      "aria": false,
      "maxExtent": 0,
      "minExtent": 0,
      "ticks": false,
      "zindex": 0
    },
    {
      "scale": "x",
      "orient": "bottom",
      "grid": false,
      "title": "Origin",
      "labelAlign": "right",
      "labelAngle": 270,
      "labelBaseline": "middle",
      "zindex": 0
    },
    {
      "scale": "y",
      "orient": "left",
      "grid": false,
      "title": "Number of Cars",
      "labelOverlap": true,
      "tickCount": {"signal": "ceil(height/40)"},
      "zindex": 0
    }
  ],
  "legends": [
    {"fill": "color_by_cylinders", "symbolType": "square", "title": "Cylinders"}
  ],
  "config": {}
}
signals
  • 1 个回答
  • 14 Views
Martin Hope
Fayzs
Asked: 2025-04-29 03:31:03 +0800 CST

如何使用 Terraform 为 Azure Linux 应用服务设置 Java 运行时堆栈

  • 4

我正在尝试使用 Terraform 为 Azure Linux 应用服务配置 Java 运行时堆栈。

我按照azurerm_linux_web_app 的 Terraform 文档进行操作,并根据输出配置了 java_server、java_server_version 和 java_version 值az webapp list-runtimes --os-type linux

1- 首次尝试

这是我当前的 Terraform 代码:

    resource "azurerm_linux_web_app" "app_service" {
      site_config {
         application_stack {
           java_server         = "JAVA"
           java_server_version = "java21"
           java_version        = "21"
          }
          app_command_line = "java -jar /home/site/wwwroot/app.jar"
        }
     }

但是,部署后,Azure 门户中的运行时堆栈部分显示空配置(参见此屏幕截图)。

2- 第二:

我偶然发现了一个相关的 GitHub 问题,上面说可以通过设置 linux_fx_version 属性来解决这个问题。于是我更新了代码,并尝试了以下方法:

    resource "azurerm_linux_web_app" "app_service" {
      site_config {
          linux_fx_version="JAVA|21"
          app_command_line = "java -jar /home/site/wwwroot/app.jar"
        }
     }

但是,在较新版本的 azurerm_linux_web_app 资源中,此属性现在是计算的,并且不能再手动设置。

╷
│ Error: Value for unconfigurable attribute
│ 
│   with module.compute.azurerm_linux_web_app.app_service,
│   on modules\004-compute\main.tf line 20, in resource "azurerm_linux_web_app" "app_service":
│   20:     linux_fx_version = "JAVA|21"
│ 
│ Can't configure a value for "site_config.0.linux_fx_version": its value will be decided automatically based on the result of applying this configuration.
  • 1 个回答
  • 57 Views
上一页
下一页

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve