所以,我正在阅读John Resig的博客,看到他的微模板javascript引擎,并决定尝试为javascript实现我自己的模板管理系统,以加深我对原型继承的理解.但是,在我开始编写它的那一刻,我遇到了一个问题.
首先,这是我的基本代码:
function template_manager() { };
template_manager.prototype = {
tags: {},
templates: {},
output: {},
default_template: "default",
set: function (tags, template_name) {
template_name = "Greetings!";
//template_name = this._util.template(this.nothing, this.default_template);
console.log(template_name);
},
get: function(tags, template_name) {
console.log("Getting");
},
unset: function(tags, template_name) {
console.log("Removing");
},
render: function(template_name) {
console.log("Rendering");
},
//_util goes here
};
// Take it for a quick test drive.
test = new template_manager;
test.set();
test.get();
test.unset();
test.render();
Run Code Online (Sandbox Code Playgroud)
然后我开始研究一些常用代码,我决定把它放到一个实用程序对象中:
_util: {
// Used to set …Run Code Online (Sandbox Code Playgroud) 我在线阅读有关语义HTML的内容......
语义HTML意味着使用HTML标签来表达其隐含意义,而不仅仅是使用(无意义的)div和span标签来表示绝对的一切.
如果你使用
<h1>的不是<div class="header">,而<h2>替代,等等,谷歌和其他搜索引擎将解释你的头在你的网页是重要的头衔.这样,当用户搜索您的标题和子标题中的字词时,您的网页将被视为更相关(并且排名更高).此外,它更短更清洁.
所以,下面是语义,
<h1>My Website Name</h1>
<h2>My Website Tagline </h2>
Run Code Online (Sandbox Code Playgroud)
下面怎么样?
<div id="header">
<h1><span class="hide">My Website Name</span></h1>
<h2><span class="hide">My Website Tagline</span></h2>
</div>
Run Code Online (Sandbox Code Playgroud)
我倾向于将h标签与上面的div和span标签结合起来 - 这是否被认为是缺乏语义?
我有隐藏类的跨度的原因是我想显示站点徽标而不是文本.因此,使用CSS将h1的背景设置为图像,然后隐藏文本.这是不正确的做法吗?
然后,如果我不使用div,我可以使用什么来围绕h1和h2制作一个盒子?
据我所知,html 5尚未完全准备好,我们一定不能使用,我们必须<header>吗?
谢谢.
我正在玩Spring-Webflow(2.3),ZK(5.0.7.1)和ZK Spring(3.0).
实际上我正试图用Spring-Webflow中描述的HTML链接发出事件信号.
<a href="${flowExecutionUrl}&_eventId=go2ProjectRoomView" >2 Project</a>
Run Code Online (Sandbox Code Playgroud)
我的流程定义文件的一部分如下所示:
<view-state id="mainView">
<transition on="go2ProjectRoomView" to="projectRoomView" bind="false"/>
</view-state>
<view-state id="projectRoomView">
<transition on="go2MainView" to="mainView" bind="false"/>
</view-state>
Run Code Online (Sandbox Code Playgroud)
如果我部署我的Web项目并导航到主视图,则会出现以下错误:
The reference to entity "_eventId" must end with the ';' delimiter
Run Code Online (Sandbox Code Playgroud)
如果我替换_eventId=go2ProjectRoomView为相同的错误_eventId_go2ProjectRoomView.
链接到完整堆栈跟踪.
使用它时出现意外错误。第一部分来自我在网上找到的脚本,我试图用它来提取 PDF 大纲中标识的特定部分。一切正常,除了output.write(outputfile1)它说:
PdfReadError:字典中有多个定义。
还有人遇到这个吗?最后请原谅所有不必要的prints。:)
import pyPdf
import glob
class Darrell(pyPdf.PdfFileReader):
def getDestinationPageNumbers(self):
def _setup_outline_page_ids(outline, _result=None):
if _result is None:
_result = {}
for obj in outline:
if isinstance(obj, pyPdf.pdf.Destination):
_result[(id(obj), obj.title)] = obj.page.idnum
elif isinstance(obj, list):
_setup_outline_page_ids(obj, _result)
return _result
def _setup_page_id_to_num(pages=None, _result=None, _num_pages=None):
if _result is None:
_result = {}
if pages is None:
_num_pages = []
pages = self.trailer["/Root"].getObject()["/Pages"].getObject()
t = pages["/Type"]
if t == "/Pages":
for page in pages["/Kids"]:
_result[page.idnum] = len(_num_pages) …Run Code Online (Sandbox Code Playgroud) 我希望能够interate都list1 = list('asdf')和list2 = list('qwer')在同一时间.什么是最好的方法?
for i, p in list1, list2:
print(i,p)
Run Code Online (Sandbox Code Playgroud)
哪里i会增加list1而且p会增加list2.
我正在尝试创建联系表单以发送电子邮件(from并将to来自用户界面):
try {
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("fromadd");
mail.To.Add("toadd");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail from GMAIL";
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("username","password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
Run Code Online (Sandbox Code Playgroud)
这仅适用于Gmail - 但是,我想让它适用于任何电子邮件提供商 - 我将如何解决这个问题?
测试我的Flask应用程序没有什么问题。我的看法如下:
def prelogin():
email = request.args.get('email')
if not email:
return '', 204
user = User.query.filter({'email': email}).first()
if not user:
return '', 204
address = current_app.config['UPLOADED_PHOTOS_URL']
try:
mongo_photo = pymongo.db.photos.find_one(user.photo)
photo = address + mongo_photo['file']
except (KeyError, AttributeError):
photo = None
return jsonify({
'email': email,
'fullname': user.fullname,
'photo': photo
})
Run Code Online (Sandbox Code Playgroud)
和我的测试功能是这样的:
@patch('arounded.userv2.views.User')
@patch('arounded.userv2.views.pymongo')
def test_valid_prelogin(self, mock_user, mock_pymongo):
user_config = {
'filter.return_value.first.return_value.fullname': 'Someone'
}
mock_user.query.configure_mock(**user_config)
mock_pymongo.db.photos.find_one.return_value = {'file': 'no-photo.png'}
response = self.client.get(
'/api/v2/users/prelogin?email=someone@example.com')
self.assert_status(response, 200)
Run Code Online (Sandbox Code Playgroud)
如果我尝试在测试函数中打印模拟对象,它们将返回正确的值。然而,鉴于我仍然得到:
arounded/userv2/views.py line 40 in prelogin
'photo': …Run Code Online (Sandbox Code Playgroud) 您好,我正在尝试运行文档中的多处理示例:http://docs.python.org/3.4/library/concurrent.futures.html,该示例使用素数但有很小的差异。
我希望能够调用具有多个参数的函数。我正在做的是将小块文本(在大约 30k 长的列表中)与更大的文本块进行匹配,并返回较大字符串中较小字符串的开始位置。
我可以像这样连续执行此操作:
matchList = []
for pattern in patterns:
# Approximate pattern matching
patternStartingPositions = processPattern(pattern, numMismatchesAllowed, transformedText, charToIndex, countMatrix, firstOccurrence, suffixArray)
# Now add each starting position found onto our master list.
for startPos in patternStartingPositions:
matchList.append(startPos)
Run Code Online (Sandbox Code Playgroud)
但我想这样做是为了加快速度:
matchList = []
with concurrent.futures.ProcessPoolExecutor() as executor:
for pattern, res in zip(patterns, executor.map(processPattern(pattern, numMismatchesAllowed, transformedText, charToIndex, countMatrix, firstOccurrence, suffixArray), patterns)):
print('%d is starts at: %s' % (pattern, res))
Run Code Online (Sandbox Code Playgroud)
在这个阶段,我刚刚在那里得到了打印调用,因为我无法得到上面的行,即调用进程的工作。
我想要做的和示例代码之间唯一真正的区别是我的函数需要 7 个参数,但我不知道如何去做,花了半天时间。
上面的调用会生成此错误:
UnboundLocalError:赋值前引用的局部变量“模式”。
这是有道理的。
但是,如果我省略第一个参数(即每次调用时都会更改的参数),并省略函数的第一个参数 …
是否可以使用一个烧瓶应用程序在两个不同端口上路由?我的Flask应用程序需要侦听Webhook,并且由于一些安全事务,它无法在默认端口上接收外部POST请求。有可能做这样的事情吗?
@app.route('/hook/<sourcename>', methods=["POST"], port=5051)
def handle_hook(sourcename):
print 'asdf'
Run Code Online (Sandbox Code Playgroud) 来自官方jinja网站的示例代码:
{% if not standalone %}{% extends 'master.html' %}{% endif -%}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>{% block title %}The Page Title{% endblock %}</title>
<link rel="stylesheet" href="style.css" type="text/css">
{% block body %}
<p>This is the page body.</p>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
据我了解,当standalone为true时,将打印以下代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>{% block title %}The Page Title{% endblock %}</title>
<link rel="stylesheet" href="style.css" type="text/css">
{% block body %}
<p>This is the page body.</p>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
当standalone为false时,会打印出来:
{% if not standalone %} …Run Code Online (Sandbox Code Playgroud)