小编you*_*786的帖子

如何在TypeScript中将类型声明为可为空?

我在TypeScript中有一个接口.

interface Employee{
   id: number;
   name: string;
   salary: number;
}
Run Code Online (Sandbox Code Playgroud)

我想把'薪水'作为一个可以为空的领域(就像我们在C#中所做的那样).这可以在TypeScript中做到吗?

javascript typescript

202
推荐指数
9
解决办法
20万
查看次数

更改Switch的"on"颜色

我在ICS应用程序中使用带有holo.light主题的标准Switch控件.

我想将切换按钮的突出显示或状态颜色从标准浅蓝色更改为绿色.

这应该很容易,但我似乎无法弄清楚如何做到这一点.

android togglebutton

132
推荐指数
16
解决办法
16万
查看次数

Rails 3 - 加快控制台加载时间

我想知道是否有任何相对简单的方法来加快我的控制台加载时间,这开始接近30秒.我有很多子类,其方法似乎没有受到影响reload!所以我最终打开和关闭控制台很多.IRB快速加载闪电.

我有太多宝石吗?我如何计算负载任务的时间,以便我可以看到占用时间最多的是什么?正如你所看到的,我已经尝试过dev-boost gem无济于事.该应用程序在Passenger中很好,它只是控制台加载,从而导致我的废话.运行在具有2.4GHz和4GB RAM的MBP OSX 10.6.6上.不使用RVM.

版本:

Ovid$ rails -v
Rails 3.0.3
Ovid$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-darwin10]
Run Code Online (Sandbox Code Playgroud)

记忆:

Ovid$ vm_stat
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free:                         118818.
Pages active:                       341320.
Pages inactive:                      99490.
Pages speculative:                  310576.
Pages wired down:                   112527.
"Translation faults":             23097323.
Pages copy-on-write:               1270961.
Pages zero filled:                13836659.
Pages reactivated:                      36.
Pageins:                            165761.
Pageouts:                                0.
Object cache: 28 hits of 760846 lookups (0% hit rate)
Run Code Online (Sandbox Code Playgroud)

的Gemfile:

source …
Run Code Online (Sandbox Code Playgroud)

ruby console ruby-on-rails ruby-on-rails-3

44
推荐指数
4
解决办法
7462
查看次数

Linux和Windows之间的Android SDK平台

我是双启动Windows 7和Ubuntu 12.04 Linux.我可以将现有的Android SDK平台从我的Windows分区复制到linux分区吗?或者平台有什么不同?我不想浪费时间再次重新加载所有包.

android

18
推荐指数
4
解决办法
4611
查看次数

使用"和"运算符与&&运算符的任何缺点?

使用"和"运算符与&&运算符有什么优缺点?我个人认为"和"只会引起混淆(具有讽刺意味).

如果没有任何差异,为什么会存在?这看似愚蠢和不必要.

c++ operators

14
推荐指数
2
解决办法
6555
查看次数

渴望从Rails 5中的实例化ActiveRecord对象加载单一关联的关联

我有一个模型User,那个has_one :childChild模型has_one :toy.

如果我有一个User类的单个实例,user我如何在一个查询中加载子和玩具?

这是不起作用的:

user.child.toy # 2 queries
user.includes(child: :toy) # can't call includes on a single record
user.child.includes(:toy) # same as above
user.association(:child).scope.eager_load(:toy).first # makes the appropriate query with both child and toy... but doesn't set the object on the user model.
user.child = user.association(:child).scope.eager_load(:toy).first # makes the appropriate query, but also calls another query before setting the child :(
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点,不涉及重新查询用户模型.即.我想避免这种情况

User.where(id: user.id).eager_load(child: :toy).first
Run Code Online (Sandbox Code Playgroud)

Relavant模型声明:

class User < …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails rails-activerecord

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

无法修复MediaController.show()异常

我使用MediaPlayer在前台服务中播放音频文件.当用户点击与前台服务关联的通知时,我使用Intent启动一个Activity,如下所示:

Intent audioPlayIntent = new Intent(context, AudioPlayActivity.class);
audioPlayIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
audioPlayIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, audioPlayIntent, 0);
Run Code Online (Sandbox Code Playgroud)

然后,此Activity绑定到服务以向用户显示MediaController.

这是服务中的绑定代码:

public class AudioPlayerServiceBinder extends Binder{

    public AudioPlayerService getAudioService(){
        return AudioPlayerService.this; //this class is declared in AudioPlayerService.java, so it has access to the Service instance.
    }

}
Run Code Online (Sandbox Code Playgroud)

..并且在Activity中onStart我调用了这个方法:

private void bindAudioService()
    {
        Intent i = new Intent(this, AudioPlayerService.class);
        serviceConnection = new AudioServiceConnection();
        bindService(i, serviceConnection, 0);
    }
Run Code Online (Sandbox Code Playgroud)

我在下面的mediaController.show(5000)行上遇到异常:

private class AudioServiceConnection implements ServiceConnection{

    AudioPlayerServiceBinder audioServiceBinder;
@Override
        public void onServiceConnected(ComponentName name, IBinder serviceBinder) …
Run Code Online (Sandbox Code Playgroud)

android android-service

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

rvm制作宝石原始是什么意思?

我在Google或rvm网站上找不到任何相关信息.

我跑的时候 rvm gemset copy 1.9.3-p194 1.9.3-p125-falcon

=> Copying gemset from 1.9.3-p194 to 1.9.3-p125-falcon
=> Making gemset for 1.9.3-p125-falcon pristine.
Run Code Online (Sandbox Code Playgroud)

是输出.这是什么意思?

ruby rvm

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

Heroku*.js不是预编译错误

我在Heroku Cedar堆栈上使用Rails并且在编译资产时没有抛出任何问题,但后来我得到了500个内部服务器错误:

2012-06-25T23:22:59+00:00 app[web.1]: ActionView::Template::Error (bootstrap-datepicker.js isn't precompiled):
Run Code Online (Sandbox Code Playgroud)

知道可能导致这种情况的原因吗?这是我包含的javascript文件(除了我在本地下载)https://github.com/eternicode/bootstrap-datepicker/blob/master/js/bootstrap-datepicker.js

我将它包含在我的application.html.erb中,如下所示:

<%= javascript_include_tag "bootstrap-datepicker" %>
Run Code Online (Sandbox Code Playgroud)

是因为它不是coffeescript文件吗?任何帮助表示赞赏!

ruby-on-rails heroku ruby-on-rails-3 asset-pipeline cedar

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

HTML选择"完成"标签未在Ionic for iOS上显示

我正在使用Ionic框架构建iOS应用程序.当我使用select-elements时,在iOS-native菜单中选择项目时,我没有得到标签为"Done"的标题.但是,当我在iOS/Safari中使用该应用程序时,它会显示出来.附加截图和代码.任何输入/解决方案都将非常感激.

截图:

iOS Safari截图 iOS Safari截图

iOS Native/Ionic截图 iOS Native/Ionic截图

标记

<label class="item item-input item-select">
    <div class="input-label">
        Bostadstyp
    </div>
    <select ng-change="addParam('objectType', selectedHouseType)" ng-model="selectedHouseType" ng-options="houseType.id as houseType.label for houseType in houseTypes"></select>
</label>
Run Code Online (Sandbox Code Playgroud)

html safari angularjs cordova ionic

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