小编Roy*_*Roy的帖子

哪里可以找到标准的windows phone 8 app bar图标?

我想要"添加","编辑","设置","删除"等标准图标.我确定某处有官方下载.

我不是在寻找花哨的自定义图标.只有标准的对我有好处.

icons windows-phone-8

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

如何在Scala中执行通用元组 - >案例类转换?

假设有人提供了一个功能:

def getTupleData[T](source: String): List[T] = {
  // ...
}
Run Code Online (Sandbox Code Playgroud)

我需要编写一个函数,它将case类C作为类型参数,并List[C]在上述函数的帮助下返回.这是我到目前为止所得到的:

def getCaseClassData[C](source: String): List[C] = {
  // Somehow get T from C.
  // For example, if C is case class MyCaseClass(a: Int, b: Long), then T is (Int, Long)
  // How to get T?      

  getTupleData[T](source) map { tuple: T =>
    // Somehow convert tuple into a case class instance with the case class type parameter
    // C.tupled(tuple) ??  Type parameter cannot be used like this. …
Run Code Online (Sandbox Code Playgroud)

scala

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

Plotly:如何在烛台图表中的日期之间绘制垂直线?

看一下此处的第三个示例(在“添加自定义文本和注释”部分中)。如果放大图表,您可以看到该示例在日期上插入了一条垂直线'2007-12-01'。如果该日期是交易日(例如'2007-11-29'),人们会看到垂直线穿过当天烛台的中间。

情节的例子。 在约会时添加 V 线。

我想在两个日期之间绘制一条垂直线(例如 11 月 29 日到 11 月 30 日之间 - 上例中 v 线之前的两个烛台)。我怎样才能做到这一点?

python candlestick-chart plotly

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

如何计算numpy中一维数组的移动(或滚动,如果你愿意的话)百分位数/分位数?

在熊猫中,我们有pd.rolling_quantile(). 在 numpy 中,我们有np.percentile(),但我不确定如何进行滚动/移动版本。

解释我所说的移动/滚动百分位数/分位数是什么意思:

给定数组[1, 5, 7, 2, 4, 6, 9, 3, 8, 10]0.5窗口大小为 3的移动分位数(即移动百分位数 50%)为:

1
5 - 1 5 7 -> 0.5 quantile = 5
7 - 5 7 2 ->                5
2 - 7 2 4 ->                4
4 - 2 4 6 ->                4
6 - 4 6 9 ->                6
9 - 6 9 3 ->                6
3 - 9 3 8 ->                8
8 - …
Run Code Online (Sandbox Code Playgroud)

numpy quantile pandas rolling-computation

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

Python 3:unittest.mock如何为特定输入指定不同的返回值?

假设我有一个模拟对象(让它成为Mock或MagicMock).我想模拟其中一个方法为特定输入返回一个值,并为另一个特定输入返回另一个值.如何在不必关心输入发送到方法的顺序的情况下执行此操作?

伪代码:

def test_blah():
    o = MagicMock()

    # How to do I these?
    o.foo.return_value.on(1) = 10
    o.foo.return_value.on(2) = 20

    assert o.foo(2) == 20
    assert o.foo(1) == 10
Run Code Online (Sandbox Code Playgroud)

python mocking python-3.x python-unittest

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

尝试在LG G Watch上录制音频时,MediaRecorder抛出"java.lang.RuntimeException:start failed:-2147483648"

我正在尝试在LG G Watch上的应用程序中录制音频.以下代码在语句"recorder.start();"中抛出RuntimeException,并显示消息"start failed:-2147483648".想知道我在这里做错了什么.

我尝试了很多不同的参数集,例如AudioSource:

recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
//-and-
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
Run Code Online (Sandbox Code Playgroud)

对于OutputFormat我也试过了

recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
//-and-
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
//-and-
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
Run Code Online (Sandbox Code Playgroud)

还尝试了不同的AudioEncoder

recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
//-and-
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
Run Code Online (Sandbox Code Playgroud)

这是源代码:

            final MediaRecorder recorder = new MediaRecorder();
            recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
            recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
            recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
            //recorder.setAudioSamplingRate(8000);  // tried with and without this line
            String filename = mMainActivity.getExternalFilesDir(null) + "/my_recording.mp4"; // changed to corresponding extension name for the output format
            Log.d("DEBUG", "Output filename = " + filename);
            recorder.setOutputFile(filename);
            try {
                recorder.prepare();
            }
            catch (IOException e) {
                Log.d("DEBUG", "IOException while prepare(): " + e.getMessage());
            }
            try {
                Thread.sleep(1000);
            } …
Run Code Online (Sandbox Code Playgroud)

android audio-recording runtimeexception mediarecorder wear-os

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

为Windows Phone 8应用程序项目创建控制台窗口的最简单方法是什么?

我有一个Windows Phone 8应用程序,并希望创建一个控制台窗口用于调试输出目的.

我发现这个链接基本上使用DllImport从kernel32.dll获取AllocConsole().

有没有更简单的方法?说,有没有提供c#功能所以我没有DllImport?

Visual Studio中的调试输出窗口如何?从未使用过它.我应该使用它而不是创建一个控制台吗?

c# windows-phone-8

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