小编ray*_*ray的帖子

找到2D三角形的中心?

我已经获得了一个带有x和y坐标的2D三角形的结构,一个旋转变量,等等.从那些x和y坐标创建的点,我应该在点周围绘制一个三角形并使用旋转变量适当地旋转它.

我熟悉使用GL_TRIANGLES在OpenGl中绘制三角形.我的问题是以某种方式提取三角形的中间并在其周围绘制顶点.

编辑:是的,我要找的是质心.

c opengl geometry rotation

19
推荐指数
2
解决办法
3万
查看次数

为什么我在类路径中有不同版本的Kotlin JAR?

我决定在AS 3.0中的现有Java Android项目中添加几个Kotlin文件.

一旦我添加了Kotlin文件,我就让助手在我的build.gradle文件中添加相应的行,特别是:

project build.gradle

buildscript {
    ext.kotlin_version = '1.2.21'
    //...
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Run Code Online (Sandbox Code Playgroud)

app build.gradle

// top of file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
//....
dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
Run Code Online (Sandbox Code Playgroud)

不幸的是,所有构建现在都会产

Warning:Runtime JAR files in the classpath should have the same version. These files were found in the classpath:
/Users/sddsfsd/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-jdk7/1.2.21/88bfff5aa470143a83b0bc5ec00c0be8cabd7cad/kotlin-stdlib-jdk7-1.2.21.jar (version 1.2)
/Applications/Android Studio.app/Contents/gradle/m2repository/org/jetbrains/kotlin/kotlin-stdlib-jre7/1.1.51/kotlin-stdlib-jre7-1.1.51.jar (version 1.1)
/Users/sddsfsd/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.2.21/d64187eb2d9d1521be3421aa8c6774a8625cdde8/kotlin-stdlib-1.2.21.jar (version 1.2)
Run Code Online (Sandbox Code Playgroud)

为什么Android Studio在类路径中有自己的旧版Kotlin?我该如何删除它?

android kotlin android-studio

8
推荐指数
1
解决办法
4316
查看次数

Perl:从文件中的每一行抓取第n个和第m个分隔的单词

由于在Nagios中添加要监视的主机的繁琐方式(它需要定义主机对象,而不是之前只需要IP和主机名的程序),我认为最好自动执行此操作,并且它这是学习Perl的好时机,因为目前我所知道的只有C/C++和Java.

我读的文件如下所示:

xxx.xxx.xxx.xxx hostname #comments. i.dont. care. about
Run Code Online (Sandbox Code Playgroud)

我想要的只是前2个字符串.这些显然是空间划界的,但为了一般性,它也可能是任何东西.为了使它更通用,为什么不是第一个和第三个,或第四个和第十个?当然必须有一些正则表达式的行动,但我暂时不会留下那个标签,以防万一.

regex perl file-io

7
推荐指数
4
解决办法
1万
查看次数

这些矩阵模式之间有什么区别?

GL_PROJECTION and GL_MODELVIEW.

我知道还有其他人,但从概念上讲,我无法弄清楚它们之间的区别.在设置模式后加载单位矩阵时,基于模式的单位矩阵有何不同?

theory opengl

7
推荐指数
1
解决办法
3938
查看次数

枚举 Mac Keychain 中的所有证书并比较创建/到期日期

我正在尝试编写一个脚本,该脚本将列出钥匙串中所有已安装的证书,并将它们与来自 Apple 开发门户的证书的创建/到期日期进行比较。

我已经查看了security( https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/security.1.html ) 和的文档openssl,但我似乎无法通过证书从一个到另一个。

另一种方法是Security.framework直接使用,但我没有看到任何明显的方法来转储证书的创建/到期日期。

任何指导?

macos keychain code-signing-certificate

6
推荐指数
1
解决办法
6123
查看次数

Xcode 6.3/iOS 8.3中的新功能:使用self alloc方便构造函数会导致构建错误

此代码在Xcode 6.2和6.3之间没有变化,但[self alloc]现在包含的行会导致错误:

Multiple methods named 'initWithType:' found with mismatched result, parameter type or attributes

@implementation AGNetworkDataRequest

+ (instancetype)networkDataRequestWithType:(AGNetworkDataRequestType)type
{
    AGNetworkDataRequest *r = [[self alloc] initWithType:type];//error here
    return r;
}

- (id)initWithType:(AGNetworkDataRequestType)type
{
    //typical init code
}

//...
Run Code Online (Sandbox Code Playgroud)

如果我Cmd +点击了这个initWithType:电话,我会看到冲突CAEmitterBehavior,我们项目中没有引用的对象,但我猜测必须是iOS 8.3中的新功能.

如果我更改了[self alloc]to [AGNetworkRequest alloc],继承此方法的子类将只返回父对象,这与我们设计此类的方式相反.

如何在不更改方法名称的情况下消除冲突(这需要更改整个应用程序中的所有方法调用)?

objective-c subclassing ios xcode6.3

5
推荐指数
1
解决办法
1243
查看次数

使用 Cocoapods 时如何包含我自己的 xcconfigs?

有没有办法在Cocoapods 生成Podfilexcconfig文件中指定一个文件#include

是否有公开的方法/变量来附加这个,#include或者我是否需要阅读生成的内容xcconfig并用附加文本反刍它?

例如,在生成的Pods-SomeTarget.[configuration].xcconfig,我想看到:

#include "my_other_config.xcconfig" //<-- I want this to be inserted

FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_ROOT}/Crashlytics" "${PODS_ROOT}/Fabric" "${PODS_ROOT}/Google-Mobile-Ads-SDK/Frameworks" "${PODS_ROOT}/GoogleAds-IMA-iOS-SDK-For-AdMob/GoogleInteractiveMediaAds/GoogleInteractiveMediaAds-GoogleIMA3ForAdMob" "${PODS_ROOT}/NewRelicAgent/NewRelicAgent" "${PODS_ROOT}/TwitterCore/iOS" "${PODS_ROOT}/TwitterKit/iOS"
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
Run Code Online (Sandbox Code Playgroud)

xcconfig cocoapods xcode8 podfile

5
推荐指数
1
解决办法
1459
查看次数

如何禁用 iOS Google 移动广告 SDK 控制台日志?

每当 Google 发布新版本的 Google 移动广告 SDK 时,当前版本都会向控制台发送以下垃圾邮件:

<Google:HTML> You are currently using version x.y.z of the SDK. Please consider 
updating your SDK to the most recent SDK version to get the latest features and 
bug fixes. The latest SDK can be downloaded from ****. 
A full list of release notes is available at https://developers.google.com/admob/ios/rel-notes.
Run Code Online (Sandbox Code Playgroud)

每个广告加载都会多次输出这些内容,如果您实际上正在尝试调试应用程序并在具有不同广告的不同屏幕上移动,那么控制台就会一团糟。

这无疑是保持 SDK 更新的巨大动力,但有时我想调试优先级列表中更高的其他问题。

logging admob ios

5
推荐指数
1
解决办法
888
查看次数

如何将Scheme列表分解为要传递给过程的args?

我想使用(max)带有list数字的预定义函数(R5RS),其长度不同.不幸的是,(max)接受这样的输入:

(max 2 43 5 6)
=> 43
Run Code Online (Sandbox Code Playgroud)

我试图像这样使用它:

(define lst '(3 5 53 4 53 54 32))
(max lst)
Run Code Online (Sandbox Code Playgroud)

这会产生以下错误.

max: expects argument of type <real number>; given (3 5 53 4 53 54 32)
Run Code Online (Sandbox Code Playgroud)

我如何将这个列表分解为我需要的各个参数,因为我将它们传递给了(max)

scheme max list-manipulation r5rs

4
推荐指数
1
解决办法
2585
查看次数

在OS X Lion中编译64位FLAC/libFLAC

我想在我正在尝试构建的应用程序中使用libFLAC动态库,但我不太熟悉configuremake实际获得FLAC编译的参数.

我试过CC="gcc -m64" CXX="g++ -m64" ./configure,看起来运行没问题,但是当我跑make,我仍然得到

[...lots of output with seemingly no errors...]  
/usr/bin/ranlib: archive member: .libs/libFLAC.a(bitreader_asm.o) cputype (7) does not match previous archive members cputype (16777223) (all members must match)
/usr/bin/ranlib: archive member: .libs/libFLAC.a(cpu_asm.o) cputype (7) does not match previous archive members cputype (16777223) (all members must match)
/usr/bin/ranlib: archive member: .libs/libFLAC.a(fixed_asm.o) cputype (7) does not match previous archive members cputype (16777223) (all members must match)
/usr/bin/ranlib: archive member: .libs/libFLAC.a(lpc_asm.o) cputype …

64-bit makefile configure osx-lion

4
推荐指数
1
解决办法
3290
查看次数

如何将字符串传递给HashSet包含?

我想使用HashSet快速字符串查找,但我似乎无法找到一种方法来传递字符串变量contains没有编译器错误.

refs = HashSet::new();

let first_pass = link_regex.replace_all(&buffer, |caps: &Captures| {

    if caps.len() == 2 {
        refs.insert(caps.at(2).unwrap());
    }

    caps.at(1).unwrap().to_owned()
});

let out = ref_regex.replace_all(&first_pass, |caps: &Captures| {
    let capture = caps.at(1).unwrap().to_owned();

    // only remove if we've seen it before
    if refs.contains(capture) {
        return "".to_string();
    }

    capture
});
Run Code Online (Sandbox Code Playgroud)

这会导致此错误:

 src/bin/remove_links.rs:30:26: 30:33 error: mismatched types [E0308]
 src/bin/remove_links.rs:30         if refs.contains(capture) {
                                                     ^~~~~~~
 src/bin/remove_links.rs:30:26: 30:33 help: run `rustc --explain E0308` to see a detailed explanation
 src/bin/remove_links.rs:30:26: 30:33 note: expected type …
Run Code Online (Sandbox Code Playgroud)

string hashset rust borrowing

3
推荐指数
1
解决办法
760
查看次数

PromiseKit 6:如何创建多个并发承诺并将它们各自的结果分组到一个数组中?

我正在处理一个奇怪的 API,在那里我收到了一个 ID 列表,我需要单独请求每个 ID 的数据。我不需要一个接一个地链接这些请求,我只想一次抓住它们,但我无法弄清楚如何以一种干净的方式做到这一点。

我已经制定了获取一个 ID 的方法,它会生成一个Promise<DataObject>. 我如何将我的 ID 数组变成一组承诺,然后给我[DataObject]

func fetchDataObject(_ id: Int64) -> Promise<DataObject> {
    return makeURL("\(id)")
        .then {
            URLSession.shared.dataTask(.promise, with: $0)
        }.compactMap { (data, response) -> DataObject in
            // ...
            return try decoder.decode(DataObject.self, from: data)
    }
}

// get the list of IDs and turn them into DataObjects

func fetchNew() -> Promise<[DataObject]> { // desired output
    return makeURL("all_ids").then {
        URLSession.shared.dataTask(.promise, with: $0)
        }.compactMap { (data, response) -> [Int64] in
            // ...
            return …
Run Code Online (Sandbox Code Playgroud)

ios swift promisekit

1
推荐指数
1
解决办法
1937
查看次数

在NSObject子类上使用自动合成属性的键值编码:respondsToSelector为所有属性访问器返回NO?

我有一个NSObject带有一些属性的简单子类

@interface MyThing : NSObject
    @property (nonatomic, copy) NSString *aString;
    //... and so on
@end
Run Code Online (Sandbox Code Playgroud)

但是当我尝试使用键/值编码通过字典设置我的属性时:

+ (instancetype)thingFromDictionary:(NSDictionary *)dict
{
    MyThing *newThing = [MyThing new];
    for (NSString *key in dict)
    {
        if ([newThing respondsToSelector:@selector(key)])
        {
            //do stuff
            [newThing setValue:[dict objectForKey:key] forKey:key];
        }
        else
        {
            NSLog(@"key %@ doesnt exist. value %@", key, [dict objectForKey:key]);
        }
    }
    return newThing;
}
Run Code Online (Sandbox Code Playgroud)

事实证明,虽然字典包含与我的属性的确切名称匹配的键,但respondsToSelector:总是NO为这些键返回. 如何通过键/值方法确保可以访问所有属性?

objective-c key-value-coding ios7

0
推荐指数
1
解决办法
174
查看次数