小编Mic*_*ael的帖子

将Integer []转换为int []数组

是否有一种将Integer数组转换为int数组的奇特方法?(我不想迭代每个元素;我正在寻找一种优雅而快速的方法来编写它)

我正在使用另一种方式

scaleTests.add(Arrays.stream(data).boxed().toArray(Double[]::new));

我正在寻找单线但无法找到的东西.

目标是:

int[] valuesPrimitives = <somehow cast> Integer[] valuesWrapper
Run Code Online (Sandbox Code Playgroud)

java arrays wrapper java-8

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

Docker 推送“缺少映像名称”-从 Github Actions 推送到 GCP Artifact Registry 时出错

我正在 Github 上运行google-github-actions/deploy-cloudrun操作,在尝试将 docker 映像推送到 Artifact Registry 时失败

  1. 我通过身份池进行身份验证
  2. docker镜像构建成功
  3. 但是,将图像推送Google Artifact Registry失败name invalid: Missing image name. Pushes should be of the form docker push HOST-NAME/PROJECT-ID/REPOSITORY/IMAGE

Github 操作 YML

# Authenticate Docker to Google Cloud Artifact Registry
  - name: Docker Auth
    id: docker-auth
    uses: 'docker/login-action@v1'
    with:
      username: 'oauth2accesstoken'
      password: '${{ steps.auth.outputs.access_token }}'
      registry: '${{ env.GAR_LOCATION }}-docker.pkg.dev'

  - name: Build and Push Container
    run: |-
      docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.SERVICE …
Run Code Online (Sandbox Code Playgroud)

docker google-cloud-platform github-actions google-artifact-registry

9
推荐指数
2
解决办法
3101
查看次数

构建Qt5 Git/Perl - 路径

我有一点理解问题.

Qt Wiki中写道,我必须:

提示:确保将Perl添加到git前面的路径,因为它发布了一个过时的版本(Perl 5.8),这将导致脚本失败.

但这究竟意味着什么呢?这是指PATH变量吗?它包含以下项目:

C:\Python33\
C:\Perl64\site\bin
C:\Perl64\bin
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files (x86)\AMD APP\bin\x86_64
C:\Program Files (x86)\AMD APP\bin\x86
%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\
C:\Program Files\Common Files\Autodesk Shared\
C:\Program Files\Microsoft\Web Platform Installer\
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\
C:\Program Files (x86)\Windows Kits\8.0\Windows Performance Toolkit\
C:\Program Files (x86)\Autodesk\Backburner\
C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\
C:\Program Files\Microsoft SQL Server\100\Tools\Binn\
C:\Program Files\Microsoft SQL Server\100\DTS\Binn\
C:\Python33\Lib\site-packages\PyQt4
Run Code Online (Sandbox Code Playgroud)

有人能告诉我如何在git前面设置路径吗?我不知道这意味着什么

问候

git perl qt

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

如果我使用 Redux Toolkit 和 RTK-Query,需要 thunk 吗?

我正在使用Redux Toolkit (RTK) 和 Redux Toolkit Query (RTK-Query)。

在任何情况下仍然使用 是最佳实践、必要还是建议thunks,或者我应该将所有逻辑移至组件中?(handleLogin()如下所示)

const Login = () => {

    const dispatch = useDispatch()
    const [formState, setFormState] = useState({ name: '', password: '' })
    const [login, { isLoading }] = useLoginMutation()
    const { push } = useHistory()

    const handleLogin = async () => {
        try {
            const user = await login(formState).unwrap()
            dispatch(setCredentials(user));
        } catch (e) {
            console.error(e)
        }
    }


    return (
        <div>
            <input type="text" name="name" placeholder="name" />
            <input type="password" …
Run Code Online (Sandbox Code Playgroud)

redux redux-thunk react-redux redux-toolkit rtk-query

6
推荐指数
1
解决办法
5866
查看次数

“未检测到权限处理程序。” 在 Expo 和 dev-client 构建中使用 React-native-permissions 时出错

我正在尝试让react-native-permissions我的 Expo 开发客户端版本运行。构建成功,但是当我启动应用程序时,我得到一个相对通用的“未检测到权限处理程序”。错误。

研究建议添加权限ios/Podfile并确保ios/<appname>/Info.plist条目需要存在。

该应用程序无需react-native-permissions即可运行,但我想使用该包来检查是否设置了权限并引导用户进行设置(如果没有)。

ios/Podfile

  pod 'Permission-Microphone', :path => "#{permissions_path}/Microphone"
  pod 'Permission-SpeechRecognition', :path => "#{permissions_path}/SpeechRecognition"
Run Code Online (Sandbox Code Playgroud)

ios/<appname>/Info.plist(相关条目)

    <key>NSMicrophoneUsageDescription</key>
    <string>CUSTOM: Allow to access the microphone</string>
    <key>NSSpeechRecognitionUsageDescription</key>
    <string>CUSTOM: Allow to securely recognize user speech</string>
Run Code Online (Sandbox Code Playgroud)

app.config.js(博览会)

...
   "plugins": [
            "@react-native-firebase/app",
            "@react-native-firebase/perf",
            "@react-native-firebase/crashlytics",
            "@react-native-google-signin/google-signin",
            ["react-native-fbsdk-next",
                {
                    "appID": "xxx",
                    "clientToken": "xxx",
                    "displayName": "xxx",
                    "advertiserIDCollectionEnabled": false,
                    "autoLogAppEventsEnabled": false,
                    "isAutoInitEnabled": true
                }
            ],
            [
                "@react-native-voice/voice",
                {
                    "microphonePermission": "CUSTOM: Allow access the microphone",
                    "speechRecognitionPermission": "CUSTOM: to securely recognize user speech"
                }
            ] …
Run Code Online (Sandbox Code Playgroud)

javascript react-native expo react-native-permissions expo-eas

6
推荐指数
1
解决办法
6446
查看次数

*ngFor显示空数组中的元素

关注*ngFor

<ul>
  <li *ngFor="#todo of todoService.todos">
    {{todo}}
  <li>
</ul>
Run Code Online (Sandbox Code Playgroud)

其中todoService是注入接口

import {Injectable} from 'angular2/core';

@Injectable()
export class TodoService {
    todos = []
}
Run Code Online (Sandbox Code Playgroud)

当我加载页面时,输出<li></li>而不是什么.

知道为什么吗?由于数组是空的,因此不应该有<li>-tag

编辑 当我用值初始化数组时也会发生这种情况.无缘无故总是有一个尾随的空元素.

EDIT2 问题示例 https://plnkr.co/edit/MRYC4MHtlDLfBMUPsL6o?p=preview

javascript angularjs angular

5
推荐指数
1
解决办法
2931
查看次数

如何使用 fetch 对 tRPC 查询的查询参数进行编码

根据tRPC文档,查询参数必须遵循此格式

myQuery?input=${encodeURIComponent(JSON.stringify(input))}
Run Code Online (Sandbox Code Playgroud)

我有这个程序:

  hello: publicProcedure
    .input(z.object({ text: z.string() }))
    .output(z.object({ greeting: z.string() }))
    .query(({ input }) => {
      return {
        greeting: `Hello ${input.text}`,
      };
    }),
Run Code Online (Sandbox Code Playgroud)

手动构造的 URL 返回错误:

const data = {text: "my message"}
const res = await fetch('http://localhost:3000/api/trpc/example.hello?batch=1&input='+encodeURIComponent(JSON.stringify(data)), { method: 'GET' });
const body = await res.json();
console.log(body);
Run Code Online (Sandbox Code Playgroud)

该错误表明查询参数编码不正确?知道出了什么问题吗?使用客户端,它的工作原理:const test = api.example.hello.useQuery({ text: "my message" });

{
    "error": {
        "json": {
            "message": "[\n  {\n    \"code\": \"invalid_type\",\n    \"expected\": \"object\",\n    \"received\": \"undefined\",\n    \"path\": [],\n    \"message\": \"Required\"\n  }\n]", …
Run Code Online (Sandbox Code Playgroud)

rpc typescript next.js trpc.io

5
推荐指数
1
解决办法
3279
查看次数

Visual Studio 11 GLFW外部符号错误

我使用的基本代码是http://www.glfw.org/documentation.html中的示例

我得到这个输出:

1>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
1>  Quelle.cpp
1>Quelle.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>Quelle.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main
1>Quelle.obj : error LNK2019: unresolved external symbol _glfwCreateWindow referenced in function _main
1>Quelle.obj : error LNK2019: unresolved external symbol _glfwWindowShouldClose referenced in function _main
1>Quelle.obj : error LNK2019: unresolved external symbol _glfwPollEvents referenced in function _main
1>Quelle.obj : error LNK2019: unresolved …
Run Code Online (Sandbox Code Playgroud)

c++ opengl linker glfw visual-studio-2012

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

UTF-8编码仍然输出错误

我有一个编码问题.

该表使用utf8_general_ci了php标头,header("Content-Type: text/html; charset=utf-8");并在html <meta charset="utf-8">中设置了元标记.BOM设置正确.德语字符显示在phpmyadmin中.

但是当我输出编码结果时:Sask

还有什么想法我能做什么?

html php sql encoding utf-8

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

如何结合护照和angular-ui路由

我想知道如何将角度ui路由与护照结合起来.我找到的所有示例都使用node.js路由.

var routerApp = angular.module('routerApp', ['ui.router']);

routerApp.config(function($stateProvider, $urlRouterProvider) {

$urlRouterProvider.otherwise('/home');

$stateProvider

    .state('home', {
        url: '/home',
        templateUrl: 'partial-home.html'
    })

    .state('about', {
        // for example just show if is loggedIn       
    });
Run Code Online (Sandbox Code Playgroud)

我将如何在上面的代码段中实现此功能?

function isLoggedIn(req, res, next) {

    // if user is authenticated in the session, carry on 
    if (req.isAuthenticated())
        return next();

    // if they aren't redirect them to the home page
    res.redirect('/');
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的每一个提示

javascript node.js angularjs angular-ui-router passport.js

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