我正在运行ember-1.0.0-rc.5并为disqus注释创建了一个视图,我正在传递文章ID.
我的问题是,disqus不知道我何时从一个页面切换到另一个页面.
这是视图代码:
App.DisqusView = Ember.View.extend({
tagName: 'div',
elementId: 'disqus_thread',
didInsertElement: function(){
var root_url = "http://my-root-url.herokuapp.com"
var page_id = this.get('identifier');
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_identifier = "item-" + page_id;
console.log(disqus_identifier);
/ this outputs the correct id/
var disqus_title = "the song title" ;
console.log(disqus_title);
/ this outputs the correct title/
var disqus_url = root_url + '/#/song/' + page_id;
console.log(disqus_url);
/ this outputs the correct url for the page/
var …Run Code Online (Sandbox Code Playgroud) 我试图使用带有车把模板的CKeditor来允许用户在我们的应用程序中自定义消息.
CKEditor做了一些奇怪的事情
它变成了这样:
<table>
<thead>
<tr>
<td>Activity</td>
<td>Quantity</td>
<td>Rate</td>
<td>Amount</td>
</tr>
</thead>
<tbody>
{{line_items}}
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
进入:
{{line_items}}
<table>
<thead>
<tr>
<td>Activity</td>
<td>Quantity</td>
<td>Rate</td>
<td>Amount</td>
</tr>
</thead>
<tbody></tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
然后谷歌搜索引导我config.protectedSource用来保护所有车把.
CKEDITOR.replace('template_body', {
//... other stuff
protectedSource: [
/{{[\s\S]*?}}/g
]
}
Run Code Online (Sandbox Code Playgroud)
此设置可以正确保护车把标签不被移动和移除,但是可以防止它们被查看/编辑!
CKEditor在编辑模式下隐藏受保护的源,并在源模式下显示它!那是一个bug吗?我可以{{}}在编辑器的源模式下看到,但不能在常规模式下看到?
我最近比Ruby项目更频繁地开发节点项目.
我大部分时间都让RubyMine与node和NPM很好地配合,但每次打开一个项目时,事件气泡都会显示,some of the gems required are not installed而我的项目没有Gemfile或者任何文件以.rb
我知道使用支持Ruby的IDE的含义,但我记得它只是WebStorm的重新命名版本,增加了Ruby功能......
我正在尝试使用节点SOAP npm模块(https://github.com/vpulim/node-soap)服务。
var soap = require('soap');
var soapWSDL = "https://webservice.s7.exacttarget.com/etframework.wsdl";
soap.createClient(soapWSDL, function (err, client) {
if (err) {
return callback(err, null);
}
client.setSecurity(new soap.WSSecurity(self.username, self.password));
console.log("describe", client.describe());
console.log("retrieve", client.describe().PartnerAPI.Soap.Retrieve);
});
Run Code Online (Sandbox Code Playgroud)
第一个日志显示了可用的方法...
但是我正在尝试从第二个console.log了解参数所需的确切格式...
更具体地说,当我打电话给client.Retrieve(options,function(e,r){});我时,要求的格式options是什么?
这是两个console.logs的输出
描述:
{ PartnerAPI:
{ Soap:
{ Create: [Object],
Retrieve: [Object],
Update: [Object],
Delete: [Object],
Query: [Object],
Describe: [Object],
Execute: [Object],
Perform: [Object],
Configure: [Object],
Schedule: [Object],
VersionInfo: [Object],
Extract: [Object],
GetSystemStatus: [Object] } } }
Run Code Online (Sandbox Code Playgroud)
检索:
{ input:
{ …Run Code Online (Sandbox Code Playgroud) 我安装了Rubymine的RuboCop,并且rubocop的检查错误正确显示。
运行?+ Alt+ L将代码转换为与rubocop样式冲突的rubymine样式。
例如:
some_array = 10.times.map {|index| index * 3} # rubymine
some_array = 10.times.map { |index| index * 3 } # rubocop
Run Code Online (Sandbox Code Playgroud)
rubocop在行内块内放置空格。我知道的一件事。但是红宝石会自动格式化,没有空格,所以我发现了一些检查通知。
我有一个 CSV 并使用默认的 CSV 库希望将不同的转换器应用于不同的列
标题是:
units_at_warehouse(#integer),
external_id(#string),
released(#date),
list_price_cents(#integer)
Run Code Online (Sandbox Code Playgroud)
我当前正在使用这些选项:
options = {
headers: true,
converters: nil,
header_converters: :symbol
}
CSV.foreach(file, options) do |row|
# current my best option is:
convert_integers(row)
convert_dates(row)
persist(row)#...saving
end
Run Code Online (Sandbox Code Playgroud)
是否可以传入转换器PER列?
就像是:
options = {
headers: true,
header_converters: :symbol,
converters: {
units_at_warehouse: :numeric,
list_price_cents: :numeric,
released: :date
}
}
Run Code Online (Sandbox Code Playgroud) 我正在将一个包含数百行的 CSV 导入到我的 Rails 数据库中。
有时用户想要强制覆盖数据,所以我认为最好销毁所有数据并重新开始。
就像是:
account.catalog_listings.delete_all if should_refresh
CSV.foreach(file, options) do |row|
account.catalog_listings.create!({...rowstuff})
Run Code Online (Sandbox Code Playgroud)
问题是该delete_all行引发 PG 错误
ActiveRecord::StatementInvalid (PG::NotNullViolation: ERROR: null value in column "account_id" violates not-null constraint
DETAIL: Failing row contains (1, null, ... ... ).
: UPDATE "catalog_listings" SET "account_id" = NULL WHERE "catalog_listings"."account_id" = $1):
app/models/catalog_listing.rb:41:in `import_catalog_listings'
app/controllers/accounts_controller.rb:20:in `catalog'
Run Code Online (Sandbox Code Playgroud)
我确实有null: false几个外键字段,但我不明白为什么delete_all要尝试删除外键而不是删除整个记录?
更新 - 当我改变时一切正常:
account.catalog_listings.delete_all if should_refresh
到:
account.catalog_listings.destroy_all if should_refresh
除了destroy遍历每一项并逐一删除:
SQL (0.1ms) DELETE FROM …Run Code Online (Sandbox Code Playgroud) 如何将带有美元金额的字符串转换为"5.32"或"100"等于整数金额,如532或等10000?
我有一个解决方案如下:
dollar_amount_string = "5.32"
dollar_amount_bigdecimal = BigDecimal.new(dollar_amount_string)
cents_amount_bigdecimal = dollar_amount_bigdecimal * BigDecimal.new(100)
cents_amount_int = cents_amount_bigdecimal.to_i
Run Code Online (Sandbox Code Playgroud)
但它似乎很不稳定.我想确定,因为这将是PayPal API的输入.
我也尝试了金钱宝石,但它无法将字符串作为输入.
我无法找到指定 SFTP 身份验证密钥的文档。
想要一些类似的东西:
export SOME_PRIVATE_KEY="$(cat tmp/some-certs/privatekey.pem)"
# then somewhere in the code
private_key = OpenSSL::PKey::RSA.new(ENV['SOME_PRIVATE_KEY'])
Net::SFTP.start(ftp_host, user, key: private_key) do |sftp|
sftp.dir.entries('/path/to/folder').each do |remote_file|
# ...
end
end
Run Code Online (Sandbox Code Playgroud) 我试图用puppeteer评估一个函数,但回调永远不会被触发(我确定主页正在按预期工作).
在主机页面上,监听器的工作方式如下:
DB.when('ready').execute(function(db){
// DB can execute stuff
})
Run Code Online (Sandbox Code Playgroud)
我的puppeteer代码尝试获取准备好的数据库:
try {
const dbhandle = await page.evaluate('DB.when("ready")');
const result = await page.evaluate(db => db.execute, function(images) {
console.log(JSON.stringify(images));
//do stuff with callback
}, dbhandle);
console.log('result', JSON.stringify(result));
} catch (e) {
console.log('evaluate', e);
} finally {
console.log('finally');
}
Run Code Online (Sandbox Code Playgroud)
我没有运气.