我正在尝试使用emacs来编辑和运行python程序(在Ubuntu 10.10上使用emacs23和python 2.6).
C-x -C-f)中读到了一个文件C-x o)现在我想在下部窗口的Python解释器的上部窗口中运行Python代码.其他地方建议:
C-c C-c,但这没有任何作用 C-c !,但emacs说该命令未定义我已经安装了ropemacs(sudo apt-get install python-ropemacs),但没有改变任何东西.
我有一个商店列表,需要添加注释.这些注释需要有一个ID,以便可以编辑和删除它们 - 这适用于web应用,其中id参数将包含用于标识对象的字符串.我对MongoDB并不太熟悉,但是认为在地图中使用ObjectId作为关键字,这将是一个简单的解决方案.如果有更好的方法在MongoDB中执行此操作,请更正我.
无论如何,当我尝试使用(new ObjectId())作为键时,我在shell中得到"无效的属性id"错误.
db.locations.update({_id: 'store1'}, {$set: {'notes': {(new ObjectId()): 'note1'}}})
Run Code Online (Sandbox Code Playgroud)
我做错了什么想法?
问:我面临以下大问题:
从时间到另一个我发现以下异常:
Base-64 char数组的长度无效
我使用加密和解密:
public static string Encrypt(string text)
{
try
{
key = Encoding.UTF8.GetBytes(stringKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
Byte[] byteArray = Encoding.UTF8.GetBytes(text);
MemoryStream memoryStream = new MemoryStream();
CryptoStream cryptoStream = new CryptoStream(memoryStream,des.CreateEncryptor(key, IV), CryptoStreamMode.Write);
cryptoStream.Write(byteArray, 0, byteArray.Length);
cryptoStream.FlushFinalBlock();
return Convert.ToBase64String(memoryStream.ToArray());
}
catch (Exception ex)
{
string message = ex.Message;
}
return string.Empty;
}
public static string Decrypt(string text)
{
try
{
key = Encoding.UTF8.GetBytes(stringKey.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
text = text.Replace(" ", "+")
Byte[] …Run Code Online (Sandbox Code Playgroud) 如何使用多个参数调用@selector方法?
我有以下内容
[self performSelector:@selector(changeImage:withString:) withObject:A1 withObject:fileString2 afterDelay:0.1];
Run Code Online (Sandbox Code Playgroud)
但得到一个
无法识别的选择器发送到实例
错误
我打电话的方法如下
-(void) changeImage: (UIButton *) button withString: (NSString *) string
{
[button setImage:[UIImage imageNamed:string] forState:UIControlStateNormal];
}
Run Code Online (Sandbox Code Playgroud) 我有两个使用Devise的模型,我希望视图彼此不同.但是,它只有一个new.html.erb视图等.
如何为每个模型分别显示视图?
谢谢
有什么区别
foreach ($my_array as $my_value) {
}
Run Code Online (Sandbox Code Playgroud)
和:
foreach ($my_array as &$my_value) {
}
Run Code Online (Sandbox Code Playgroud)
?
我可以请你给我两个真实世界的例子,说明何时使用另一个以及何时使用另一个?
我正在使用以下代码在rails 3中设置AJAX操作.代码的AJAX部分似乎有效,但它没有请求正确的文件,我的respond_to为常规HTML提供服务.
路由信息:
resources :zones do
resources :records
end
Run Code Online (Sandbox Code Playgroud)
控制器:
def new
@zone = Zone.new
respond_to do |format|
format.html
format.js
end
end
Run Code Online (Sandbox Code Playgroud)
链接视图(haml):
= link_to 'Add a zone →', new_zone_path, :remote=>true
Run Code Online (Sandbox Code Playgroud)
从link_to生成的HTML(还注意到html实体的失败呈现......但这是另一个问题):
<a href="/zones/new" data-remote="true">Add a zone &#8594;</a>
Run Code Online (Sandbox Code Playgroud)
对于踢,视图/区域的目录列表.我不确定我这样做是否正确,所以我有new.js.rjs和new.rjs.它们都具有相同的内容,但从未被动作拾取.
| `~zones/
| |-_form.html.haml
| |-_record.html.haml
| |-edit.html.haml
| |-index.html.haml
| |-new.html.haml
| |-new.js.rjs
| |-new.rjs
| `-show.html.haml
Run Code Online (Sandbox Code Playgroud)
最后,从我点击链接时的服务器日志:
Started GET "/zones/new" for 127.0.0.1 at Wed Dec 29 00:04:03 -0700 2010
Processing by ZonesController#new as */*
User Load (0.4ms) SELECT "users".* …Run Code Online (Sandbox Code Playgroud) 我正在学习石英,并尝试了一些在控制台应用程序中工作的样本.现在我正在尝试网络应用程序.以下是我的所作所为.
web.xml中
<?xml version="1.0" encoding="UTF-8"?>
<web-app>
<servlet>
<servlet-name>QuartzInitializer</servlet-name>
<display-name> Quartz Initializer Servlet</display-name>
<servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
<load-on-startup>1</load-on-startup>
<init-param>
<param-name>config-file</param-name>
<param-value>quartz.properties</param-value>
</init-param>
<init-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>start-scheduler-on-load</param-name>
<param-value>true</param-value>
</init-param>
</servlet>
</web-app>
Run Code Online (Sandbox Code Playgroud)
quartz.properties
org.quartz.plugin.jobInitializer.class = org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin
org.quartz.plugin.jobInitializer.fileNames = quartz-config.xml
org.quartz.plugin.jobInitializer.failOnFileNotFound = true
org.quartz.plugin.jobInitializer.scanInterval = 10
org.quartz.plugin.jobInitializer.wrapInUserTransaction = false
# Configuring ThreadPool
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 30
org.quartz.threadPool.threadPriority = 5
Run Code Online (Sandbox Code Playgroud)
石英-config.xml中
<?xml version="1.0" encoding="UTF-8"?>
<job-scheduling-data
xmlns="http://www.quartz-scheduler.org/xml/JobSchedulingData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.quartz-scheduler.org/xml/JobSchedulingData http://www.quartz-scheduler.org/xml/job_scheduling_data_1_8.xsd"
version="1.8">
<pre-processing-commands>
<delete-jobs-in-group>*</delete-jobs-in-group> <!-- clear all jobs in scheduler -->
<delete-triggers-in-group>*</delete-triggers-in-group> <!-- clear all triggers …Run Code Online (Sandbox Code Playgroud) 我正在阅读Michele Leroux Bustamante撰写的<学习WCF>.在本书中,当谈到net.tcp协议时,作者只是说TCP.那么net.tcp和着名的TCP协议之间的区别是什么?
和net.msmq,net.pipe一样,净前缀是什么意思?
非常感谢.
我有一个先前的问题,我提供了我的解决方案; 但是,ConcurrentQueue<T>因为我在.Net 3.5上,所以我没有访问权限.我需要Queue<T>允许并发.我读了这个问题,如果一个项目不在队列中并且线程方法试图使项目出列,则似乎存在问题.
我现在的任务是确定是否可以派生自己的并发队列类.这就是我想出的:
public sealed class ConcurrentQueue : Queue<DataTable>
{
public event EventHandler<TableQueuedEventArgs> TableQueued;
private ICollection que;
new public void Enqueue(DataTable Table)
{
lock (que.SyncRoot)
{
base.Enqueue(Table);
}
OnTableQueued(new TableQueuedEventArgs(Dequeue()));
}
// this is where I think I will have a problem...
new public DataTable Dequeue()
{
DataTable table;
lock (que.SyncRoot)
{
table = base.Dequeue();
}
return table;
}
public void OnTableQueued(TableQueuedEventArgs table)
{
EventHandler<TableQueuedEventArgs> handler = TableQueued;
if …Run Code Online (Sandbox Code Playgroud)