小编Chr*_*ton的帖子

无法解析模块`@babel/runtime/helpers/interopRequireDefault`

当使用标准创建一个新的反应本机项目react-native init MyApp并且react-native run-ios第一次运行时,我看到以下错误

error: bundling failed: Error: Unable to resolve module `@babel/runtime/helpers/interopRequireDefault` from `/Users/chrisedgington/Development/ReactNative/SixNationsPredictor/index.js`: Module `@babel/runtime/helpers/interopRequireDefault` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:
  1. Clear watchman watches: `watchman watch-del-all`.
  2. Delete the `node_modules` folder: `rm -rf node_modules && npm install`.
  3. Reset Metro Bundler cache: `rm -rf /tmp/metro-bundler-cache-*` or `npm start -- --reset-cache`.
  4. Remove haste cache: `rm -rf /tmp/haste-map-react-native-packager-*`.
    at ModuleResolver.resolveDependency (/Users/chrisedgington/Development/ReactNative/MyApp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:209:1301) …
Run Code Online (Sandbox Code Playgroud)

react-native

56
推荐指数
6
解决办法
2万
查看次数

如何在Kotlin中解析Unix时间戳到日期字符串

如何将Unix时间戳解析为Kotlin中的日期字符串?

例如1532358895,以2018-07-23T15:14:55Z

kotlin

7
推荐指数
2
解决办法
4656
查看次数

EF Core Eager加载嵌套集合

我正在尝试在Entity Framework Core中加载相关的模态,但是由于某种原因,当我在Include()调用中没有要求时,正在加载一个嵌套集合。

这是我的两个模型-

Driver.cs

public partial class Driver : IBaseEntity
{
    public short DriverId { get; set; }
    public string Surname { get; set; }
    public string Initials { get; set; }
    public byte DriverStatusTypeId { get; set; }

    public DriverStatusType DriverStatusType { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

DriverStatusType.cs

public partial class DriverStatusType
{
    public DriverStatusType()
    {
        Drivers = new HashSet<Driver>();
    }

    public byte DriverStatusTypeId { get; set; }
    public string DriverStatusTypeName { get; set; }
    public string …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core

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

在 Android 上生成和导出 RSA 密钥对

我正在尝试在 Android 上生成一个 KeyPair 并将公钥导出为一个字符串,因此它的格式为 -

-----BEGIN RSA PUBLIC KEY-----MIIB...

我使用以下方法成功生成了 KeyPair -

fun generateKeyPair(): KeyPair {
    val generator = KeyPairGenerator.getInstance(KeyProperties.KEY_ALGORITHM_RSA)

    generator.initialize(2048, SecureRandom())
    val keypair = generator.genKeyPair()
    return keypair
}

val keypair = generateKeyPair()

Log.d("Keypair", keypair.public.toString())
Run Code Online (Sandbox Code Playgroud)

但这给了我 -

OpenSSLRSAPublicKey{modulus=e0a6a5a...
Run Code Online (Sandbox Code Playgroud)

有谁知道我如何以上述格式导出密钥?

android rsa kotlin

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

在类型转换 Typescript 类上调用方法

我正在使用 Cloud Firestore 投射到一个工作正常的对象。但是,我似乎无法在该对象上调用方法。这是我的模型定义 -

联系人.ts

export class Contact {
  id: string
  firstname: string
  lastname: string
  email: string

  getFullname() {
    return this.firstname + this.lastname
  }
}
Run Code Online (Sandbox Code Playgroud)

联系服务.ts

@Injectable()
export class ContactService {
  getAll(raiseId: string): Observable<Contact[]> {
    this.contactsCollection = this.afs.collection<IContact>('contacts')
    this.contacts$ = this.contactsCollection.snapshotChanges().pipe(
      map(actions => actions.map(a => {
        const contact = a.payload.doc.data() as Contact;
        const id = a.payload.doc.id;
        return { id, ...contact };
      }))
    );
    return this.contacts$;
  }
}
Run Code Online (Sandbox Code Playgroud)

contact.component.ts

@Component({
  selector: 'contact-view',
  templateUrl: './contact-view.component.html',
  styleUrls: ['./contact-view.component.scss']
})
export class ContactViewComponent …
Run Code Online (Sandbox Code Playgroud)

firebase typescript angular google-cloud-firestore

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

在 Angular 中按顺序运行一组 http 调用

我已经多次看到这个问题,但我不知道如何实现这个问题来解决我的问题。

我基本上有一组需要按顺序执行的 http 调用。具体来说,我需要执行一个,等待它返回然后执行下一个。

let requests = [
  this.http.post('http://localhost:4200/api/value', 'one'),
  this.http.post('http://localhost:4200/api/value', 'two'),
  this.http.post('http://localhost:4200/api/value', 'three'),
  this.http.post('http://localhost:4200/api/value', 'four'),
];
Run Code Online (Sandbox Code Playgroud)

所以我目前正在使用 forkJoin 但这会同时运行请求,这不是我想要的。

forkJoin(observableBatch).subscribe(result => {
  // success
}, error => {
  // log error
}); 
Run Code Online (Sandbox Code Playgroud)

我读到 usingconcatMap可能是答案,但我如何在可观察数组上使用它?

rxjs angular

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

在Swift的循环中减少内存使用

我在Swift中有一个while循环,试图解决问题,有点像比特币挖矿。简化版本是-

import SwiftyRSA

func solveProblem(data: String, complete: (UInt32, String) -> Void) {
    let root = data.sha256()
    let difficulty = "00001"
    let range: UInt32 = 10000000
    var hash: String = "9"
    var nonce: UInt32 = 0
    while (hash > difficulty) {
        nonce = arc4random_uniform(range)
        hash = (root + String(describing: nonce)).sha256()
    }
    complete(nonce, hash)
}

solveProblem(data: "MyData") { (nonce, hash) in
    // Problem solved!
}
Run Code Online (Sandbox Code Playgroud)

尽管此循环正在运行,但内存使用量有时会稳定达到300mb,一旦完成,它似乎就不会释放。

有人能够解释为什么会这样吗,如果这是我应该担心的事情?

swift

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

Javascript过滤嵌套数组

我正在尝试在Angular应用程序中的对象数组内的嵌套数组上过滤a。这是组件代码的片段-

var teams = [
  { name: 'Team1', members: [{ name: 'm1' }, { name: 'm2' }, { name: 'm3' }] }, 
  { name: 'Team2', members: [{ name: 'm4' }, { name: 'm5' }, { name: 'm6' }] }, 
  { name: 'Team3', members: [{ name: 'm7' }, { name: 'm8' }, { name: 'm9' }] }
];
Run Code Online (Sandbox Code Playgroud)

我要达到的目标是m5,例如,如果搜索,我的结果应该是-

var teams = [
  { name: 'Team1', members: [] }, 
  { name: 'Team2', members: [{ name: 'm5' }] }, 
  { …
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular

0
推荐指数
2
解决办法
107
查看次数