小编The*_*uhn的帖子

图标字体未在IE11中加载

我们使用icomoon作为我们的图标字体,它们在Chrome和Firefox中运行良好,但不会在IE11中显示......有时候.它似乎适用于第一页加载,但不适用于后续页面加载.清除缓存似乎没有重置它.这个问题可能出现在其他IE版本中,现在我们只关注IE11.

这是我们的@ font-face:

@font-face {
font-family: 'icon';
src:url('fonts/icon.eot?-3q3vo5');
src:url('fonts/icon.eot?#iefix-3q3vo5') format('embedded-opentype'),
    url('fonts/icon.woff?-3q3vo5') format('woff'),
    url('fonts/icon.ttf?-3q3vo5') format('truetype'),
    url('fonts/icon.svg?-3q3vo5#rezku') format('svg');
font-weight: normal;
font-style: normal;
}

[class^="icon-"], [class*=" icon-"] {
font-family: 'icon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;

/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-alphabet:before {
content: "\e600";
}
/* etc etc etc */
Run Code Online (Sandbox Code Playgroud)

但这里变得奇怪.查看开发人员工具,正在发送字体的HTTP请求,但只接收了几百个字节(可能只是标题).

网络面板

但HTTP响应正确地将内容长度列为几千字节.

响应标头

"响应正文"选项卡只显示"无数据可查看".

您可以在网络面板屏幕截图中看到Google字体的行为不是这样的.

在位置栏中粘贴URL会导致下载完整文件.

css internet-explorer webfonts internet-explorer-11

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

iOS:无法将UISplitViewController推送到UINavigationController

我有一个使用导航控制器的XCode iPad项目.我试图获得一个按钮将UISplitViewController推送到导航堆栈,但是出现了这个错误:

拆分视图控制器无法推送到导航控制器

原来UISplitViewController不能很好地与UINavigationController一起使用.但是,单击此按钮时,我仍需要显示拆分视图控制器.我该怎么做呢?而且,同样重要的是,如何制作一个后退按钮,以便用户可以返回到导航控制器?

uinavigationcontroller uisplitviewcontroller ios ios5

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

金字塔:自定义404页面返回"200 OK"

我在Pyramid应用程序中定义了自定义404视图:

@view_config(context=HTTPNotFound, renderer='404.pt')
def not_found(self, request):
     return {}
Run Code Online (Sandbox Code Playgroud)

它工作正常,除了与内容一起发送的HTTP状态代码是200 OK,这无论如何都不行.403 Forbidden我遇到了同样的问题.如何让Pyramid发送正确的状态代码?

python pyramid

18
推荐指数
2
解决办法
4696
查看次数

Python:通用的getter和setter

TL; DR:必须为每个属性定义一组唯一的getter和setter()'d变量很糟糕.我可以定义通用的getter和setter,并将它们与我想要的任何变量一起使用吗?

假设我用一些不错的getter和setter创建了一个类:

class Foo
    def getter(self):
        return _bar+' sasquatch'

    def setter(self, value):
        _bar = value+' unicorns'

    bar = property(getter, setter)
Run Code Online (Sandbox Code Playgroud)

太好了,对吧?

现在让我们说我放入另一个名为"baz"的变量,我不希望它被这个sasquatch/unicorn乐趣所遗漏.好吧,我想我可以制作另一组getter和setter:

class Foo
    def bar_getter(self):
        return _bar+' sasquatch'

    def bar_setter(self, value):
        _bar = value+' unicorns'

    bar = property(bar_getter, bar_setter)

    def baz_getter(self):
        return _baz+' sasquatch'

    def baz_setter(self, value):
        _baz = value+' unicorns'

    baz = property(baz_getter, baz_setter)
Run Code Online (Sandbox Code Playgroud)

但那不是很干,而且不必要地混乱了我的代码.我想我可以做一点DRYer:

class Foo
    def unicornify(self, value):
        return value+' unicorns'

    def sasquatchify(self, value):
        return value+' sasquatch'

    def bar_getter(self):
        return self.sasquatchify(_bar)

    def bar_setter(self, value):
        _bar …
Run Code Online (Sandbox Code Playgroud)

python

14
推荐指数
3
解决办法
4400
查看次数

Python不等式:!= vs not ==

我今天在编写Python时意识到可以将不等式运算符编写为a!=bnot a==b.这让我很好奇:

  1. 两种方式都表现完全相同,还是存在一些微妙的差异?
  2. 有没有理由使用一个而不是另一个?比另一个更常用吗?

python operators

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

Python:序列化/反序列化datetime.time

我有一个表格,下载时间很多,用datetime.time对象表示.

序列化对象的最佳方法是什么?例如:

<option value="${time.serialize()}">${time.isoformat()}</option>
Run Code Online (Sandbox Code Playgroud)

然后在另一端反序列化它?例如:

time = datetime.time.deserialize(request.params['time'])
Run Code Online (Sandbox Code Playgroud)

python datetime

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

SQLAlchemy ORM 插入前钩子

我试图弄清楚如何在从 ORM 插入一行之前编写一个钩子来查询数据库。我希望实现类似的东西:

class Table(Base):
    id = Column(Integer, primary_key=True)
    value = Column(Integer, nullable=False)

    def before_insert_hook(self, session):
        """Some arbitrary queries and code.  For example:"""
        if self.value is None:
            self.value = session.query(func.avg(Table.value))\
                    .filter(Table.value > 100).scalar()
Run Code Online (Sandbox Code Playgroud)

我一直在阅读有关 ORM 事件等的 SQLAlchemy 文档,但我不知道如何使用它们来实现这一点。

orm sqlalchemy

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

Postgres全文搜索与同义词

我有一个餐馆数据库,我在那里进行全文搜索.代码看起来像这样:

SELECT * FROM restaurant WHERE restaurant.search_vector @@ plainto_tsquery(:terms);
Run Code Online (Sandbox Code Playgroud)

search_vector定义如下:

alter table restaurant add column search_vector tsvector;
create index restaurant_search_index on restaurant using gin(search_vector);
create trigger restaurant_search_update before update or insert on restaurant
    for each row execute procedure
    tsvector_update_trigger('search_vector',
    'pg_catalog.english','title');
Run Code Online (Sandbox Code Playgroud)

现在,这个搜索的一个值得注意的问题是烧烤这个词.它可以拼写不同的方式:烧烤,烧烤,烧烤,烧烤,烧烤等.当有人搜索其中任何一个时,我需要在餐馆搜索所有这些条款.

从我在网上看到的,似乎我需要修改字典(那就是pg_catalog.english,对吗?),但我不知道该怎么做.

postgresql full-text-search

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

并发连接和性能?

我有一个Comet应用程序可能会同时打开许多实例.这意味着许多并发连接.为了克服浏览器并发连接限制,改变连接主机名应该不会太难.我的问题是:平均互联网连接如何公平?我会遇到性能问题吗?

javascript concurrency comet

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

Postgres 时间与时区相等

time with time zone在 Postgres 中遇到了一些问题。 timestamp with time zone等式按我的预期工作,如果在规范化时区后时间相同,则它应该是真的:

postgres=# select '2013-06-27 12:00:00 -0800'::timestamp with time zone = '2013-06-27 14:00:00 -0600'::timestamp with time zone;
 ?column?
----------
 t
Run Code Online (Sandbox Code Playgroud)

但是,这似乎不适用于time with time zone

postgres=# select '12:00:00 -0800'::time with time zone = '14:00:00 -0600'::time with time zone;
 ?column?
----------
 f
Run Code Online (Sandbox Code Playgroud)

然而,不平等如何运作,我希望它们能:

postgres=# select '12:00:00 -0800'::time with time zone < '14:01:00 -0600'::time with time zone;
 ?column?
----------
 t

postgres=# select '12:00:00 -0800'::time with time zone > '13:59:00 -0600'::time …
Run Code Online (Sandbox Code Playgroud)

sql postgresql time timezone

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