小编Jac*_*kie的帖子

Python退出命令 - 为什么这么多,何时应该使用?

似乎python支持许多不同的命令来停止脚本执行.
我发现的选择是: quit(),exit(),sys.exit(),os._exit()

我错过了吗?他们之间有什么区别?你什么时候用?

python

435
推荐指数
4
解决办法
58万
查看次数

连接多个设备时如何使用ADB Shell?失败"错误:多个设备和模拟器"

$ adb --help
Run Code Online (Sandbox Code Playgroud)

...

-s SERIAL  use device with given serial (overrides $ANDROID_SERIAL)
Run Code Online (Sandbox Code Playgroud)

...

$ adb devices
List of devices attached 
emulator-5554 device
7f1c864e  device
Run Code Online (Sandbox Code Playgroud)

...

$ adb shell -s 7f1c864e
error: more than one device and emulator
Run Code Online (Sandbox Code Playgroud)

shell android cmd adb android-debug

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

我可以获得node --inspect自动打开Chrome

在新版本的节点中,node-inspector是内置的,可以使用该命令触发node --inspect index.js.但是,这始终提供一个命令行,其中包含您必须插入地址栏的地址.我知道这可能不是最"安全"但有没有办法消除复制和粘贴步骤?

node.js

53
推荐指数
3
解决办法
8495
查看次数

为什么我在一个webpack项目上获得"意外的令牌导入"而不是另一个?

我有2个项目的工作方式不同,我不知道有什么不同.我在一个项目上有以下内容......

// In .ts wile
import 'core-js/es6';
import 'reflect-metadata';
Run Code Online (Sandbox Code Playgroud)

这在一个项目上很有用,但是,另一个项目具有相同的tsconfig.json和typings.json以及在webpack配置中配置的ts-loader我得到...

未捕获的SyntaxError:意外的令牌导入

关于失败的JS的转换JS看起来像这样......

/***/ function(module, exports, __webpack_require__) {

    /* WEBPACK VAR INJECTION */(function(process) {import 'core-js/es6';
    import 'reflect-metadata';
Run Code Online (Sandbox Code Playgroud)

我将稍后发布一个后续项目

所以我的问题是我错过了什么?打字稿定义是否未正确导入?我已经尝试过typings install再次运行只是为了排除这一点.

更多信息

//tsconfig
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  }
}

// Typings.json
{
  "globalDependencies": {
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
    "node": "registry:dt/node#6.0.0+20160621231320"
  }
}
Run Code Online (Sandbox Code Playgroud)

typescript webpack

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

如何使用grunt-sass编译多个scss文件

我正在尝试将多个.scss文件编译为单个CSS文件.这实际上有效,但只抓取第一个文件...

sass: {                                 // Task
   dist: {     
     files: {
       'css/test.css':'sass/*.scss'
     }

   }
}
Run Code Online (Sandbox Code Playgroud)

我们没有安装ruby,所以grunt-contrib-sass不是一个选项.我在Stylus中做同样的事情......

stylus: {
  compile : {
    files : {
      'css/g.css' : 'stylus/*.styl'
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

sass gruntjs grunt-contrib-sass

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

Android:错误:无法打开crtbegin_dynamic.o:没有这样的文件或目录

我用了以下......

〜/开发/ Android/android-ndk-r8c/build/tools/make-standalone-toolchain.sh --platform = android-9 --install-dir =/Users/me/toolchain

然后我创建以下代码文件...

int main ()
{
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我试过了 ...

<toolchain>/arm-linux-androideabi-gcc test.c
Run Code Online (Sandbox Code Playgroud)

我也试过了

 <toolchain>/arm-linux-androideabi-gcc --sysroot=<toolchain>/sysroot test.c 
Run Code Online (Sandbox Code Playgroud)

两人都回来了......

 toolchain/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_dynamic.o: No such file or directory
Run Code Online (Sandbox Code Playgroud)

android-ndk

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

我如何让Groovy和JAXB一起玩得很好

我试图让JAXB与我的一个groovy类一起工作,但是,似乎它不起作用,但java版本.这是代码......

以下是场景:

如果取消注释2和3,它可以正常工作.

如果取消注释1和4,我得到:

 com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:
       2 counts of IllegalAnnotationExceptions
 groovy.lang.MetaClass is an interface, and JAXB can't handle interfaces.
Run Code Online (Sandbox Code Playgroud)

如果取消注释1和5,我得到:

  javax.xml.bind.JAXBException: class org.oclc.presentations.simplejaxb.PlayerGroovy
        nor any of its super class is known to this context.
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Java的:

    import javax.xml.bind.annotation.XmlRootElement;

    @XmlRootElement
    public class Player {
    }
Run Code Online (Sandbox Code Playgroud)

Groovy的:

    import javax.xml.bind.annotation.XmlRootElement

    @XmlRootElement
    public class PlayerGroovy {
    }
Run Code Online (Sandbox Code Playgroud)

测试:

    import org.junit.Test
    import javax.xml.bind.JAXBContext
    import javax.xml.bind.Marshaller
    import org.junit.Assert

    class PlayerTest {
        @Test
        public void testJaXB(){
            //1 PlayerGroovy player = new PlayerGroovy()
            //2 Player player = new Player() …
Run Code Online (Sandbox Code Playgroud)

java groovy jaxb

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

STL映射错误:命名空间'std'中没有名为'map'的模板; 你是说'max'吗?

我正在开发一个跟踪字符串中字母频率的应用程序.为此,我创建了以下Struct

struct MessageLetter{
  char letter;
  int count;
  MessageLetter(char letter, int freq)
  : letter(letter), count(freq)
  {}
};
Run Code Online (Sandbox Code Playgroud)

现在我正在尝试创建一个如下的stl :: map ...

  std::map<std::string, MessageLetter> lList;
  for(int i = 0; i < output.length(); i++){
    std::cout << i << output[i] << std::endl;
    if(lList.find(output[i]) == lList.end()){
      std::cout << "Letter not found" << std::endl;
      MessageLetter m = {output[i],1};
      lList[output[i]] = m;
    }
    else{
      std::cout << "Letter found" << std::endl;
    }
  }
Run Code Online (Sandbox Code Playgroud)

当我尝试编译这个时,我得到以下内容......

test.cpp:95:8: error: no template named 'map' in namespace 'std'; did you mean 'max'?
  std::map<std::string, …
Run Code Online (Sandbox Code Playgroud)

c++ std

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

找不到名字'PropertyKey'

我正在尝试在项目上运行Webpack,我遇到了多个错误

node_modules/@types/core-js/index.d.ts
error TS2304: Cannot find name 'PropertyKey'.
...
node_modules/@types/core-js/index.d.ts
error TS2339: Property 'for' does not exist on type 'SymbolConstructor'.
Run Code Online (Sandbox Code Playgroud)

我应该安装所有的打字机,所以我不确定它们来自哪里.我尝试从一个编译的项目复制一个package.json,但它没有帮助.我错过了什么?

我的tsconfig看起来像这样

{
  "compilerOptions": {
    "target": "es5",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "noImplicitAny": false,
    "suppressImplicitAnyIndexErrors": true
  },
  "include": [
    "src/**/*"
  ],
  "exclude": [
    "node_modules",
    "**/*.spec.ts"
  ]
}
Run Code Online (Sandbox Code Playgroud)

webpack angular

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

如何为Router Guard Jasmine测试模拟RouterStateSnapshot

我有一个简单的路由器防护,我正在尝试测试canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot ).我可以像这样创建ActivatedRouteSnapshot,new ActivatedRouteSnapshot()但我无法弄清楚如何创建一个模拟RouterStateSnapshot.

根据我试过的代码......

let createEmptyStateSnapshot = function(
    urlTree: UrlTree, rootComponent: Type<any>){
    const emptyParams = {};
    const emptyData = {};
    const emptyQueryParams = {};
    const fragment = '';
    const activated = new ActivatedRouteSnapshot();
    const state = new RouterStateSnapshot(new TreeNode<ActivatedRouteSnapshot>(activated, []));
    return {
        state: state,
        activated: activated
    }
}
Run Code Online (Sandbox Code Playgroud)

import {TreeNode} from "@angular/router/src/utils/tree";似乎需要进行转换或者其他因为我得到......

未捕获的SyntaxError:webpack上的意外的令牌导出:///~/@angular/router/src/utils/tree.js:8:0 < - test.bundle.ts:72431

jasmine angular2-routing angular

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