我正在使用UltiSnips.
http://www.vim.org/scripts/script.php?script_id=2715
一切正常.让我们说当我输入st<tab>它时插入submit_tag….但如果st<tab>介于其他角色之间,则无法正常工作.
例如: foost<tab>bar
有任何解决这个问题的方法吗?
我有2条记录Foo,id为1和2.两者都是按顺序创建的.请记住,在Postgres中,记录没有固有的顺序.
在Rails控制台中.Foo.first并Foo.last返回最后一条记录.我的印象是Foo.first会返回第一张唱片.
这是捕获.SQL查询看起来像:
SELECT "foos".* FROM "foos" LIMIT 1
SELECT "foos".* FROM "foos" ORDER BY "foos"."id" DESC LIMIT 1
Run Code Online (Sandbox Code Playgroud)
第二个查询(Foo.last)有一个ORDER BY DESC.那么为什么AR没有ORDER BY ASCfor .first?这背后的逻辑是什么?似乎有点"不一致".
我可以通过以下方式轻松解决此问题:Foo.order('id ASC').first相反.但寻找解释.
如何从一个范围返回一系列日期和小时?到目前为止,我尝试过:
(48.hours.ago..Time.now.utc).map { |time| { :hour => time.hour } }.uniq
Run Code Online (Sandbox Code Playgroud)
返回:
[{:hour=>1}, {:hour=>2}, {:hour=>3}, {:hour=>4}, {:hour=>5}, {:hour=>6}, {:hour=>7}, {:hour=>8}, {:hour=>9}, {:hour=>10}, {:hour=>11}, {:hour=>12}, {:hour=>13}, {:hour=>14}, {:hour=>15}, {:hour=>16}, {:hour=>17}, {:hour=>18}, {:hour=>19}, {:hour=>20}, {:hour=>21}, {:hour=>22}, {:hour=>23}, {:hour=>0}]
Run Code Online (Sandbox Code Playgroud)
不理想,因为它每秒迭代一次.这需要很长时间.我收到几条警告信息说:
/Users/Chris/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.2/lib/active_support/time_with_zone.rb:328: warning: Time#succ is obsolete; use time + 1
Run Code Online (Sandbox Code Playgroud)
我试图返回类似的东西:
[{:day => 25, :hour=>1}, {:day => 25, :hour=>2}, {:day => 25, :hour=>3}, {:day => 25, :hour=>4} ... {:day => 26, :hour=>1}, {:day => 26, :hour=>2}, {:day => 26, :hour=>3}, {:day => 26, :hour=>4}]
Run Code Online (Sandbox Code Playgroud) 在本地测试并发性的最佳方法是什么?即我想测试 10 个并发命中。我知道像Blitz这样的服务。但是,我试图找到一种更简单的方法在本地进行测试以测试竞争条件。
有任何想法吗?也许通过 Curl?
您何时在命名空间上使用子域?即http://admin.foo.com VS http://foo.com/admin
或者,我也喜欢api.foo.com看起来像VS foo.com/api.我也发现,子域设置有点棘手.
在http://www.rethinkdb.com/docs/data-modeling/,声明:
由于之前的限制,最好将posts数组的大小保持为不超过几百个文档.
如果我打算保留90天(3个月)的统计数据,并且每个日期可能包含大约10个地区的嵌入式数组.这意味着90*10 = 900.900不完全是几百.
但MongoDB关系中的相关问题是:嵌入还是引用?表明MongoDB的限制为16mb,这意味着能够托管3000万条推文或大约250,000个典型的Stackoverflow问题作为嵌入式文档.好多啊!
但是,那就是MongoDB.RethinkDB每个文档的限制为10mb.哪个应该还是相当高的.RethinkDB的文档可能存在缺陷.或者还有另一个特定的原因(未解释)为什么Rethinkdb建议只将它保持在几百个嵌入式阵列中,即使10mb可以明显地保持更多.
我所指的架构的粗略概念:
DailyStat::Campaign
[
{
id: '32141241dkfjhjksdlf',
days_remaining: 26,
status: 'running',
dates: [
{
date: 20130926,
delivered: 1,
failed: 1,
clicked: 1,
top_regions: [
{ region_name: 'Asia', views: 10 },
{ region_name: 'America', views: 10 },
{ region_name: 'Europe', views: 10 },
{ region_name: 'Africa', views: 10 },
{ region_name: 'South East Asia', views: 10 },
{ region_name: 'South America', views: 10 },
{ …Run Code Online (Sandbox Code Playgroud) 我在我的model钩子里使用RSVP.hash .但是我需要我的路线来加载基于url(包含动态段)的动态数据.即this.route('foo', {path: ':id'}).
所以我决定将一些东西移出afterModel钩子.
但是,我需要执行商店params(用于分页):
model(params) {
this.set('params', params);
return this.store.findRecord('foo', params.foo_id);
},
afterModel: function(model) {
console.log(this.get('params')); // logs the right params
let params = this.get('params');
// This store query needs access to params
this.store.query('bar', { filter: { 'foo-id': model.get('id') }, page: { number: (params.page ? params.page : 1) } }).then(bars => {
this.controller.set('bars', bars);
});
}
setupController(controller, model) {
this._super(controller, model);
this.set('bars', bars);
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我有这个,它有效:
model(params) {
this.set('params', params);
... …Run Code Online (Sandbox Code Playgroud) 到目前为止,我目前的HABTM实现工作:has_and_belongs_to_many.通知和隐私都继承自Preference.偏好是STI.我想尝试使用:has_many,:通过关联代替.
模型文件
class User < ActiveRecord::Base
has_and_belongs_to_many :preferences
end
class Preference < ActiveRecord::Base
has_and_belongs_to_many :users
end
class Notification < Preference
end
class Privacy < Preference
end
Run Code Online (Sandbox Code Playgroud)
迁移文件
class UsersHaveAndBelongToManyPreferences < ActiveRecord::Migration
def self.up
create_table :preferences_users, :id => false do |t|
t.references :preference, :user
t.timestamps
end
end
def self.down
drop_table :preferences_users
end
end
class CreatePreferences < ActiveRecord::Migration
def self.up
create_table :preferences do |t|
t.string :title
t.text :description
t.string :type
t.timestamps
end
end
def self.down
drop_table :preferences
end
end
class DeviseCreateUsers < …Run Code Online (Sandbox Code Playgroud) 我有一些关于水豚的问题.我不妨在这里问一下,因为Capybara的github页面中的RDOC 非常适合设置和运行.但是API或可用方法列表在哪里?
第一.Per*_spec.rb文件应该scenario只存在一次?或者scenario在一个文件中有多个?
例如,在spec/request/user_spec.rb:
require 'spec_helper'
feature 'User actions' do
background do
data = {
:first_name => 'foo',
:last_name => 'bar',
...
}
user = User.new(data, :as => :user)
user.save
end
scenario 'User can browse home page' do
visit root_path
page.should have_content('Homepage')
end
scenario 'User should not be able to visit the dashboard' do
visit dashboard_root_path
page.should have_content('You are not authorized to access this page.')
end
end
Run Code Online (Sandbox Code Playgroud)
如果上面的代码结构有任何问题,或者还有改进的余地.我是公开反馈.
第二.我注意到上面的代码.如果我config.use_transactional_fixtures …
我需要一张世界地图,并能够突出显示地图的某些部分.
因此,当我执行(通过js)时US,它应该在世界地图中突出显示美国大陆.其他国家也是如此.我应该开始/看的任何想法?
我需要一个简单的平面地图.因此,没有太多复杂的连接到谷歌地图的API.
谷歌搜索并发现了这个:http://davidlynch.org/projects/maphilight/docs/demo_world.html
http://ammap.com/看起来也很有趣,但是在Flash中.如果有一个javascript版本会很棒.
还有其他值得一提的选择吗?
activerecord ×1
capybara ×1
concurrency ×1
ember-cli ×1
ember.js ×1
jquery ×1
macvim ×1
mongodb ×1
nosql ×1
postgresql ×1
rethinkdb ×1
rspec ×1
ruby ×1
testing ×1
ultisnips ×1
vim ×1
vim-plugin ×1