小编PHP*_*ate的帖子

如何将当前工作目录设置为脚本目录?

我正在写一个bash脚本.我需要当前的工作目录始终是脚本所在的目录.

默认行为是脚本中的当前工作目录是我运行它的shell的目录,但我不想要这种行为.

bash scripting path

500
推荐指数
7
解决办法
35万
查看次数


如何在android中设置自定义声音通知

我将mp3(kalimba.mp3)文件复制到raw文件夹中的res文件夹中.但是当触发通知时,它会产生默认声音.

这是我发出通知的方式:

protected void GenerateNotify() {

    NotificationManager myNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);  
    Notification notification=new Notification(android.R.drawable.ic_btn_speak_now,"hi",100);
    Intent intent=new Intent(getApplicationContext(),as.class);
    PendingIntent contentintent=PendingIntent.getBroadcast(getApplicationContext(),0, intent, 0);
    notification.setLatestEventInfo(getApplicationContext(), "Hi","date", contentintent);
    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.sound = Uri.parse("android.resource://com.example.serviceproject/" + R.raw.kalimba);
    myNotificationManager.notify(NOTIFICATION_ID,notification);
}
Run Code Online (Sandbox Code Playgroud)

android

46
推荐指数
3
解决办法
5万
查看次数

Django DetailView - 如何在get_context_data中使用'request'

我正在尝试修改上下文数据,所以我压倒了get_context_data.我需要request变量来修改这个上下文.那么如何才能获得request变量get_context-data呢?

python django

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

如何在 Text Widget Flutter 中使用换行符

如何在 Flutter 中显示多行文本?

Text("Text1\n Text2\n Text3",maxLines: 20, style: TextStyle(fontSize: 16.0 ,fontWeight:FontWeight.bold,color: Colors.black) , )
Run Code Online (Sandbox Code Playgroud)

flutter

34
推荐指数
3
解决办法
5万
查看次数

如何在Gradle中使用JUnit 5?

在成功运行JUnit 4测试后,我正在尝试将JUnit 5与Gradle一起使用.

预期的结果: JUnit 4测试在输出中给出了一个很好的'传递',并且输入了一个html报告build/reports/tests.

实际结果: JUnit 5测试如下所示不输出任何内容(...) build succesful,虽然我知道测试实际上没有运行,因为没有传递/跳过/失败的测试日志输出,并且fail在测试中放置一个使构建成功.

在很多我认为主要是不相关的输出之间运行gradle test --info收益率Skipping task ':testClasses' as it has no actions..令人惊讶的是,它也说Executing task ':test'Generating HTML test report... Finished generating test html resultsxml中的类似build/test-results/test,而xml没有生成,html显示没有测试运行且没有错误,测试确实没有运行.

我认为非常有趣的是gradle test --debug收益率

[TestEventLogger] Gradle Test Run :test STARTED
[org.gradle.api.internal.tasks.testing.junit.JUnitDetector] test-class-
scan : failed to scan parent class java/lang/Object, could not find the class file
[TestEventLogger]
[TestEventLogger] Gradle Test Run :test …
Run Code Online (Sandbox Code Playgroud)

junit gradle build.gradle junit5

33
推荐指数
4
解决办法
3万
查看次数

不推荐使用DefaultSourceDirectorySet构造函数.如何使用ObjectFactory服务?

我最近更新为gradle版本5.0-rc-4,当运行./gradlew assemble(或任何其他任务)时,我现在收到以下消息:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
Run Code Online (Sandbox Code Playgroud)

当我使用时,./gradlew assemble --warning-mode all我得到:

> Configure project :
The DefaultSourceDirectorySet constructor has been deprecated. This is scheduled to be removed in Gradle 6.0. Please use the ObjectFactory service to create instances of SourceDirectorySet instead.
Run Code Online (Sandbox Code Playgroud)

但是在下面build.gradle我没有看到我在哪里使用任何内容DefaultSourceDirectorySet,那么这个警告是什么,以及我需要更改哪些内容才能与Gradle 6.0兼容?

plugins {
    id 'org.jetbrains.kotlin.jvm' version '1.3.10'
}

dependencies {
    compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' …
Run Code Online (Sandbox Code Playgroud)

gradle

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

如何在像IntelliJ这样的IDE中签署git提交?

问题如何在Windows上使用IntelliJ等IDE进行git提交?

如果你有兴趣,请阅读我在这里尝试的内容:

我主要跟随Github的指南.我确保在更改配置文件后不要忘记重启bash/IntelliJ.

  1. 生成新的GPG密钥对
  2. 将GPG密钥添加到我的GitHub帐户
  3. 将经过验证的(通过GitHub)电子邮件与我的GPG密钥相关联,我确保我的电子邮件.gitconfig是相同的.
  4. 告诉Git关于我的GPG密钥
  5. 与GPG签署提交并确认它已在Github上进行了Verfied.
  6. 从同一页面,我设置默认签名的提交git config --global commit.gpgsign true(我正在使用git 2.12).我做了一个新的提交并验证它已签名git verify-commit HEAD
  7. 当我尝试在IntelliJ中提交时,我gpg: cannot open tty 'no tty'发现IntelliT在尝试签名提交(GPG)并添加no-tty到我的C:\Users\username\.gnupg\gpg.conf文件并重新启动时未能提交更改.

  8. 然后我得到了gpg: Sorry, no terminal at all requested - can't get input似乎合理的错误,因为我刚添加了与没有终端有关的选项.像gpg:抱歉,没有终端请求 - 无法获得输入说解决方案是删除no-tty我希望不适用于我的情况.

  9. 第一个问题中的其他答案建议use-agentgpg.conf文件中添加,这会导致额外的错误gpg: gpg-agent is not available in this session.等等,也许我需要设置gpg-agent.

  10. 我能找到的最佳Windows指南是Archlinux wiki(是的,右).它指定添加到C:/Users/username/.gnupg/gpg-agent.conf …

git gnupg intellij-idea

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

检查programm是否在调试模式下运行

我使用PyCharm IDE进行Python编程.

当我运行proframm时,是否有可能检查我是否处于调试模式?

我使用pyplot作为plt,如果我调试我的程序,只想显示一个图.是的,我可以有一个由我自己设置的全局布尔调试,但我寻找一个更性感的解决方案.

感谢您的支持!

python debugging pycharm python-2.7

11
推荐指数
3
解决办法
3398
查看次数

如何使用Kotlin DSL在Gradle中使用本机JUnit 5支持?

我想在Gradle Kotlin DSL中使用内置的JUnit 5,因为在构建过程中我得到了这个警告:

WARNING: The junit-platform-gradle-plugin is deprecated and will be discontinued in JUnit Platform 1.3.
Please use Gradle's native support for running tests on the JUnit Platform (requires Gradle 4.6 or higher):
https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle
Run Code Online (Sandbox Code Playgroud)

这个链接告诉我放

test {
    useJUnitPlatform()
}
Run Code Online (Sandbox Code Playgroud)

在我的build.gradle,但是语法是build.gradle.kts什么?

我当前的构建文件是

import org.gradle.api.plugins.ExtensionAware

import org.junit.platform.gradle.plugin.FiltersExtension
import org.junit.platform.gradle.plugin.EnginesExtension
import org.junit.platform.gradle.plugin.JUnitPlatformExtension

group = "com.example"
version = "0.0"

// JUnit 5
buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath("org.junit.platform:junit-platform-gradle-plugin:1.2.0")
    }
}

apply {
    plugin("org.junit.platform.gradle.plugin")
}

// …
Run Code Online (Sandbox Code Playgroud)

gradle kotlin gradle-kotlin-dsl

8
推荐指数
2
解决办法
2267
查看次数