使用MongoDB文档中的字段ID或_ID有什么区别吗?
我问这个,因为我通常使用"_id",但是我在文档中看到了这种类型({id:-1}):http://www.mongodb.org/display/DOCS/Optimizing+Object+IDs# OptimizingObjectIDs-Sortbyidtosortbyinsertiontime
编辑
事实证明文件是错误的.
这是一个常见的问题,但没有一个解决方案解决了我的问题,所以在这里:
我将ace.js添加到我的rails4应用程序中,所以我做的是
- Added vendor/assets/ace/ace.js
- Created vendor/assets/ace/index.js , with content
//= require ace
- Added the following to my production.rb
config.assets.precompile += %w( index.js )
config.assets.paths << Rails.root.join("vendor", "assets", "ace")
Run Code Online (Sandbox Code Playgroud)
所以在我的布局文件中我有:
<%= javascript_include_tag "ace" %>
Run Code Online (Sandbox Code Playgroud)
它在dev上运行得很好,但是当我运行时:
RAILS_ENV=production bundle exec rake assets:precompile
Run Code Online (Sandbox Code Playgroud)
它不会创建ace文件的摘要版本.
我错过了什么吗?
我试图在xcode,ios中自定义我的TabBar,但是我发现ppl说这不可自定义!另外,我确实找到了某种解决方案,但它们都没有为我工作.
我想要更改UITabBarItem标题(文本)颜色,并更改其中的2个图像,正常图像和所选图像!
我试图在我的UITabBar子视图中迭代,看看我是否找到了什么,但是任何成功:
for (UIView *view in [self.tabBarController tabBar].subviews)
{
NSLog(@"Class: %@",[view class]);
}
Run Code Online (Sandbox Code Playgroud)
这个输出是:
2011-05-18 18:15:24.031 EventApp[52235:207] Class: UIImageView
2011-05-18 18:15:24.032 EventApp[52235:207] Class: UITabBarButton
2011-05-18 18:15:24.032 EventApp[52235:207] Class: UITabBarButton
2011-05-18 18:15:24.033 EventApp[52235:207] Class: UITabBarButton
2011-05-18 18:15:24.033 EventApp[52235:207] Class: UITabBarButton
2011-05-18 18:15:24.034 EventApp[52235:207] Class: UITabBarButton
Run Code Online (Sandbox Code Playgroud)
我无法导入UITabBarButton obj来使用它!
一些解决方案?!我也张贴了一些我看过的链接,但没有用!
编辑
我想做的是像下面这样的想法:

所以我在我的数据库中有一个带有以下shardkey的集合:{cl:"yyyy-mm",user_id:N}
当我执行以下查询
db.collection.find({ cl:"2012-03", user_id:{$in:users}, _id:{"$lt":new ObjectId('4f788b54204cfa4946000044')} }).sort({_id:-1}).limit(5).explain(true)
Run Code Online (Sandbox Code Playgroud)
它给了我这个结果:
"clusteredType" : "ParallelSort",
"shards" : {
"set1/hostname.com:27018" : [
{
"cursor" : "BtreeCursor cl_1_user_id_1 multi",
"nscanned" : 21294,
"nscannedObjects" : 21288,
"n" : 5,
"scanAndOrder" : true,
"millis" : 1258,
"nYields" : 69,
"nChunkSkips" : 0,
"isMultiKey" : false,
"indexOnly" : false,
"indexBounds" : { ...
Run Code Online (Sandbox Code Playgroud)
那么如何才能使用索引进行排序然后我不需要扫描所有21288文档,只返回最后5个?
我在as3中几乎是新手,我带来了一个双重声明,声明'如果'吼叫,做同样的想法?
public function get products(a:Object){
if(a){
// smtg
}
if(null!=a){
// smtg
}
}
Run Code Online (Sandbox Code Playgroud) 在我的网站上,我有一些图像,我在fancybox中显示它们.一切正常,但现在网站的要求是对照片采用全屏模式,全屏我的意思是我想在我的花式框底部添加一个按钮,当用户点击该按钮时,当前图像(fancybox图像)必须以全屏模式显示.
全屏示例:http://buildinternet.com/project/supersized/slideshow/3.2/demo.html
但是这个例子并不适合我的情况因为我仍然需要在全屏模式之前使用fancybox.
所以有人有一些代码可以分享或者一些好的库,我可以做那个集成btw jQuery Fancybox和一些全屏api?谢谢
我最近试图对我的mongodb服务器进行基准测试,我猜它们有点过载,这是serverStatus()的结果:
SECONDARY> db.serverStatus().mem
{
"bits" : 64,
"resident" : 26197,
"virtual" : 161106,
"supported" : true,
"mapped" : 79994,
"mappedWithJournal" : 159988
}
Run Code Online (Sandbox Code Playgroud)
所以,如果我理解正确,MongoDB使用26GB的内存.如果我的服务器有32GB,并且只运行mongoDb,那么获取新服务器并分割我的数据将是一个好主意?
我只是将spring-security-plugin添加到我的grails项目中.一切看起来都很好.但是当我尝试注销时,应用程序会向我显示注销消息,但应用程序仍然已登录!
我的配置文件如下:
// Added by the Spring Security Core plugin:
grails.plugins.springsecurity.useBasicAuth = true
grails.plugins.springsecurity.userLookup.userDomainClassName = 'malibu.server.User'
grails.plugins.springsecurity.userLookup.authorityJoinClassName = 'malibu.server.UserRole'
grails.plugins.springsecurity.authority.className = 'malibu.server.Role'
Run Code Online (Sandbox Code Playgroud)
干杯
我正在尝试做的几乎是创建以下图像:

所以这是一个进度条,它将显示客户在该选项中获得多少票.我怎样才能做到这一点?我想知道我是否可以使用掩码(就像我在flex中那样),但我在网上找到的所有掩码实现都是为UIImages 做掩码,而不是UIImageView.我不能做掩码UIImage,因为这两个图像具有相同的尺寸.我必须使用图像的X和Y来裁剪它们?!那么,有什么建议吗?
以下是我必须创建进度条的两个图像:

干杯.
--- Sharding Status ---
sharding version: { "_id" : 1, "version" : 3 }
shards:
{ "_id" : "set1", "host" : "set1/m1.example.com:27018,mr1.example.com:27018,mrb1.example.com:27018" }
{ "_id" : "set2", "draining" : true, "host" : "set2/m2.example.com:27018,mr2.example.com:27018,mrb2.example.com:27018" }
{ "_id" : "set3", "host" : "set3/m3.example.com:27018,mr3.example.com:27018,mrb3.example.com:27018" }
Run Code Online (Sandbox Code Playgroud)
我错误地从分片群集中删除了set2,它开始排水,我如何停止排水?
我有一个 grails 应用程序,它应该通过 FTP 将一堆图像上传到服务器。为此,我正在使用 commons-net。奇怪的是,如果我为每个文件创建一个新连接,它可以正常工作,但是如果我连接过一次然后开始发送文件,文件就会损坏!下面是我的代码,它可以工作,但我不想为每个文件创建一个新连接:
filesList.each{ f->
String ftpUser = ConfigurationHolder.config.ftp.user
String ftpPassword = ConfigurationHolder.config.ftp.password
String ftpHost = ConfigurationHolder.config.ftp.host
log.debug "ftp> ${ftpUser}@${ftpHost}"
JakartaFtpWrapper ftp = new JakartaFtpWrapper();
ftp.connectAndLogin(ftpHost, ftpUser, ftpPassword)
ftp.setDataTimeout(1000*60*60*5)
log.debug "Welcome message[${ftp.getReplyString()}]"
log.debug "Current Directory[${ftp.printWorkingDirectory()}]";
log.debug "remote dir[${remoteDir}]"
ftp.makeDirectory(remoteDir)
ftp.cwd(remoteDir)
log.debug "uploading file path[${f}]..."
ftp.binary()
ftp.enterLocalPassiveMode()
def input = new FileInputStream(f.getAbsolutePath());
OutputStream output = ftp.storeFileStream(f.getName())
Util.copyStream(input, output);
output.flush()
input.close();
output.close();
ftp.logout();
ftp.disconnect();
}
Run Code Online (Sandbox Code Playgroud)
如果我从每个中删除连接,图像就会损坏!我在这里做错了吗?
编辑**:这个不起作用:
String ftpUser = ConfigurationHolder.config.malibu.ftp.user
String ftpPassword = ConfigurationHolder.config.malibu.ftp.password
String ftpHost = ConfigurationHolder.config.malibu.ftp.host …Run Code Online (Sandbox Code Playgroud) 从Scaling MongoDB一书中:
一般情况
我们可以将其概括为分片键的公式:{coarseLocality:1,search:1}
所以我的问题是,这是正确的吗?不应该是更好写作的对立面?
也来自这本书:
这种模式仍在继续:所有内容将始终添加到"最后"块中,这意味着所有内容都将添加到一个分片中.此分片键为您提供单个,不可分发的热点.
所以说我的应用程序总是按user_id搜索,并在集合中的最后一个条目.
我应该拥有的最好的分片键是什么,这个:
{_id:1, user_id:1}
Run Code Online (Sandbox Code Playgroud)
要么:
{user_id:1,_id:1}
Run Code Online (Sandbox Code Playgroud)