我正在生成一个使用内部样式表的html电子邮件,即
<!doctype html>
<html>
<head>
<style type="text/css">
h2.foo {color: red}
</style>
</head>
<body>
<h2 class="foo">Email content here</foo>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在Gmail中查看时,似乎忽略了内部样式表中的所有样式.Gmail似乎忽略了除内联规则之外的所有样式,例如
<h2 style="color: red">Email content here</foo>
Run Code Online (Sandbox Code Playgroud)
这是我在使用Gmail查看时设置HTML电子邮件样式的唯一选项吗?
最近我在尝试使用Djang与Django时遇到了麻烦.我用这种方式安装了hstore:
$ sudo -u postgres psql
postgres=# CREATE EXTENSION hstore;
WARNING: => is deprecated as an operator name
DETAIL: This name may be disallowed altogether in future versions of PostgreSQL.
CREATE EXTENSION
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
---------+---------+------------+--------------------------------------------------
hstore | 1.0 | public | data type for storing sets of (key, value) pairs
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(2 rows)
Run Code Online (Sandbox Code Playgroud)
并天真地认为我的新数据库将包括hstore.情况并非如此:
$ createdb dbtest …Run Code Online (Sandbox Code Playgroud) 开发一个Django Web应用程序,我有一个我需要在virtualenv中安装的软件包列表.说:
Django==1.3.1
--extra-index-url=http://dist.pinaxproject.com/dev/
Pinax==0.9b1.dev10
git+git://github.com/pinax/pinax-theme-bootstrap.git@cff4f5bbe9f87f0c67ee9ada9aa8ae82978f9890
# and other packages
Run Code Online (Sandbox Code Playgroud)
最初我在开发过程中一个接一个地手动安装它们.这安装了所需的依赖项,我最终pip freeze在部署应用程序之前使用了它.
问题是,当我升级一些软件包时,一些依赖项不再使用也不需要,但它们仍然被列出pip freeze.
现在,我想以这种方式建立一个新的virtualenv:
manual-requirements.txtpip install -r manual-requirement.txt(←问题,这不会安装依赖项)pip freeze -r manual-requirements.txt > full-requirements.txt没有手动在新的virtualenv中重新安装软件包来获取它们的依赖关系的任何方法吗?这很容易出错,我希望自动化从不再需要的旧依赖项中清除virtualenv的过程.
编辑:实际上,pip 会安装未在需求文件中明确列出的依赖项,即使文档告诉我们这些文件是扁平的.关于我希望安装哪些依赖项我错了.我会让这个问题让任何人对pip没有安装所有依赖项有疑问.
有一个div和一个h1内部的部分,我如何浮动右上角的div而不重叠标题的文本?
HTML代码如下:
<section>
<h1>some long long long long header, a whole line, 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6</h1>
<div><button>button</button></div>
</section>
Run Code Online (Sandbox Code Playgroud)
我尝试了相对于父级的绝对位置,但文本重叠,http://jsfiddle.net/FnpS8/2/

使用这个CSS代码:
section { position: relative; }
h1 { display: inline; }
div {
position: absolute;
top: 0;
right: 0;
}
Run Code Online (Sandbox Code Playgroud)
我尝试将div浮动到右边,但它不会保留在右上角,http://jsfiddle.net/P6xCw/2/

使用这个CSS代码:
h1 { display: inline; }
div { float: right; }
Run Code Online (Sandbox Code Playgroud)
我知道有很多类似的问题,但我找不到解决这个问题的人.
我尝试使用这个很好的教程使用django-hstore .我在South管理的现有应用中添加了两个类:
class Attribute(models.Model):
name = models.CharField(max_length=200, verbose_name=_("name"))
description = models.CharField(max_length=1000, verbose_name=_("description"))
class Measure(models.Model):
attribute = models.ForeignKey(Attribute)
data = hstore.DictionaryField(db_index=True)
objects = hstore.HStoreManager()
Run Code Online (Sandbox Code Playgroud)
做了一个schemamigration --auto,启动了迁移并得到了一个django.db.utils.DatabaseError: type "hstore" does not exist.
好吧,tuto似乎不完整,django-hstore 文档告诉我使用自定义数据库后端,我将以下内容添加到我的设置文件中:
DATABASES['default']['ENGINE'] = 'django_hstore.postgresql_psycopg2'
Run Code Online (Sandbox Code Playgroud)
后来我有一个KeyError: 'default'在south/db/__init__.py", line 78.此时,intertubes +一些试验/错误将我指向SOUTH_DATABASE_ADAPTERS设置变量,我在设置中添加了以下内容:
SOUTH_DATABASE_ADAPTERS = {'default': 'south.db.postgresql_psycopg2'}
Run Code Online (Sandbox Code Playgroud)
新错误:
File ".../psycopg2/extras.py", line 769, in register_hstore
"hstore type not found in the database. "
psycopg2.ProgrammingError: hstore type not found in the database. …Run Code Online (Sandbox Code Playgroud) 我刚刚创建了一个代理模型,并且惊讶于manage.py makemigrations创建了一个带有migrations.CreateModel操作的新迁移文件.
代理模型不会创建新的数据库表,它只是同一数据集的不同python接口,并且实际上不manage.py sqlmigrate my_app_label 0042返回任何内容.
我认为它可能用于创建代理模型,ContentType但如果它们不存在则按需创建.
它是否用于触发代理模型权限的创建?代理模型权限有一个6岁的开放式bug,所以我不确定这个部分应该如何工作...
它用来Django 1.8测试这个.
编辑:澄清一下,Django创建一个对新代理模型没有任何作用的迁移,所以Django如果它没有用,我们不想在第一时间创建迁移吗?
是否存在迁移有用的用例?
以下C文件使用emscripten编译为wasm:
int counter = 100;
int count() {
counter += 1;
return counter;
}
Run Code Online (Sandbox Code Playgroud)
$ emcc counter.c -o counter.wasm -s WASM=1 -s SIDE_MODULE=1
Run Code Online (Sandbox Code Playgroud)
没有问题.然后我让webpack加载wasm文件(使用wasm-loader)作为UInt8Array:
var buffer = new ArrayBuffer(648);
var uint8 = new Uint8Array(buffer);
uint8.set([0,97,115,109,1,0,0,0,0,12,6,100,121,108,105,110,107,144,128,192,2,0,1,150,128,128,128,0,5,96,1,127,0,96,1,127,1,127,96,0,1,127,96,2,127,127,0,96,0,0,2,179,129,128,128,0,10,3,101,110,118,14,68,89,78,65,77,73,67,84,79,80,95,80,84,82,3,127,0,3,101,110,118,13,116,101,109,112,68,111,117,98,108,101,80,116,114,3,127,0,3,101,110,118,5,65,66,79,82,84,3,127,0,3,101,110,118,10,109,101,109,111,114,121,66,97,115,101,3,127,0,3,101,110,118,9,116,97,98,108,101,66,97,115,101,3,127,0,6,103,108,111,98,97,108,3,78,97,78,3,124,0,6,103,108,111,98,97,108,8,73,110,102,105,110,105,116,121,3,124,0,3,101,110,118,18,97,98,111,114,116,83,116,97,99,107,79,118,101,114,102,108,111,119,0,0,3,101,110,118,6,109,101,109,111,114,121,2,0,128,2,3,101,110,118,5,116,97,98,108,101,1,112,0,0,3,137,128,128,128,0,8,1,2,0,3,3,2,4,4,6,242,128,128,128,0,20,127,1,35,0,11,127,1,35,1,11,127,1,35,2,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,124,1,35,5,11,124,1,35,6,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,127,1,65,0,11,124,1,68,0,0,0,0,0,0,0,0,11,127,1,65,0,11,125,1,67,0,0,0,0,11,125,1,67,0,0,0,0,11,127,0,65,0,11,7,184,128,128,128,0,4,6,95,99,111,117,110,116,0,6,18,95,95,112,111,115,116,95,105,110,115,116,97,110,116,105,97,116,101,0,8,11,114,117,110,80,111,115,116,83,101,116,115,0,7,8,95,99,111,117,110,116,101,114,3,26,9,129,128,128,128,0,0,10,190,129,128,128,0,8,173,128,128,128,0,1,1,127,2,64,35,10,33,1,35,10,32,0,106,36,10,35,10,65,15,106,65,112,113,36,10,35,10,35,11,78,4,64,32,0,16,0,11,32,1,15,0,11,0,11,133,128,128,128,0,0,35,10,15,11,134,128,128,128,0,0,32,0,36,10,11,141,128,128,128,0,0,2,64,32,0,36,10,32,1,36,11,11,11,146,128,128,128,0,0,35,12,65,0,70,4,64,32,0,36,12,32,1,36,13,11,11,161,128,128,128,0,1,4,127,2,64,35,10,33,3,35,3,65,0,106,40,2,0,33,0,32,0,65,1,106,33,1,32,1,15,0,11,0,11,133,128,128,128,0,1,1,127,1,11,152,128,128,128,0,0,2,64,35,3,65,16,106,36,10,35,10,65,128,128,192,2,106,36,11,16,7,11,11,11,135,128,128,128,0,1,0,35,3,11,1,100,]);
Run Code Online (Sandbox Code Playgroud)
我的JS代码然后调用以下内容:
import Counter from './wasm/counter'
const counter = new Counter();
Run Code Online (Sandbox Code Playgroud)
并且在实例化时失败并出现以下错误:
LinkError: import object field 'DYNAMICTOP_PTR' is not a Number
Run Code Online (Sandbox Code Playgroud)
wasm-loader使用以下默认选项(importObject)WebAssembly.Instance(module, importObject):
{
'global': {},
'env': {
'memory': new Memory({initial: 10, limit: 100}),
'table': new Table({initial: 0, element: 'anyfunc'})
}
} …Run Code Online (Sandbox Code Playgroud) 在回答了有关如何解析包含浮点数组的文本文件的问题之后,我运行了以下基准测试:
import timeit
import random
line = [random.random() for x in range(1000)]
n = 10000
json_setup = 'line = "{}"; import json'.format(line)
json_work = 'json.loads(line)'
json_time = timeit.timeit(json_work, json_setup, number=n)
print "json: ", json_time
ast_setup = 'line = "{}"; import ast'.format(line)
ast_work = 'ast.literal_eval(line)'
ast_time = timeit.timeit(ast_work, ast_setup, number=n)
print "ast: ", ast_time
print "time ratio ast/json: ", ast_time / json_time
Run Code Online (Sandbox Code Playgroud)
我多次运行此代码并始终得到这样的结果:
$ python json-ast-bench.py
json: 4.3199338913
ast: 28.4827561378
time ratio ast/json: 6.59333148483
Run Code Online (Sandbox Code Playgroud)
我经常不得不从a重新创建虚拟环境requirements.txt,我已经在使用了$PIP_DOWNLOAD_CACHE.它仍然需要很多时间,我注意到以下几点:
Pip在以下两行之间花费了大量时间:
Downloading/unpacking SomePackage==1.4 (from -r requirements.txt (line 2))
Using download cache from $HOME/.pip_download_cache/cached_package.tar.gz
Run Code Online (Sandbox Code Playgroud)
像平均约20秒决定它将使用缓存包,然后安装很快.这是很多时候你必须安装几十个包(实际上足以写这个问题).
后台发生了什么?它们是针对在线包的某种完整性检查吗?
有没有办法加快速度?
编辑:看:
time pip install -v Django==1.4
Run Code Online (Sandbox Code Playgroud)
我明白了:
real 1m16.120s
user 0m4.312s
sys 0m1.280s
Run Code Online (Sandbox Code Playgroud)
完整的输出在这里http://pastebin.com/e4Q2B5BA.看起来pip花了他的时间寻找有效的下载链接,而它已经有一个有效的缓存http://pypi.python.org/packages/source/D/Django/Django-1.4.tar.gz.
有没有办法先查找缓存,如果版本匹配则停在那里?
阅读完全手动Mercurial合并后,我有这样一个.hgrc:
[ui]
merge = meld
[merge-tools]
meld.priority = 1
meld.premerge = False
meld.args = $local $other $base
[merge-patterns]
** = meld
Run Code Online (Sandbox Code Playgroud)
然而,hg merge -r REV只是工作,我没有得到我所缺少的...
我想进行手动合并以删除其他分支引入的一些更改.另一个分支有一个影响几个文件的变更集,我不想全部修改它们.
拥有以下型号:
from django_hstore import hstore
from django.db import models
class Item(VoteModel):
data = hstore.DictionaryField(db_index=True)
objects = hstore.HStoreManager()
Run Code Online (Sandbox Code Playgroud)
就像是:
Item.objects.extra(select={"key": "content_item.data -> 'key'"}).aggregate(Count('key'))
Run Code Online (Sandbox Code Playgroud)
不起作用,参见 在Django Query中使用.extra(select = {...})引入的值上使用.aggregate()?和https://code.djangoproject.com/ticket/11671.
有效的原始SQL如下:
SELECT content_item.data -> 'key' AS key, count(*) FROM content_item GROUP BY key;
key | count
-----------+-------
value1 | 223
value2 | 28
value3 | 31
(3 rows)
Run Code Online (Sandbox Code Playgroud)
如何通过Django的ORM获得相同的结果?
供参考:
Item.objects.extra(select={"key": "content_item.data -> 'key'"})
Run Code Online (Sandbox Code Playgroud)
翻译为:
SELECT (content_item.data -> 'key') AS "key", "content_item"."id", "content_item"."data" FROM "content_item"
Run Code Online (Sandbox Code Playgroud) 我在Bitbucket上有一个现有的Django应用程序,我可以部署到Heroku whithhg-git.每当我想在我的app文件夹中运行一些heroku命令时,我会收到以下错误:
$ heroku ps
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
$ heroku logs
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
etc.
Run Code Online (Sandbox Code Playgroud)
目前的解决方法是指定应用程序名称:heroku ps --app <app name>但我正在寻找一种方法将我的存储库名称链接到远程Heroku应用程序名称,就像使用git完成它一样.
我现在无法将我的应用程序移动到github.
python ×6
django ×4
hstore ×3
css ×2
mercurial ×2
pip ×2
postgresql ×2
benchmarking ×1
deployment ×1
emscripten ×1
gmail ×1
heroku ×1
hg-git ×1
html ×1
html-email ×1
html5 ×1
javascript ×1
json ×1
meld ×1
merge ×1
orm ×1
parsing ×1
psycopg2 ×1
sql ×1
virtualenv ×1
webassembly ×1