我正在编写一个简单的注释观察器,无论何时创建新注释,它都会触发邮件程序.所有相关的代码都在这个要点:https://gist.github.com/c3234352b3c4776ce132
请注意,Notification传递的规格,但CommentObserver因为Notification.new_comment返回失败的规格nil.我发现通过使用它可以获得通过规范:
describe CommentObserver do
it "sends a notification mail after a new comment is created" do
Factory(:comment)
ActionMailer::Base.deliveries.should_not be_empty
end
end
Run Code Online (Sandbox Code Playgroud)
然而,这并不理想,因为它在观察者的规范中测试邮件程序的行为,而我真正想知道的是它正在触发邮件程序.为什么邮件程序会返回nil原始版本的规范?选择此类功能的最佳方法是什么?我正在使用Rails 3和RSpec 2(和Factory Girl,如果这很重要).
我开始在我的应用程序中使用PDO和准备语句,但我对那里的专业人员有一些问题.希望你能帮我!:)
我试图使用python将camel case转换为空格分隔值.例如:
divLineColor - > div Line Color
这条线成功地做到了:
label = re.sub("([A-Z])"," \g<0>",label)
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是simpleBigURL他们应该这样做:
simpleBigURL - >简单的大URL
我不完全确定如何得到这个结果.救命!
这是我尝试过的一件事:
label = re.sub("([a-z])([A-Z])","\g<0> \g<1>",label)
Run Code Online (Sandbox Code Playgroud)
但这会产生奇怪的结果,如:
divLineColor - > divL vineC eolor
我也在想使用它(?!...)可以工作,但我没有运气.
我试图在Postgres数据库中删除一些表.对于其中一些表,我得到一个事务超时(即使它们是空的).
这是我的桌子
CREATE TABLE many_2_many_table (
id integer NOT NULL,
object_1_id integer NOT NULL,
object_2_id integer NOT NULL);
Run Code Online (Sandbox Code Playgroud)
id是主键,object_1_id和object_2_id都是外键.
现在桌子是空的,我想放弃它.Drop和Truncate都给我转换超时.我已经能够放弃它和我的其他postgres环境.超时是30秒后.
我一直在玩Google Appengine,想要检查应用程序是否在本地数据存储区中填充数据.这个文件在哪里?
我有一个站点,当用户登录时,用户名存储在会话变量中,我想知道从这个会话变量中存储的值查询是否安全?
如何更改popup.html的宽度?我试图改变它的div的宽度,但似乎没有效果.
这是我试过的......
<div id='poppingup' style = "min-width: 300px; display:none">
Run Code Online (Sandbox Code Playgroud) 我一直在寻找一种方法来将最大/最小函数添加到JavaScript的Array类中,这似乎是一个已解决的问题:JavaScript:min&max数组值?.但是,当我尝试使用它时,我开始从我的代码中获取错误.事实证明,这种方法不适用于循环.
for(i in myArray) { console.log(i) }prints out 1
2
3
max
min
我可以使用另一种方法吗?
您将如何在以下代码中实现deleteRecords函数:
Example:
type Record struct {
id int
name string
}
type RecordList []*Record
func deleteRecords( l *RecordList, ids []int ) {
// Assume the RecordList can contain several 100 entries.
// and the number of the of the records to be removed is about 10.
// What is the fastest and cleanest ways to remove the records that match
// the id specified in the records list.
}
Run Code Online (Sandbox Code Playgroud) 我想加快数据加载速度.
我使用MySQL 5.5,InnoDB并拥有1M行数据(65Mb文件).这需要5分钟.
什么mysql设置和命令会影响InnoDB的LOAD DATA INFILE的速度?
谢谢.
php ×2
actionmailer ×1
arrays ×1
for-in-loop ×1
go ×1
html ×1
import ×1
innodb ×1
javascript ×1
mysql ×1
pdo ×1
postgresql ×1
python ×1
regex ×1
rspec ×1
slice ×1
timeout ×1