有没有办法分析Vim插件?
当我打开一个大的时候,我的MacVim变得越来越慢.py.我知道我可以取消选择所有插件并逐个重新选择以检查哪个插件是罪魁祸首,但有更快的方法吗?
我的dotvim在这里:https://github.com/charlax/dotvim
你如何用mock模拟readonly属性?
我试过了:
setattr(obj.__class__, 'property_to_be_mocked', mock.Mock())
Run Code Online (Sandbox Code Playgroud)
但问题是它然后适用于所有类的实例...这打破了我的测试.
你还有其他想法吗?我不想模拟完整的对象,只有这个特定的属性.
我已经阅读了很多关于NSDecimal,NSNumber,NSNumberDecimal,CFNumber ......它开始对我来说是一种丛林.
基本上,我正在尝试创建一个简单的模型类来处理简单的计算,如下所示:
#import <Foundation/Foundation.h>
@interface Test : NSObject
{
float rate;
float amount;
int duration;
}
- (float)capitalizedAmount;
@end
@implementation Test
- (float)capitalizedAmount {
return (amount*pow((1.0+rate),duration));
}
@end
Run Code Online (Sandbox Code Playgroud)
我想以名字作为字符串来访问这些方法和setter,因为我打算有很多其他类这样的类,我只保留一个字段列表来进行键值编码.
// This is just the desired behavior
// This evidently won't work with the previous class definition
Test *obj = [[Test alloc] init];
[NSNumber numberWithInt:10]
...
float r;
r = [obj performSelector:NSSelectorFromString(@"capitalizedAmount")];
Run Code Online (Sandbox Code Playgroud)
我知道这是不可能的,performSelector:它将返回一个对象,因此它capitalizedAmount应该返回一个对象.我已经阅读NSInvocation了关于comp.lang的Objective-C Faq的相关内容和相关部分.
我也明白我应该使用NSDecimalNumber,但我想知道两件事:
decimalNumberByAdding:吗?使用Python,很容易定义__add__使用运算符和对象.我应该从中获取浮点值NSDecimalNumber …我想知道这是否是最好的解决方案:
osacompile但也有.scptd目录.或者我可以将两个.applescript和.scpt文件置于版本控制之下?
什么是最好的解决方案?
为什么这样做:
# mongo dbname
MongoDB shell version: 1.8.3
connecting to: nextmuni_staging
> db.collection.find()
{ "foo" : "bar" }
> bye
Run Code Online (Sandbox Code Playgroud)
虽然这不起作用:
# mongo localhost/dbname --eval 'db.collection.find()'
MongoDB shell version: 1.8.3
connecting to: localhost/dbname
DBQuery: dbname.collection -> undefined
Run Code Online (Sandbox Code Playgroud)
应该完全相同,不是吗?
谢谢!
检查Django中是否存在模板的最有效方法是什么?我正在考虑捕获TemplateDoesNotExist异常,但也许有更多的Djangoistic方法来做到这一点?
谢谢你的帮助!
基本上,我要做的是擦除CoreData持久存储中的所有数据,然后导入新数据.你会怎么做?似乎最简单的解决方案是调用[NSPersistentStoreCoordinator removePersistentStore:error:]然后删除文件.这是最好的做法吗?它是线程安全的吗?
非常感谢你,
问题0.1:是
我正在尝试更新CoreData持久性存储中的数据.我的用户正在查看包含统计数据的表格视图.我想通过删除所有现有数据,然后导入新数据来更新应用程序.我想显示一个进度视图,告诉用户应用程序没有挂起.
我resetPersistentStore在AppDelegate中添加了以下方法(persistentStoreCoordinator供参考):
// ...
@property (nonatomic, retain, readonly) NSManagedObjectModel *managedObjectModel;
@property (nonatomic, retain, readonly) NSManagedObjectContext *managedObjectContext;
@property (nonatomic, retain, readonly) NSPersistentStoreCoordinator *persistentStoreCoordinator;
// ...
/**
Returns the persistent store coordinator for the application.
If the coordinator doesn't already exist, it is created and the application's store added to it.
*/
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] …Run Code Online (Sandbox Code Playgroud) 我更改了git子模块的提交指针:
% git status
# On branch fix
# Your branch is behind 'origin/fix' by 1 commit, and can be fast-forwarded.
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: app/lib (new commits)
#
no changes added to commit (use "git add" and/or "git commit -a")
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时git checkout,没有任何改变:
% git checkout -- app/lib && …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用CoreData中的迁移功能.我已经关注了Apple文档.我在以下方法中遇到问题:
/**
Returns the managed object model for the application.
If the model doesn't already exist, it is created by merging all of the models found in the application bundle.
*/
- (NSManagedObjectModel *)managedObjectModel {
if (managedObjectModel != nil) {
return managedObjectModel;
}
/*
* NSInvalidArgumentException', reason: '*** -[NSCFArray insertObject:atIndex:]: attempt to insert nil'
* 2010-02-17 16:27:15.338 Patrimoine[3037:207]
*/
managedObjectModel = [[NSManagedObjectModel mergedModelFromBundles:nil] retain];
return managedObjectModel;
}
Run Code Online (Sandbox Code Playgroud)
http://iphonedevelopment.blogspot.com/2009/09/core-data-migration-problems.html上似乎存在同样的问题
然而,我确实选择了Apple建议的方法,使用菜单选项"添加模型版本".
你有什么主意吗?
也许这是一个错误,但无论如何我都在这里发帖.
我在我的本地AppEngine测试服务器上遇到以下问题:
WARNING 2012-01-10 06:08:40,336 rdbms_mysqldb.py:90] The rdbms API is not available because the MySQLdb library could not be loaded.
INFO 2012-01-10 06:08:40,470 appengine_rpc.py:159] Server: appengine.google.com
INFO 2012-01-10 06:08:40,474 appcfg.py:561] Checking for updates to the SDK.
INFO 2012-01-10 06:08:40,990 appcfg.py:574] Update check failed: HTTP Error 404: Not Found
WARNING 2012-01-10 06:08:47,643 dev_appserver.py:3344] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO 2012-01-10 06:08:47,654 dev_appserver_multiprocess.py:638] Running application dev~project_name on port 8080: …Run Code Online (Sandbox Code Playgroud) iphone ×3
python ×3
core-data ×2
git ×2
applescript ×1
cocoa ×1
debugging ×1
django ×1
macvim ×1
mocking ×1
mongodb ×1
objective-c ×1
optimization ×1
unit-testing ×1
vim ×1