我正在尝试使用依赖于matplotlib和numpy的py2exe创建一个独立的应用程序.应用程序的代码是这样的:
import numpy as np
import pylab as plt
plt.figure()
a = np.random.random((16,16))
plt.imshow(a,interpolation='nearest')
plt.show()
Run Code Online (Sandbox Code Playgroud)
py2exe的设置代码(从http://www.py2exe.org/index.cgi/MatPlotLib修改)是这样的:
from distutils.core import setup
import py2exe
import sys
sys.argv.append('py2exe')
opts = {
'py2exe': {"bundle_files" : 3,
"includes" : [ "matplotlib.backends",
"matplotlib.backends.backend_qt4agg",
"pylab", "numpy",
"matplotlib.backends.backend_tkagg"],
'excludes': ['_gtkagg', '_tkagg', '_agg2',
'_cairo', '_cocoaagg',
'_fltkagg', '_gtk', '_gtkcairo', ],
'dll_excludes': ['libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll']
}
}
setup(console=[{"script" : "matplotlib_test.py"}],
zipfile=None,options=opts)
Run Code Online (Sandbox Code Playgroud)
现在,当bundle_files设置= 3或不存在时,一切正常,但生成的exe无法分发到未配置相同版本的Python等的机器.如果我设置bundle_files = 1,它会创建一个合适的必须包含所有内容的大型exe文件,但无法在本地或分布式运行.在这种情况下,我正在使用Python 2.6.6在Windows 7机器上创建所有内容,并尝试在本地运行并在安装了Python 2.6.4的XP机器上运行.
我在XP机器上运行时遇到的错误看起来很奇怪,因为没有捆绑,我在Win 7上没有错误.通过捆绑,Win 7不会报告回溯信息,所以我无法确定错误是否相同.在任何情况下,这是XP上的错误消息:
Traceback (most recent call last):
File "matplotlib_test.py", line 2, …Run Code Online (Sandbox Code Playgroud) 现在有针对Mongodb和redis的REST apis.
我可以使用我的语言驱动程序连接到这些数据库.
或者我可以使用REST api.我知道REST api更容易理解,更容易从语言转换为语言.但功能较少.
但是,如果我已经使用语言驱动程序做得很好,有没有理由使用其余的api?
谢谢.
我在将Unix时间戳转换为sql server时间戳时遇到问题.
我在excel表中有数据,我将通过工具导入该数据.所以我正在寻找可以将Epoch时间戳转换为sql server时间戳的代码或语法.
我有3个不同的列具有相同的格式.如何更改这些列中的值.
例如:
我有一个我正在研究的2D游戏,它的宽高比为4:3.当我在宽屏显示器上将其切换到全屏模式时,它会拉伸.我尝试使用两个视口给游戏不应该伸展的黑色背景,但这使得游戏的大小与以前相同.我无法让它填满本应举行整个游戏的视口.
如果没有拉伸而没有我需要修改游戏中的每个位置和绘制语句,我怎么能让它全屏?我用于视口的代码如下.
// set the viewport to the whole screen
GraphicsDevice.Viewport = new Viewport
{
X = 0,
Y = 0,
Width = GraphicsDevice.PresentationParameters.BackBufferWidth,
Height = GraphicsDevice.PresentationParameters.BackBufferHeight,
MinDepth = 0,
MaxDepth = 1
};
// clear whole screen to black
GraphicsDevice.Clear(Color.Black);
// figure out the largest area that fits in this resolution at the desired aspect ratio
int width = GraphicsDevice.PresentationParameters.BackBufferWidth;
int height = (int)(width / targetAspectRatio + .5f);
if (height > GraphicsDevice.PresentationParameters.BackBufferHeight)
{
height = GraphicsDevice.PresentationParameters.BackBufferHeight;
width = (int)(height …Run Code Online (Sandbox Code Playgroud) 有业务需要对项目进行分类.最好的想法似乎是将一个列表中的项目拖放到类别列表中.类别数可以变化,因此使用p:dataTable.发送Ajax请求但不从dataTable内部调用onDrop方法.删除数据表和列并静态输出窗口时,会调用onDrop吗?
如何最好地将项目拖放到动态变化的类别中?
<h:form prependId="false">
<h:panelGrid columns="2">
<p:dataTable id="itemstable" value="#{categoryBean.items}" var="item">
<p:column>
<p:outputPanel id="itemrow">
<h:outputText value="#{item}"></h:outputText>
</p:outputPanel>
<p:draggable for="itemrow"></p:draggable>
</p:column>
</p:dataTable>
<p:dataTable value="#{categoryBean.categories}" var="cat">
<p:column>
<p:outputPanel id="cats1">
<h:outputText value="category1"></h:outputText>
</p:outputPanel>
<p:droppable for="cats1"
dropListener="#{categoryBean.onDrop}"
tolerance="pointer"
activeStyleClass="slotActive"
datasource="itemstable">
</p:droppable>
</p:column>
</p:dataTable>
</h:panelGrid>
</h:form>
Run Code Online (Sandbox Code Playgroud) 我在Rails 3上使用以下文件上传器:https://github.com/blueimp/jQuery-File-Upload
客户端的上传工作正常.我可以在Rails日志文件中看到上传文件时发布了以下内容:
Started POST "/attachments/upload" for 127.0.0.1 at Mon Jan 24 14:15:25 -0800 2011
Processing by AttachmentsController#upload as */*
Parameters: {"_http_accept"=>"application/javascript", "authenticity_token"=>"F1h9pvCZL9HUgTjwCIAMc%252BW1cYwx7eBOPwThHfbS5ZU%253D", "file"=>#<ActionDispatch::Http::UploadedFile:0x1076a6d48 @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"joecocker.jpg\"\r\nContent-Type: image/jpeg\r\n", @original_filename="joecocker.jpg", @tempfile=#<File:/var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/RackMultipart20110124-12264-rbtnth-0>>}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我无法将上传的文件保存到Paperclip.
我已经说过:
@attachment = Attachment.create(:attachment => File.open(params[:file].tempfile.path))
@attachment = Attachment.create(:attachment => params[:file].tempfile.path)
Run Code Online (Sandbox Code Playgroud)
并没有工作.Paperclip插入文件附件名称"RackMultipart20110124-12264-rbtnth-0"
有关如何将文件保存到回形针的任何想法/建议?谢谢
我想知道Android是否有与iPhone相似的功能,你可以使用HTML A标签发送短信,方法是将HREF属性设置为你想要发送短信的电话号码,并在其前面添加"短信:" ,即href="SMS:02313213"
我已经环顾四周,似乎找不到任何暗示它可以在Android上使用的东西.
为了研究Hibernate的行为是否与NHibernate的特定使用场景不同,我开始编写基于NHibernate的应用程序相关部分的Java SE和Hibernate端口,但遇到了获取相应SQL Server的实体的问题2008 R2 Express表使用a uniqueidentifier作为主键.
这是映射文件:
<!-- User.hbm.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="hibernatetest.entity.User" table="aspnet_Users">
<id name="Id">
<column name="UserId" sql-type="uniqueidentifier" not-null="true" />
</id>
<!-- ... -->
Run Code Online (Sandbox Code Playgroud)
和相应的POJO定义:
// hibernatetest/entity/User.java
package hibernatetest.entity;
import java.util.UUID;
public class User {
private UUID id;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
//...
Run Code Online (Sandbox Code Playgroud)
主要代码:
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
Session session = sessionFactory.openSession(); …Run Code Online (Sandbox Code Playgroud) 我正在崩溃,因为我的阵列被解除分配,但我不知道为什么或在哪里.该数组来自于这样的东西:
@implementation Sources
- (NSArray *)sourceArray{
NSMutableArray *array = [NSMutableArray array];
//fill array with objects
return (NSArray*)array;
}
@end
Run Code Online (Sandbox Code Playgroud)
然后,在tableview中,我有一个属性,我在其中覆盖getter,如下所示:
- (NSArray *)feedSourceList
{
if (!_sources) {
_feedSourceList = [_sourceList sourceArray];
}
return _sources;
}
Run Code Online (Sandbox Code Playgroud)
然后我像这样调用属性,这会导致崩溃:
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section
{
return [self.feedSourceList count];
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么数组被释放.这是自动释放池在某个我不知道的地方被耗尽了吗?保留这个阵列的正确方法是什么?
我想知道是否有人可以帮忙在mathematica中绘制边长为n的三角形网格(等边)。谢谢。