小编rob*_*más的帖子

如何在Chrome中使用谷歌字体中的Roboto Light/Thin

我在Chrome浏览器中使用Roboto字体时遇到了麻烦..特别是我似乎无法获得Condensed和Thin/Light等字体粗细.我下载了所有3种完整字体:

@import url(https://fonts.googleapis.com/css?family=Roboto:100,100italic,300,300italic,400,400italic,500,500italic,700,700italic,900,900italic&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext,cyrillic-ext,cyrillic,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,latin-ext,greek-ext,greek,vietnamese,cyrillic,cyrillic-ext);
Run Code Online (Sandbox Code Playgroud)

然后我在声明中使用它们:

Roboto Condensed

.mas-1st-col {
font-family: Roboto !important;
font-size: 8pt; !important
font-weight: 200 !important;
font-stretch: condensed !important;
}
Run Code Online (Sandbox Code Playgroud)

Roboto Light

span.f, div.f.kv + div.f.slp {
font-family: Roboto !important;
font-size: 8pt !important;
font-weight: 200 !important;
}
Run Code Online (Sandbox Code Playgroud)

然而,它给我的是简单的Roboto.如果我将"Condensed"更改为使用font-family"Roboto Condensed"它可以正常工作......这是有道理的,因为显然铬很晚才采用font-stretch.但是,将font-family更改为"roboto condensed" 不会使用打火机font-weight(300),它会保持在400.即使我将其更改font-weight为300(具体而言),它仍将保持为400(切换为200,300和400之间的控制台完全没有效果.我必须专门放置"Roboto Condensed Light",以获得轻盈的字体重量.

其他人怎么样?"Roboto Thin"没有专门下载或设置在@font-face......我不应该使用像"roboto thin"这样的名字,当我只想要一个字体 - 重量时,我应该吗?

细节

由于Terry的伟大建议,这里的相关代码基本上是完整的:

    function _miscCSS () {
        var css = function(){/*
@import url(https://fonts.googleapis.com/css?family=Roboto:100,100italic,300,300italic,400,400italic,500,500italic,700,700italic,900,900italic&subset=latin,latin-ext,cyrillic,cyrillic-ext,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext,cyrillic-ext,cyrillic,greek-ext,greek,vietnamese);
@import url(https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,latin-ext,greek-ext,greek,vietnamese,cyrillic,cyrillic-ext);

 ...[css declarations …
Run Code Online (Sandbox Code Playgroud)

css fonts google-chrome

20
推荐指数
2
解决办法
8万
查看次数

intellij idea设置空白node.js项目

我对intellij的想法有点新意.

带有intellij IDEA的node.js项目模板是一个node.js表达项目 - 这很好(你得到的Web服务器连接起来运行你的项目等),但是它里面有各种各样丑陋的东西,比如jade.我只想要一个简单的,没有废话的node.js项目...甚至http都是可选的.

我可以看到想要一个带有基本Web处理的node.js项目,例如:body-parser,cookie-parser,serve-favicon,method-override和morgan(用于http记录) - 但这确实是一个奖励问题/问题再过一天 现在我只想要一个项目模板,然后我可以按下运行并在控制台或其他东西上查看输出.

intellij-idea node.js

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

使用枚举数组反序列化 json

使用枚举:

namespace AppGlobals
{
    [JsonConverter(typeof(JsonStringEnumConverter))]
    public enum BoardSymbols
    {
        [EnumMember(Value = "X")]
        First = 'X',
        [EnumMember(Value = "O")]
        Second = 'O',
        [EnumMember(Value = "?")]
        EMPTY = '?'
    }
}
Run Code Online (Sandbox Code Playgroud)

我想为我的 api 定义一个模型:

using System;
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;
using Newtonsoft.Json;

namespace Assignment_1
{
    public class MyRequest
    {
//...
        [Required]
        [MinLength(9)]
        [MaxLength(9)]
        [JsonProperty("changeTypes", ItemConverterType = typeof(JsonStringEnumConverter))]
        public AppGlobals.BoardSymbols[] GameBoard { get; set; }
    }
}
Run Code Online (Sandbox Code Playgroud)

哪里GameBoard应该序列化为 JSON 作为字符串数组,其名称由EnumMember属性指定。这种方法改编自Deserialize json character as enumeration。然而,它不起作用。如果我将枚举更改为:

    [JsonConverter(typeof(JsonStringEnumConverter))]
    public enum …
Run Code Online (Sandbox Code Playgroud)

c# asp.net json.net asp.net-core-webapi asp.net-core-3.1

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

如何将jquery.com的CDN中的jQuery用于Chrome扩展

我希望jQuery可以在内容脚本和控制台中访问(即,从网页 - 我相信,但我不确定,这就是你使用的原因web_accessible_resources).

注意:我同意下面的Zig Mandel,他说你不应该使用CDN来加载jquery,因为它只能节省少量空间并留下CDN可能关闭的可能性.在这一点上,我只是想知道为什么这不起作用.

为什么这不起作用:

的manifest.json

  "content_scripts": [
    {
  ...
      "js": ["foo.js", "https://code.jquery.com/jquery-1.10.1.min.js", "https://code.jquery.com/jquery-1.10.1.min.map"],
      "run_at": "document_idle",
      "all_frames": true
    }
  ],
  "content_security_policy": "script-src 'self' https://code.jquery.com; object-src 'self'",
  "web_accessible_resources": [ "https://code.jquery.com/jquery-1.10.1.min.js", "https://code.jquery.com/jquery-1.10.1.min.map"],
Run Code Online (Sandbox Code Playgroud)

我加载扩展程序时收到的错误是:

--------------------------- Extension error
--------------------------- Could not load extension from 'C:\Users\[me]\Documents\GitHub\foo'. Could not load
javascript '' for content script.
--------------------------- OK   
---------------------------
Run Code Online (Sandbox Code Playgroud)

当我需要在jQuery的(或一些自定义调试库等)web_accessible_resources与中时content_scripts

控制台使用的回答ExpertSystem

你必须在jQuery中包含一个javascript文件web_accessible_resources,然后注入它.包含jQuery content_scripts仅供扩展中的其他内容脚本使用.如何注入代码(无论是否为本地)的示例:

内容脚本

function inject(script) {
    if (script.match(/^http\:\/\//)){
        var …
Run Code Online (Sandbox Code Playgroud)

jquery cdn google-chrome-extension

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

需要jQuery到Tampermonkey脚本和控制台中的安全变量

通常我使用了以下代码片段,这通常有效:

(function () {
    function main() {
        //...script body...
    }

    var OGloboCSS = { // var could be named anything, appropriate to the page
        addJQuery: function (callback) {
            var script = document.createElement("script");
            script.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js");
            script.addEventListener('load', function () {
                var script = document.createElement("script");
                script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
                document.body.appendChild(script);
            }, false);
            document.body.appendChild(script);
        }
    };

    OGloboCSS.addJQuery(main);

})();
Run Code Online (Sandbox Code Playgroud)

但偶尔我会在https://steamcommunity.com上收到类似这样的错误:

拒绝加载脚本' https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js ',因为它违反了以下内容安全策略指令:"script-src'unsafe-eval ''self''unsafe-inline''unsafe-eval'https: //steamcommunity-a.akamaihd.net/ https://api.steampowered.com/ http://www.google-analytics.com https:/ /ssl.google-analytics.com https://www.google.com https://www.gstatic.com https://apis.google.com ".

解决方案基本上是,您必须使用TamperMonkey的@require头指令,如下所示:

// @require …
Run Code Online (Sandbox Code Playgroud)

javascript jquery google-chrome tampermonkey

10
推荐指数
2
解决办法
3596
查看次数

如何通过AJAX检测网址更改而无需在jQuery中重新加载?

我有一个用户脚本(用于Chrome),我用它来为我设计duolingo的练习页面.它只应用了一行css

jQ(document).ready(function(){
    jQ('#start-button').css({"float": "left", "margin-right": "10em"});
});
Run Code Online (Sandbox Code Playgroud)

这是我第一次来到页面时工作得很好.但他们使用Ajax来避免页面重新加载.并且url 确实发生了变化,因此如果我检测到这一点,我可以刷新css更改而不会丢失此网站导航模式的格式.

有人碰巧知道检测它的好方法吗?

编辑:完整的用户脚本实现了几个首先指出的流行解决方案(这是行不通的):

// ==UserScript==
// @name         duolingo
// @namespace    http://your.homepage/
// @version      0.1
// @description  reformat /skills to not start timed practice by default
// @author       You
// @include      /^https?\:\/\/www\.duolingo\.com\/(skill|practice)?\/?.*/
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
// @grant        none
// ==/UserScript==

window.jQ=jQuery.noConflict(true);

jQ(document).ready(function(){
    style_duolingo();
});
jQ(window).bind('hashchange', function() {
    style_duolingo();
});
jQ(document).ajaxComplete(function() {
    style_duolingo();
});


function style_duolingo() {
    jQ('#start-button').css({"float": "left", "margin-right": "10em"});
    console.log("Tampermonkey script: wrote css change");
}
Run Code Online (Sandbox Code Playgroud)

编辑#2:

赏金奖励

请提供一个不加载外部库的工作解决方案(我想知道我缺少什么,而不是将其保存在黑盒子中),并使用事件解决问题(没有基于间隔的解决方案).如果无法使用事件(奇怪),请提供更正解决方案以及未触发事件的原因.

ajax jquery

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

在孩子中访问父母的ngForm

我有这样的结构:

<form #myForm="ngForm">
  <div class=row>
    <app-section-a [myForm]="myForm"></app-section-a>
Run Code Online (Sandbox Code Playgroud)

和我的孩子组件:

@Component({
...
  viewProviders: [ { provide: ControlContainer, useExisting: NgForm } ]
})
// ...
@Input() myForm: ElementRef;
Run Code Online (Sandbox Code Playgroud)
<input ...>
<button type=submit [disabled]="!myForm.valid">
Run Code Online (Sandbox Code Playgroud)

而且,这可以完美地确保表格中的所有组成部分都被计入有效性。问题是,我认为我不需要直接将 ngForm 的引用作为输入传递。我如何跳过该输入并仍然使其正常工作?

一个细节:恰好是一个 Angular 5 项目。

angular

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

如何在 Python Google Cloud Function 中返回特定状态

我注意到我可以提出或返回,产生 500 或 200 个响应。例如:

def random(request):
    coin = [true, false]
    if random.choice(coin):
        succeed()
    else:
        fail()

def succeed():
    return '{ "status": "success!"}'

def fail():
    raise Exception("failure")
Run Code Online (Sandbox Code Playgroud)

大致类似的东西会产生 500 或 200 的响应。但它不会,例如,让我用身体引发 422 错误。

我可以这样做吗?

python-3.x google-cloud-platform google-cloud-functions

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

如何手动添加到 swagger 的 schemas 部分?

我正在使用 Swashbuckle.AspNetCore 并将此模式部分开箱即用: swagger 模式的屏幕截图

我的响应模式看起来是空的,但实际上我返回了子类。我怎样才能将它们添加到此部分?

我有这个请求模型:

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using static Assignment_1.AppGlobals;

namespace Assignment_1
{
    public class ExecuteMoveRequest: IValidatableObject, ICloneable
    {
        public int? Move { get; set; }

        [Required]
        public BoardSymbol AzurePlayerSymbol { get; set; }

        [Required]
        public BoardSymbol HumanPlayerSymbol { get; set; }

        [MinLength(9)]
        [MaxLength(9)]
        public BoardSymbol[] GameBoard { get; set; }

        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
//...
Run Code Online (Sandbox Code Playgroud)

我将其用于我的响应模型:

using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using static Assignment_1.AppGlobals;

namespace Assignment_1
{ …
Run Code Online (Sandbox Code Playgroud)

c# swagger swashbuckle asp.net-core

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

d3 - "无法在数字'65'上创建属性'vx'"

所以我试图用一些非常简单的json 来展示这个伟大的示例Force-Directed Graph:https://raw.githubusercontent.com/DealPete/forceDirected/master/countries.json

我的工作在这里:codepen

我从d3得到一个永无止境的错误源,一开始没有错误,表明我的代码有问题.它是这样开始的:

XHR finished loading: GET "https://raw.githubusercontent.com/DealPete/forceDirected/master/countries.json".
[...]
d3.min.js:2 Uncaught Error: missing: 0
    at ar (d3.min.js:2)
    at r (d3.min.js:5)
    at Function.e.links (d3.min.js:5)
    at pen.js:46
    at Object.<anonymous> (d3.min.js:7)
    at d.call (d3.min.js:4)
    at XMLHttpRequest.e (d3.min.js:7)
ar @ d3.min.js:2
r @ d3.min.js:5
e.links @ d3.min.js:5
(anonymous) @ pen.js:46
(anonymous) @ d3.min.js:7
call @ d3.min.js:4
e @ d3.min.js:7
d3.min.js:5 Uncaught TypeError: Cannot create property 'vx' on number '66'
    at e (d3.min.js:5)
    at d3.min.js:5
    at Fe.each …
Run Code Online (Sandbox Code Playgroud)

json directed-graph d3.js d3-force-directed

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