小编Sja*_*sma的帖子

R - 以毫秒为单位获取当前时间

我正在尝试进行API调用,这需要一个毫秒的时间.我是R的新手,并且谷歌搜索了几个小时,以实现像Java一样的东西:

System.currentTimeMillis();
Run Code Online (Sandbox Code Playgroud)

我看到的只有像

Sys.Date()Sys.time

返回格式化日期而不是毫秒时间.

我希望有人可以给我一个解决我问题的oneliner.

r

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

var self =这在Coffeescript中

我在使用Coffeescript时处理一些范围问题.

drawFirstLine: (currentAngle)  ->
    currentAngle = currentAngle # = 1

    switch @type
        # set @endAngle to pick up later on
        # Math.PI * 2 is the endpoint of a circle divided by seconds times current seconds
        when "seconds" then @endAngle = Math.PI * 2 / 60 * @seconds
        when "minutes" then @endAngle = Math.PI * 2 / 60 * @minutes
        when "hours" then @endAngle = Math.PI * 2 / 24 * @hours


    @context.arc(@center_x, @center_y, 100, @startAngle, currentAngle, @counterClockWise)
    @context.lineWidth = …
Run Code Online (Sandbox Code Playgroud)

javascript coffeescript

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

警告:运行grunt测试时找不到任务"karma"

http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower

按照这篇关于Angular,Yeoman,Bower和Grunt的有趣指南,我能够引导一个Angular应用程序.

除了使用Karma进行测试外,一切正常.当我跑:

grunt test
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Warning: Task "karma" not found. Used --force, continuing.

Done, but with warnings
Run Code Online (Sandbox Code Playgroud)

我检查了我是否安装了Karma,但是已经安装了.对于Grunt来说,你似乎需要安装grunt-karma.所以我在以下命令中尝试了这个:

npm install grunt-karma --save-dev
Run Code Online (Sandbox Code Playgroud)

这给了我错误,如:

errno: 53,
code: 'ENOTEMPTY',
path: 'C:\\tmp\\phantomjs\\phantom-1.9.2-windows-.zip-extract-' ..
Run Code Online (Sandbox Code Playgroud)

我在Windows上并从powershell执行命令.

希望有人能提供帮助.

编辑karma.conf.js和gruntfile

// Karma configuration
// http://karma-runner.github.io/0.10/config/configuration-file.html

module.exports = function(config) {
  config.set({
    // base path, that will be used to resolve files and exclude
    basePath: '',

    // testing framework to use (jasmine/mocha/qunit/...)
    frameworks: ['jasmine'],

    // list of files / patterns to load in the browser
    files: [
      'app/bower_components/angular/angular.js', …
Run Code Online (Sandbox Code Playgroud)

node.js angularjs gruntjs yeoman karma-runner

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

Webview证书固定

我正在Android中实现一个加载https网站的WebView.在这个网站上我想做证书固定,这意味着我想检查服务器所服务的证书的某些方面.但是我发现WebViewClient中没有方法可以拦截请求并检索证书.

在互联网上有很多人说它无法完成,证书固定在Androids WebView上.所以我希望这里有人知道更多.

android webview

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

将自定义HTTP标头传递给RESTful请求

我试图在Yii中集成Backbone,因此我需要REST.所以我安装了一个yii扩展,restfullyii,它使用了需要传递给请求的用户名和密码.问题是我不知道如何使用Backbone这样做.

想要的请求示例:

List
curl -i -H "Accept: application/json" -H "X_REST_USERNAME: admin@restuser" -H "X_REST_PASSWORD: admin@Access" http://yii-tester.local/api/sample/    
curl -i -H "Accept: application/json" -H "X_REST_USERNAME: admin@restuser" -H "X_REST_PASSWORD: admin@Access" http://yii-tester.local/api/sample/limit/1
curl -i -H "Accept: application/json" -H "X_REST_USERNAME: admin@restuser" -H "X_REST_PASSWORD: admin@Access" http://yii-tester.local/api/sample/limit/10/5 (limit/offeset)
Run Code Online (Sandbox Code Playgroud)

当前的错误响应,完全有意义..:

{
    "success": false,
    "message": "You are not authorized to proform this action.",
    "data": {"errorCode":500}
}
Run Code Online (Sandbox Code Playgroud)

有没有人知道如何在整个Backbone中发送这样的值?

php rest yii backbone.js

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

自定义验证器未在Ruby on Rails中加载

我正在尝试将自定义验证器应用于我的模型issue.rb:

class Issue < ActiveRecord::Base
  attr_accessible :description, :no_followers, :title
  validates_presence_of :title
  validates_uniqueness_of :title, message: "Title should be unique!"

  validates_length_of :description, minimum: 10, maximum: 50
  validates_numericality_of :no_followers, allow_blank: true

  validates_with YesNoValidator

end
Run Code Online (Sandbox Code Playgroud)

验证器是位于应用程序/验证器上的文件,其中包含以下内容:

class YesNoValidator < ActiveModel::Validator
    def validate record
        if record.title.include? "yes" && record.description.include? "No"
            record.errors[:title] << "Title has the word yes and description has the word no"
        end 
    end
end
Run Code Online (Sandbox Code Playgroud)

我也尝试将其放在lib文件夹中,但这也会出现此错误:

Routing Error

uninitialized constant Issue::YesNoValidator
Run Code Online (Sandbox Code Playgroud)

在随机F5'ing中,有时会出现此错误:

NoMethodError in IssuesController#new

undefined method `key?' for nil:NilClass
Run Code Online (Sandbox Code Playgroud)

因此,似乎未加载带有该类的文件,因此我尝试将lib和app / validators文件夹都添加到application.rb中的autoload_paths中。但这也不起作用。

有谁之前经历过这个吗?

validation model ruby-on-rails

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

嵌套的scrollview不占用CoordinatorLayout中的可用空间

我正面临着实施NestedScrollview内部问题的问题CoordinatorLayout.请参阅以下布局代码:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:card_view="http://schemas.android.com/tools">

<android.support.design.widget.AppBarLayout
    android:id="@+id/app_bar_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:expanded="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    android:fitsSystemWindows="true">

    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/collapsing_toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <LinearLayout
            android:layout_marginTop="?android:attr/actionBarSize"
            app:layout_collapseMode="parallax"
            android:layout_width="match_parent"
            android:weightSum="2"
            android:orientation="horizontal"
            android:gravity="bottom"
            android:fitsSystemWindows="true"
            android:background="@color/aop_gray"
            android:layout_height="87dp">

            <LinearLayout
                android:background="#E5E5E5"
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent">

            </LinearLayout>

            <LinearLayout
                android:layout_width="0dp"
                android:layout_weight="1"
                android:layout_height="match_parent">
            </LinearLayout>

        </LinearLayout>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar_anders"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="@color/Custom_red"
            style="@style/CustomTheme.CustomActionBar"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            />
        </android.support.design.widget.CollapsingToolbarLayout>
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:id="@+id/scroll"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clipToPadding="false"
        android:paddingTop="@dimen/activity_horizontal_margin"
        android:paddingBottom="@dimen/activity_horizontal_margin"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <LinearLayout
            android:id="@+id/test1"
            android:layout_gravity="fill_vertical"
            android:layout_width="match_parent"
            android:orientation="vertical"
            android:layout_height="match_parent">

            <com.Custom.saving.widgets.CustomTextView
                android:id="@+id/aop_data_overview_form_header"
                android:gravity="center"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:paddingRight="@dimen/activity_horizontal_margin"
                android:paddingLeft="@dimen/activity_horizontal_margin"
                style="@style/AopHeader"
                android:layout_marginBottom="@dimen/default_margin"
                android:text="@string/is_your_data_correct_header" …
Run Code Online (Sandbox Code Playgroud)

android coordinator-layout android-nestedscrollview

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

Fastlane Gradle命令-未传递属性

我创建了一个fastlane任务,用于上传到Play商店,如下所示:

  lane :DEPLOY_BETA do

  gradle(task: "clean")

  version_codes = google_play_track_version_codes(
      package_name: "",
      json_key: "play_store_service_account_key.json",
  )

  gradle(
    task: "assemble",
    flavor: "World",
    build_type: "Release",
    properties: { "versionCode" => 100 }
  )

  apk_path = Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
  supply(
    apk: apk_path,
    json_key: "play_store_service_account_key.json",
    package_name: "",
    track: "beta",
    skip_upload_metadata: true,
    validate_only: true,
    skip_upload_images: true,
    skip_upload_screenshots: true
    )

  end
Run Code Online (Sandbox Code Playgroud)

问题在于该属性versionCode不会覆盖versionCode味道(也不是defaultConfig)中指定的属性。这是Fastlane中的错误吗?如果我没有设置versionCodebuild.gradle所有它只是增加了不versionCode和FASTLANE供应将失败。

有人可以帮我从这里出去吗?

android gradle fastlane

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

立即取消设置所有属性骨干

我有一个关于Backbone的问题,如何将模型的所有属性设置为空?

unsetmodel.unset(attribute, [options]) 
Remove an attribute by deleting it from the internal attributes hash. Fires a "change" event unless silent is passed as an option.
Run Code Online (Sandbox Code Playgroud)

但这仅仅是为了逐个取消个别财产.

有人有想法吗?

Gretz,

javascript backbone.js

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

每个循环的java期望对象为类型,而它包含整数数组

我有一个初学者的Java问题.

我这样填写ArrayList:

   private ArrayList getDuplicatesIndexes(char[] letters) {
        ArrayList<int[]> duplicatesIndexes = new ArrayList<int[]>();

        for(int i = 0; i < letters.length; i++ ) {

            for(int j = 0; j < letters.length; j++) {
                System.out.println("compare this");
                System.out.println(letters[i]);
                System.out.println("with this:");
                System.out.println(letters[j]);
                if(letters[i] == letters[j] && i != j) {
                    System.out.println("match!");
                    int[] indexes = new int[2];
                    indexes[0] = i;
                    indexes[1] = j;
                    duplicatesIndexes.add(indexes);
                }
            }
        }

        return duplicatesIndexes;
    }
Run Code Online (Sandbox Code Playgroud)

我想像这样遍历它:

private void checkForSingularLetters(ArrayList duplicatesIndexes, char[] letters) {
        for(int[] indexes : duplicatesIndexes ){
            System.out.println(indexes[0]); …
Run Code Online (Sandbox Code Playgroud)

java arraylist

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

为什么我不能从哈希中读取值?

考虑以下代码:

  hash = {"a"=>["B", "C"], "b"=>["C"], "c"=>["D", "E"], "d"=>["F"]}
  puts hash["a"]
Run Code Online (Sandbox Code Playgroud)

这只是打印没有.

puts hash["a"].class
Run Code Online (Sandbox Code Playgroud)

这打印 NilClass

以下ruby版本中是否存在某种已知错误?

ruby 2.0.0p247(2013-06-27修订版41674)[universal.x86_64-darwin13]

我希望有人可以帮助我,这让我发疯.我的IDE是JetBrains的RubyMine.我也尝试通过IRB直接运行它.

谢谢

PS.OS是OSX

ruby hash

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

phonegap运行android:命令无法执行:ant jar - 在Windows上

当我试图将android平台添加到新的phonegap项目(3.1.0)时,我收到以下错误:

  Checking Android requirements...
    Creating android project...
    [Error: An error occured during creation of android sub-project. Creating Cordova project for the Android platform:

    Command failed to execute : ant jar
Run Code Online (Sandbox Code Playgroud)

我做了很多研究并尝试了很多不起作用的潜在解决方案.所以我最后的希望是Stackoverflow.

  • 我正在使用正确安装的Java jdk 1.7.0_45(也尝试过JRE)
  • 我正在使用ant 1.9.2,我完全能够在命令行中检查ant的版本.这里唯一的问题是ant jar给我一个build.xml错误.我认为这是导致Command failed to execute : ant jar错误的主要原因 .

  • 我在整个节点安装了phonegap和cordova,这些工作也完美无缺.

  • 我的路径都配置正确.

我不知道该怎么做,我需要知道一种获得正确build.xml的方法.我希望有人可以帮助我!

ant android cordova

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

adb devices命令不显示我的xperia z - 获得了正确的驱动程序和所有

我试图刷一个自定义ROM,因此我需要运行某些adb命令.现在问题是,当我启动到fastboot时,一切都没问题

fastboot devices
Run Code Online (Sandbox Code Playgroud)

命令识别我的手机(C6603).此外,设备显示为Android设备 - 设备管理器中的sony fastboot接口.但如果我试着跑

adb devices
Run Code Online (Sandbox Code Playgroud)

命令没有找到设备..

我有点绝望这是/是我尝试过的一些其他信息/事情:

  • 我在Kingo root中闪过,我在固件上.74
  • 当然,USB调试正在进行中
  • 我尝试了媒体传输和大容量存储
  • 我尝试了几次不同的USB端口并重启adb几次
  • 我尝试将设备ID添加到adb_usb.ini.虽然我不确定我的设备ID
  • 我使用Flashtool为'fastboot device'安装了驱动程序,并安装了fasbtboot和ADT驱动程序.
  • 我在Windows 8(x64)

我希望有人可以帮助我.否则我应该考虑将ADB Wireless作为我的最后选择

谢谢!

android adb sony-xperia fastboot

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