小编Mik*_*ler的帖子

与 Material UI 反应找不到自定义字体

我的 mui 主题定义如下:

export default createMuiTheme({
  typography: {
    fontFamily: '"Nunito Sans", "Helvetica", "Arial", sans-serif',
    fontWeightLight: 300,
    fontWeightMedium: 600,
    fontWeightRegular: 400
    }
  }
});
Run Code Online (Sandbox Code Playgroud)

我使用App.css本地文件加载了字体。我可以从网络请求中看到这些文件正在被找到。

/* latin */
@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 300;
  src: local('Nunito Sans Light'), local('NunitoSans-Light'), 
  url(../assets/font/pe03MImSLYBIv1o4X1M8cc8WAc5tU1E.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* latin */
@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 400;
  src: local('Nunito Sans Regular'), …
Run Code Online (Sandbox Code Playgroud)

fonts themes reactjs material-ui

7
推荐指数
1
解决办法
8083
查看次数

JSONSchema - 依赖于父属性的必需属性

我想根据根模式中属性的存在,在数组子模式中应用一个额外的“必需”属性。我的架构设置如下:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "required":[
       "isParentDependency",
       "subArray"
    ],
    "properties": {
        "isParentDependency": {
            "$id": "#/properties/isParentDependency",
            "type": "boolean"
        },
        "subArray": {
            "$id": "#/properties/subArray",
            "type": "array",
            "items": {
                "$id": "#/properties/subArrayItem",
                "required": ["alwaysRequiredProp"],
                "dependencies": {
                    "isParentDependency":{
                        "required":["requiredPropIfIsParentDependency"]
                    }
                },
                "properties": {
                    "alwaysRequiredProp": {
                        "$id": "#/properties/subArray/items/properties/alwaysRequiredProp",
                        "type": "boolean"
                    },
                    "requiredPropIfIsParentDependency": {
                        "$id": "#/properties/subArray/items/properties/requiredPropIfIsParentDependency",
                        "type": "boolean"
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

过往案例

{
    "isParentDependency": false,
    "subArray": [{
        "alwaysRequiredProp": true
    }]
}
Run Code Online (Sandbox Code Playgroud)
    "isParentDependency": true,
    "subArray": [{
        "alwaysRequiredProp": true,
        "requiredPropIfIsParentDependency":true
    }]
}
Run Code Online (Sandbox Code Playgroud)

失败案例

{
    "isParentDependency": …
Run Code Online (Sandbox Code Playgroud)

javascript jsonschema ajv

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

CakePHP删除多个条件

这让我很生气.为什么Cake需要使简单的事情变得过于复杂..

我希望让Cake生成看起来像这样的SQL.

我希望运行的SQL是

DELETE `ProductVouchers` 
FROM `product_vouchers` AS `ProductVouchers`   
WHERE `ProductVouchers`.`id` = 16 
AND `ProductVouchers`.`client_id` IS NULL; 
Run Code Online (Sandbox Code Playgroud)

我使用delete()这样的

$this->ProductVouchers->delete([
    'ProductVouchers.id'=>$id,
    'ProductVouchers.client_id'=>"NULL"
]);
Run Code Online (Sandbox Code Playgroud)

日志显示

DELETE `ProductVouchers` 
FROM `product_vouchers` AS `ProductVouchers`   
WHERE `ProductVouchers`.`id` IN (16, 'NULL')
Run Code Online (Sandbox Code Playgroud)

$this->ProductVouchers->delete([
   'ProductVouchers.id'=>$id,
   'ProductVouchers.client_id'=>NULL
]);
Run Code Online (Sandbox Code Playgroud)

日志显示

DELETE `ProductVouchers` 
FROM `product_vouchers` AS `ProductVouchers`   
WHERE `ProductVouchers`.`id` IN (16, NULL) 
Run Code Online (Sandbox Code Playgroud)

试:

 $this->ProductVouchers->delete([
    'ProductVouchers.id'=>$id,
    'ProductVouchers.client_id IS NULL'
 ]);
Run Code Online (Sandbox Code Playgroud)

日志显示什么都没有错!

编辑:

正如下面的答案中指出的那样,该delete()方法是不正确的,因为它只接受主键作为整数.所以使用deleteAll()

 $this->ProductVouchers->deleteAll([       
   'ProductVouchers.id'=>$id,
   'ProductVouchers.client_id'=>'NULL'
 ]);
Run Code Online (Sandbox Code Playgroud)

这也不会在日志中产生任何内容或任何错误.试:

 $this->ProductVouchers->deleteAll([
   'ProductVouchers.id'=>$id,
   'ProductVouchers.client_id'=>NULL
 ]);
Run Code Online (Sandbox Code Playgroud)

这产生......

 DELETE `ProductVouchers` 
 FROM `product_vouchers` …
Run Code Online (Sandbox Code Playgroud)

php cakephp cakephp-3.0

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

使用 FFMPEG 将 RTMP 源重新流式传输到 YouTube - 输出中没有视频流

我正在尝试从 nginx-rtmp 服务器获取 .m3u8 文件并将其传递到 YouTube rtmp。我相信这是可能的(例如这里: https: //stackoverflow.com/a/11978820/1552594,尽管这是在同一主机上)。我正在使用的命令是:

ffmpeg -analyzeduration 0 -i \
http://source.rtmp.server/hls/stream.m3u8 -pix_fmt yuv420p \ 
-f flv rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx
Run Code Online (Sandbox Code Playgroud)

然而,输出仅包含音频,而 YouTube 不喜欢它。该命令产生以下结果:

没有视频哦

正如您在输出元数据中看到的那样,没有视频流,流映射仅显示音频,跟踪显示 0kb 视频对应 651kb 音频

非常感谢任何帮助

更多信息

从本文中提取的命令的改进版本:

https://judge2020.com/restreaming-a-m3u8-hls-stream-to-youtube-using-ffmpeg/

“使用 FFMPEG 将 m3u8 HLS 流重新传输到 Youtube”,这正是我想要做的。

我现在发送的命令是:

ffmpeg -re -i "http://source.rtmp.server/hls/stream.m3u8" \ 
-strict -2 -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -flags \ 
+global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv \ 
"rtmp://a.rtmp.youtube.com/live2/xxx-xxxx-xxxx-xxxx"
Run Code Online (Sandbox Code Playgroud)

除了使用编解码器读取和输出音频之外,我得到了几乎完全相同的响应aac

在此输入图像描述

更多更多信息

我发现添加映射可以强制视频流进入输出:

ffmpeg -re -i "http://source.rtmp.server/hls/stream.m3u8" \ …
Run Code Online (Sandbox Code Playgroud)

youtube video ffmpeg nginx rtmp

2
推荐指数
1
解决办法
7821
查看次数

fengyuanchen jQuery cropper插件 - 最小裁剪验证

我试图使用fengyuanchen jquery cropper插件强制裁剪数据输出的最小大小 - https://github.com/fengyuanchen/cropper

该插件提供两个选项minCropBoxWidth,minCropBoxHeight但这些只能控制屏幕上的实际裁剪框.由于裁剪器内的图像大小可以是任意的(在合理范围内),这不会有助于确保最终输出的大小.它直接足以检索图像的实际大小(它在数据参数中传递给crop函数).我所坚持的是,一旦达到最小宽度/高度值,就会阻止裁剪盒缩小尺寸.我明白了$(this).cropper(...).disable is not a function

$('.image-preview img').cropper({
                    aspectRatio:1/1,
                    strict:true,
                    background:false,
                    guides:false,
                    autoCropArea:1,
                    rotatable:false,
                    minCropBoxWidth:20,//using these just to stop box collapsing on itself
                    minCropBoxHeight:20,
                    crop:function(data){
                        //test the new height/width
                        if(data.height < 120 || data.width < 120){
                            //try to make it stop 
                            $(this).cropper().disable(); //here be the error
                        }else{
                           var json = [
                              '{"x":' + data.x,
                              '"y":' + data.y,
                              '"height":' + data.height,
                              '"width":' + data.width + '}'
                            ].join();
                           $('#image-data').val(json);
                        }
                    }
Run Code Online (Sandbox Code Playgroud)

php jquery image-processing jquery-plugins

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