小编Sha*_*oon的帖子

如何使用CodeMirror动态切换模式?

如何使用CodeMirror动态切换模式?

我有默认设置,但需要切换它.

codemirror

10
推荐指数
2
解决办法
7080
查看次数

为什么Mongo不读取/usr/local/mongodb/mongod.conf文件?

在我的/usr/local/mongodb/mongod.conf档案中,我有

# Store data alongside MongoDB instead of the default, /data/db/
dbpath = /usr/local/mongodb_data

# Only accept local connections
bind_ip = 127.0.0.1
Run Code Online (Sandbox Code Playgroud)

但是当我尝试运行Mongo(在我的Mac上)时,我收到一个错误:

Wed Sep 14 09:29:35 [initandlisten] exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating
Run Code Online (Sandbox Code Playgroud)

显然conf文件没有被读取

macos mongodb

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

Rails 3引擎可以从它的父应用程序访问模型吗?

我有一个Rails引擎,我想访问父母模型.那可能吗?如果是这样,我该怎么做?

rails-engines ruby-on-rails-3

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

Rails production.log文件为空

我正在使用Rails 2.3.13而在我的中environments/production.rb,我有:

config.log_level = :info
RAILS_DEFAULT_LOGGER = SyslogLogger.new('mysite-platform-production')
Run Code Online (Sandbox Code Playgroud)

然而,我log/production.log是空的.那为什么会这样?

ruby-on-rails

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

我可以使用Node.js编程Raspberry Pi吗?

我想学习Raspberry Pi的编程,我对Node.js非常好.我差不多五年没碰过C++了.我知道我可以在Pi上加载Linux,但是如何在Node中进行编程呢?

如果是这样,我该如何处理输入/输出等事情?例如,如果我想制作一个检测到运动并发出哔哔声的简单设备,这是否可以通过Pi上的Node.js来实现?

node.js raspberry-pi raspbian

10
推荐指数
2
解决办法
6694
查看次数

困惑$ locationChangeSuccess和$ stateChangeStart

我正在尝试使用AngularUI路由器进行一些身份验证.$urlRouter.sync()看起来正是我需要的.但是,这只有在我拦截时才可用$locationChangeSuccess.但是当我这样做时,它$state.current.name是空的,而我希望它是当前的状态.

到目前为止,这是我的代码:

$rootScope.$on('$locationChangeSuccess', function(event, next, nextParams) {
  event.preventDefault();
  if ($state.current.name === 'login') {
    return userService.isAuthenticated().then(function(response) {
      var authenticated;
      authenticated = response.authenticated;
      return alert(authenticated);
    });
  }
});
Run Code Online (Sandbox Code Playgroud)

关于我做错了什么的指示?

angularjs angular-ui-router

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

如何配置passport-github以在回调时确认用户?

我有一项服务,我的目标是让用户通过OAuth授权我们使用他/她的Github帐户.API层是无状态的,因此我不想维护任何会话信息.我到目前为止的代码是:

  app.use passport.initialize()
  app.use passport.session()

  passport.use new GitHubStrategy
    clientID: global.config.oauth.github.clientID
    clientSecret: global.config.oauth.github.clientSecret
    callbackURL: "http://localhost:9500/auth/github/callback"
    passReqToCallback: true
  , (req, accessToken, refreshToken, profile, done) ->
    console.log req.params
    serviceQuery =
      service: 'github'
      provider_id: "#{profile.id}"
      UserId: 13

    global.db.Service.find
      where: serviceQuery
    .then (dbService) ->
      if not dbService
        newService =
          service: 'github'
          token: accessToken
          secret: null
          provider_id: profile.id
          raw: profile._json
          UserId: 13
        global.db.Service.create newService
      else
        dbService.token = accessToken
        dbService.raw = profile._json
        dbService.save()
    .then ->
      done null, true


  app.get '/auth/github/:sessionToken', (req, res, next) ->
    console.log req.params
    next() …
Run Code Online (Sandbox Code Playgroud)

node.js coffeescript oauth-2.0 passport.js

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

如何让我的Angular5 spyOn按预期工作?

我的测试没有检测到变化.这是我的组件:

  toggleUploadModal() {
    const modalRef = this.ngbModal.open(UploadFilesComponent, { size: 'lg', backdrop: 'static' });
    modalRef.componentInstance.DeliverableTransaction = this.transactionDetails;
    modalRef.result.then((res) => {
      if (res.status === 'success') {
        this.deliverableTransactionService.updateDeliverableTransaction(this.route.snapshot.params.id, {
          submissionStatus: 'In Process'
        })
      }
      setTimeout(() => {
        this.uploadStatus = {};
      }, 5000);
    })
  }
Run Code Online (Sandbox Code Playgroud)

我的测试有:

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [TransactionFileViewer, NgxPermissionsAllowStubDirective],
      providers: [...],
      imports: [...],
      schemas: [
        NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA
      ],
    })
      .compileComponents();
    fixture = TestBed.createComponent(TransactionFileViewer);
    downloadService = TestBed.get(DownloadService);
    component = fixture.componentInstance;
    fixture.detectChanges();
    submissionFileService = TestBed.get(SubmissionFileService);
    deliverableDefinitionService = TestBed.get(DeliverableDefinitionService);
    service = TestBed.get(DeliverableDefinitionDetailViewService);
    deliverableTransactionService …
Run Code Online (Sandbox Code Playgroud)

stub spy bluebird angular angular5

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

如何将当前时间戳放在Mongoose Schema中?

根据文档,我可以这样做一个日期:

new Schema({
    date: { type: Date, default: Date.now }
})
Run Code Online (Sandbox Code Playgroud)

但如果我需要时间怎么办?

mongoose node.js

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

如何模拟工作人员进行 Jest 测试?

我有一个测试:

import { convertHeicToPng } from './heicUtils';

class Worker {
  url: string;
  onmessage: (m?: any) => void;
  constructor(stringUrl: string) {
    this.url = stringUrl;
    this.onmessage = () => {};
  }

  postMessage(msg: any) {
    this.onmessage(msg);
  }
}

(window.Worker as any) = Worker;

describe('test heicUtils', () => {
  test('should convert HEIC to PNG', async () => {
    const file = new File([''], 'test.heic', { type: 'image/heic' });
    const base64 = await convertHeicToPng(file);
    expect(base64).toContain('data:image/png;base64');
  });
});
Run Code Online (Sandbox Code Playgroud)

在 中heicUtils,我使用的是heic2any,它使用 WebWorkers。我如何才能正确地模拟 Worker …

javascript web-worker typescript jestjs

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