小编Dan*_*npe的帖子

让用户在C#中空闲时间?

我找到了关于如何获得用户空闲时间的空闲时间的教程.

问题是它只有在应用程序在用户上运行时才有效.

我的应用程序在SYSTEM上运行.

我怎样才能获得空闲时间?或者如果PC空闲?

.net c# windows-services system

11
推荐指数
2
解决办法
7301
查看次数

在after_update回调中获取更改的属性

我正在尝试创建一个有条件的after_update,我有以下内容:

  after_update do |participant|
    Rails.logger.info "#{self.previous_changes} changed."
    if self.previous_changes.include?(:current_distance)
      #Do my stuff ...
    end
  end
Run Code Online (Sandbox Code Playgroud)

记录器打印空哈希: {}

如何检查哪个属性已更改?

我正在使用:participant.update_attribute(:current_distance, distance)更新属性.

ruby activerecord ruby-on-rails

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

非泛型类型'System.Collections.IEnumerable'不能与类型参数一起使用

using System.Collections.Generic;

public sealed class LoLQueue<T> where T: class
{
    private SingleLinkNode<T> mHe;
    private SingleLinkNode<T> mTa;

    public LoLQueue()
    {
        this.mHe = new SingleLinkNode<T>();
        this.mTa = this.mHe;
    }
}
Run Code Online (Sandbox Code Playgroud)

错误:

The non-generic type 'LoLQueue<T>.SingleLinkNode' cannot be used with type arguments
Run Code Online (Sandbox Code Playgroud)

为什么我会这样?

.net c# generics queue nodes

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

循环遍历GroupView的所有子节点?

这是我的代码:

    Typeface font = Typeface.createFromAsset(getAssets(), "fonts/choco.ttf");  
    ViewGroup rootView = (ViewGroup) findViewById(android.R.id.content).getRootView();
    for(int i = 0; i < rootView.getChildCount(); i++)
    {
        View child = rootView.getChildAt(i);
        Log.d("menfis", child.toString());
        if(child != null)
            if(child.getClass() == TextView.class)
                ((TextView) child).setTypeface(font);
    }
Run Code Online (Sandbox Code Playgroud)

这是我的XML页面:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/background_page"
android:gravity="center_horizontal" >

<ImageView
    android:id="@+id/imgApplicationIcon"         
    android:src="@drawable/logo" 
    android:layout_width="fill_parent" android:layout_height="wrap_content"/>

<TextView  
    android:layout_marginTop="40dip"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="right"
    android:textColor="@color/red"
    android:lines="2"
    android:layout_marginRight="30dip"
    android:text="test1" />

<TextView  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="right"
    android:layout_marginRight="30dip"
    android:textColor="@color/red"
    android:lines="2"
    android:text="test2" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

问题是我只能在LogCat控制台上得到它:

09-20 14:34:27.264: DEBUG/menfis(12251): android.widget.LinearLayout@40523820
Run Code Online (Sandbox Code Playgroud)

为什么我没有得到TextViews的引用?

java android

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

如果...(在1行中)添加内联类

我想只在语句为真时才向link_to添加一个类.

<%= link_to product.name, product, :class => "last" if product == @products.last %>
Run Code Online (Sandbox Code Playgroud)

IF语句影响整行而不仅仅是:class部分的问题.

我知道我可以用IF ELSE完成它,但它可以在一行中完成吗?

ruby if-statement ruby-on-rails class link-to

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

谁负责在Rails中生成.idea文件?

当我在我的Rails应用程序文件夹上查找时,我可以找到.idea文件夹,它包括:

  • .generators
  • .rakeTasks

还有更多... 例如,当我打开.generators时,我看到以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<Settings><!--This file was automatically generated by Ruby plugin.
You are allowed to: 
1. Reorder generators
2. Remove generators
3. Add installed generators
To add new installed generators automatically delete this file and reload the project.
--><GeneratorsGroup><Generator name="active_record:migration" /><Generator name="active_record:model" /><Generator name="active_record:observer" /><Generator name="active_record:session_migration" /><Generator name="controller" /><Generator name="erb:controller" /><Generator name="erb:mailer" /><Generator name="erb:scaffold" /><Generator name="generator" /><Generator name="helper" /><Generator name="integration_test" /><Generator name="mailer" /><Generator name="metal" /><Generator name="migration" /><Generator name="model" /><Generator name="model_subclass" /><Generator …
Run Code Online (Sandbox Code Playgroud)

ruby plugins code-generation ruby-on-rails ruby-on-rails-3

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

SQL选择COUNT(值=值)可能吗?

我想计算所有只有我想要的值的行:

SELECT Users.Balance,
       Users.FreeBids,
       COUNT(Bids.Burned = 0) AS 'ActiveBids',
       COUNT(Bids.Burned = 1) AS 'BurnedBids'
FROM   Users
       INNER JOIN Bids
         ON Users.ID = Bids.BidderID
WHERE  Users.ID = 2
GROUP  BY Users.Balance,
          Users.FreeBids  
Run Code Online (Sandbox Code Playgroud)

它说" Invalid Syntax Neat '='没有'='就可以完美地工作.我如何计算Burned = 1并且Burned = 0的行?

谢谢,丹

sql sql-server select count

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

#define从C转换为C#

这是C代码:

/* LERP(a,b,c) = linear interpolation macro, is 'a' when c == 0.0 and 'b' when c == 1.0 */
#define LERP(a,b,c)     (((b) - (a)) * (c) + (a))
Run Code Online (Sandbox Code Playgroud)

http://www.brucelindbloom.com/index.html?Eqn_XYZ_to_T.html

等于这个C#代码?

private static double LERP(double a, double b, double c) { return (((b) - (a)) * (c) + (a)); }
Run Code Online (Sandbox Code Playgroud)

c c# macros

8
推荐指数
3
解决办法
1268
查看次数

手动更新模型后更新db/migrate?

例如,我有这个模型:

class Product < ActiveRecord::Base
  attr_accessible :name, :order
end
Run Code Online (Sandbox Code Playgroud)

然后,当我这样做时,rake db:migrate它创建了这个db/migrate/20120825132038_create_products.rb:

class CreateProducts < ActiveRecord::Migration
  def change
    create_table :products do |t|
      t.integer :order
      t.string :name

      t.timestamps
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

但这一切都发生了,因为我用过 rails generate Product order:integer name:string

现在我转到产品型号并手动更改为:

class Product < ActiveRecord::Base
  attr_accessible :name, :order, :category_id

  validates :name, uniqueness: true
  belongs_to :category
end
Run Code Online (Sandbox Code Playgroud)

如何使用更新自动更新db/migrate/20120825132038_create_products.rb

rake activerecord model ruby-on-rails

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

编辑android VideoView帧

环境:

Nexus 7 Jelly Bean 4.1.2

问题:

我正在尝试使用VideoView制作适用于RTSP的运动检测应用程序.

我希望有类似onNewFrameListener的东西

videoView.onNewFrame(Frame frame)
Run Code Online (Sandbox Code Playgroud)

我试图通过VideoView访问RTSP流的原始帧,但在Android SDK中找不到任何支持.

我发现VideoView封装了Android的MediaPlayer类.

所以我潜入media_jnilib尝试找到一种方法来访问原始帧,但找不到字节缓冲区或代表帧的任何东西.

题:

任何人都知道我在哪里或如何找到这个缓冲区并获得访问权限?

或者通过VideoView实现运动检测的任何其他想法?

即使我需要重新编译AOSP也是如此.

android motion-detection android-source android-4.2-jelly-bean android-videoview

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