小编Mar*_* M.的帖子

带有图例的字段集右上角的位置图标

我在使以下布局在所有浏览器中看起来都相同时遇到问题:

.wrapper {
  margin-top: 100px;
  position: relative;
  height: 400px;
  width: 400px;
  border: 1px solid black;
}

.icon {
  position: absolute;
  width: 40;
  height: 40px;
  border: 1px solid black;
  background-color: white;
  top: -20px;
  right: 10px;
}
Run Code Online (Sandbox Code Playgroud)
<fieldset class="wrapper">
  <legend>Legendary!</legend>
  <div class="icon">icon</div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

问题是当legend元素存在时,div.icon在firefox上向下拉几个像素,在chrome上向上拉几个像素.当我删除legend元素时,它工作正常,但我不能这样做.关于如何让它在任何地方看起来都一样的想法?

html css

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

使用NEST渗透

我正在为我的查询编制索引,如下所示:

client.Index(new PercolatedQuery
{
    Id = "std_query",
    Query = new QueryContainer(new MatchQuery
    {
        Field = Infer.Field<LogEntryModel>(entry => entry.Message),
        Query = "just a text"
    })
}, d => d.Index(EsIndex));

client.Refresh(EsIndex);
Run Code Online (Sandbox Code Playgroud)

现在,如何使用ES的过滤器功能将传入的文档与此查询进行匹配?说这个领域缺乏NEST文件将是一个巨大的轻描淡写.我尝试使用client.Percolatecall,但它现在已被弃用,他们建议使用搜索api,但不要告诉如何使用percolator ...

我正在使用ES v5和相同版本的NEST lib.

c# elasticsearch nest elasticsearch-percolate

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

如何在gunicorn服务器下为生产配置Django日志记录?

我已经设置了以下日志记录配置:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'formatters': {
        'verbose': {
            'format': '%(asctime)s %(levelname)s [%(name)s:%(lineno)s] %(module)s %(process)d %(thread)d %(message)s'
        }
    },
    'handlers': {
        'console': {
            'level': 'INFO',
            'class': 'logging.StreamHandler',
            'stream': sys.stdout,
            'formatter': 'verbose'
        }
    },
    'loggers': {
        'gunicorn.errors': {
            'level': 'INFO',
            'handlers': ['console'],
            'propagate': True,
        },
    }
}
Run Code Online (Sandbox Code Playgroud)

它似乎根本没有作用。当该标志DEBUG设置True为时,我可以在控制台中看到一些错误。但是,将其设置为时False,我不能。因此,尽管DEBUG以一种方式或其他方式设置了标志,如何将错误记录到控制台?

django logging gunicorn

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

如何在 angular-cli.json 样式部分包含所有 .less 文件?

所以我遇到的问题是每次创建新组件后,我都必须记住将它的.less样式表添加到angular-cli.json文件中。我真正想要的是以某种方式告诉 angular 只重建.lesssrc 中的所有文件。我尝试做这样的事情:

{
    "apps": [
        {
            ...
            "styles": [
                "**/*.less"
            ],
            ...
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

但我得到

module not found error

有什么帮助吗?

javascript angularjs angular-cli

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

联合查询在一列上不同

我希望第二个查询的结果覆盖第一个查询的结果:

SELECT "panel_restaurants_restaurant"."id",
       "panel_restaurants_restaurant"."name",
       "panel_restaurants_restaurant"."logo",
       "panel_restaurants_restaurantfeatures"."currency" AS "currency",
       ST_DistanceSphere(location, ST_GeomFromText('POINT(0.0 0.0)',4326)) AS "distance",
       "panel_meals_meal"."id" AS "meal_id",
       "panel_meals_meal"."status" AS "meal_status",
       "panel_meals_meal"."available_count" AS "available_dishes",
       "panel_meals_meal"."discount_price" AS "discount_price",
       "panel_meals_meal"."normal_price" AS "normal_price",
       "panel_meals_meal"."collection_from" AS "pickup_from",
       "panel_meals_meal"."collection_to" AS "pickup_to",
       "panel_meals_meal"."description" AS "meal_description"
FROM "panel_restaurants_restaurant"
INNER JOIN "panel_restaurants_restaurantfeatures" ON (
    "panel_restaurants_restaurantfeatures"."restaurant_id" = "panel_restaurants_restaurant"."id")
LEFT OUTER JOIN "panel_meals_meal" ON ("panel_restaurants_restaurant"."id" = "panel_meals_meal"."restaurant_id"
                AND "panel_meals_meal"."status" = 0
                AND (
                ("panel_meals_meal"."collection_from" AT TIME ZONE 'Europe/Warsaw')::date = DATE 'today' OR
                ("panel_meals_meal"."collection_from" AT TIME ZONE 'Europe/Warsaw')::date = DATE 'tomorrow'
                )
                AND …
Run Code Online (Sandbox Code Playgroud)

sql postgresql union join coalesce

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

如何使用 pony orm 以多对多关系加载数据?

这是我的实体:

class Article(db.Entity):
    id = PrimaryKey(int, auto=True)
    creation_time = Required(datetime)
    last_modification_time = Optional(datetime, default=datetime.now)
    title = Required(str)
    contents = Required(str)
    authors = Set('Author')


class Author(db.Entity):
    id = PrimaryKey(int, auto=True)
    first_name = Required(str)
    last_name = Required(str)
    articles = Set(Article)
Run Code Online (Sandbox Code Playgroud)

这是我用来获取一些数据的代码:

return left_join((article, author) for article in entities.Article
                 for author in article.authors).prefetch(entities.Author)[:]
Run Code Online (Sandbox Code Playgroud)

无论我是否使用 prefetch 方法,生成的 sql 看起来总是一样的:

SELECT DISTINCT "article"."id", "t-1"."author"
FROM "article" "article"
  LEFT JOIN "article_author" "t-1"
    ON "article"."id" = "t-1"."article"
Run Code Online (Sandbox Code Playgroud)

然后当我迭代结果时,小马正在发出另一个查询(查询):

SELECT "id", "creation_time", "last_modification_time", "title", "contents"
FROM "article"
WHERE …
Run Code Online (Sandbox Code Playgroud)

python sql ponyorm

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

加入并计入sql-alchemy

我有一个如此定义的模型:

class Article(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    authors = db.relationship('Author', secondary=articles_authors, backref=db.backref('articles', lazy='dynamic'))
    tags = db.relationship('Tag', secondary=articles_tags, backref=db.backref('articles', lazy='dynamic'))
    comments = db.relationship('Comment', backref=db.backref('article'), lazy='dynamic')
    creation_time = db.Column(db.DateTime, default=datetime.datetime.utcnow)
    modification_time = db.Column(db.DateTime, default=datetime.datetime.utcnow)
    title = db.Column(db.String(256), nullable=False)
    contents = db.Column(db.Text, nullable=False)
Run Code Online (Sandbox Code Playgroud)

我想创建一个查询,它会给我所有与作者和标签相关联的文章,并且会计算与给定文章相关的评论.这就是我到目前为止所知道的:

Article.query.options(db.joinedload(Article.authors), db.joinedload(Article.tags)).all()
Run Code Online (Sandbox Code Playgroud)

给我带来麻烦的是计数部分 - 我找不到任何关于如何做的例子.那我该怎么做?

编辑:

查询不起作用,但感觉正确的方向:

subquery = db.session.query(Comment.article_id, func.count(Comment.id).label('comments_count'))\
            .group_by(Comment.article_id).subquery()

return db.session.query(Article, subquery.c.comments_count)\
    .outerjoin(subquery, Article.id == subquery.c.article_id)\
    .join(Tag).all()
Run Code Online (Sandbox Code Playgroud)

在这种情况下计数部分工作正常,但我没有得到使用此查询的标签和作者.

EDIT2:

如果它不明显 - 文章和标签之间的关系是多对多的:

articles_tags = db.Table('articles_tags',
    db.Column('tag_id', db.Integer, db.ForeignKey('tag.id')),
    db.Column('article_id', db.Integer, db.ForeignKey('article.id'))
)
Run Code Online (Sandbox Code Playgroud)

文章和作者也是如此.

编辑:

答案:

subquery …
Run Code Online (Sandbox Code Playgroud)

python sqlalchemy

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

在汇编程序中写入文件

我的任务是创建一个程序,将一些字符串写入文件.到目前为止,我想出了这个:

org     100h

mov     dx, text
mov     bx, filename
mov     cx, 5
mov     ah, 40h
int     21h

mov     ax, 4c00h
int     21h

text db "Adam$"
filename db "name.txt",0
Run Code Online (Sandbox Code Playgroud)

但它没有做任何事情.我正在使用nasm和dosbox.

assembly nasm dosbox

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

如何在 aurelia 自定义组件中获取路由参数

我正在 aureliajs 框架中创建一个自定义组件并将其注入一个Router实例:

@inject(Router)
export class Pagination {
    constructor(router) {
        this.router = router;
    }
}
Run Code Online (Sandbox Code Playgroud)

它将与列表视图模型一起使用以设置一些基本的分页。因此,我需要从活动路线中读取当前页码(看起来像:orders/:pageNum。我不知道该怎么做?我的意思是 - 我知道它可能应该放在Pagination附加方法中,但是如何做到这一点:pageNum参数?

javascript aurelia

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

Android:TextInputLayout 总是从顶部留出一些空间

我有这个布局:

<LinearLayout
    android:id="@+id/dialogCentralContent"
    android:gravity="center_horizontal"
    android:layout_width="220dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/phoneNumberInfo"
    android:layout_marginLeft="8dp"
    android:layout_marginRight="8dp"
    android:layout_marginBottom="20dp"
    android:layout_centerHorizontal="true"
    android:orientation="horizontal"
    android:background="@drawable/edittext_white_rounded">

    <EditText
        android:layout_width="0dp"
        android:layout_height="60dp"
        android:layout_weight="1"
        android:gravity="center"
        android:maxLines="1"
        android:inputType="none"
        android:focusable="false"
        android:text="@={dataContext.phonePrefix}"
        style="@style/Widget.App.PurchaseAmountEditText" />

    <android.support.design.widget.TextInputLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        tools:errorEnabled="true"
        app:errorText="@{dataContext.validator.phoneValidation}">

        <android.support.design.widget.TextInputEditText
            android:layout_height="60dp"
            android:layout_width="match_parent"
            android:gravity="center"
            android:maxLines="1"
            android:inputType="phone"
            android:text="@={dataContext.phoneNumber}"
            style="@style/Widget.App.PurchaseAmountEditText" />

    </android.support.design.widget.TextInputLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

它看起来像这样:

在此处输入图片说明

如您所见,第二个EditText渲染得低于第一个。当我在 Android Studio 的可视化编辑器中查看它时,我可以看到TextInputLayout它的顶部有一些可用空间,但是设置paddingTop="0dp"没有改变任何东西。那么如何让这两个EditTexts 以相同的方式呈现呢?

android android-layout

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