prompt

grunt-init template conditional prompts

假装没事ソ 提交于 2019-12-06 14:49:13
I'm creating a new grunt-init template for my project and was wondering if there is a way to do conditional prompts based on the answers given to previous prompts. My main goal is to be able to use the Github API to create an issue when I create a new module in my project. After asking for the module information, I would ask if a Github issue should be created. If yes, then ask for information like assignee, milestone, labels. If no, I don't care about any of those features. Right now, I can just default them to blanks, but I'd like to just skip those prompts entirely. The init property

readline库使用

谁说我不能喝 提交于 2019-12-06 12:18:18
本文档主要介绍readline库和其它程序之间的接口,主要有:自动补全、行编辑、历史交互命令等。 基本函数 readline 函数原型:char *readline (const char *prompt); 在官方文档中,对readline函数的描述如下: The function readline() prints a prompt prompt and then reads and returns a single line of text from the user. If prompt is NULL or the empty string, no prompt is displayed. The line readline returns is allocated with malloc(); the caller should free() the line when it has finished with it. 大意是readline()函数打印一个提示符,返回一个用户输入的单行文本,如果输入的是一个空字符串,没有参数显示。readline的返回结果是已经通过malloc分配了内存的,用户应该在调用了readline()函数之后使用free()释放它。 测试代码如下: 来源: https://www.cnblogs.com/mrlayfolk/p

Android JNI作用及其详解

隐身守侯 提交于 2019-12-06 08:29:41
Java Native Interface (JNI)标准是Java平台的一部分,它允许Java代码和其他语言写的代码进行交互。JNI 是本地编程接口,它使得在 Java 虚拟机 (VM) 内部运行的 Java 代码能够与用其它编程语言(如 C、C++ 和汇编语言)编写的应用程序和库进行交互操作。   1.从如何载入.so档案谈起   由于Android的应用层的类都是以Java写的,这些Java类编译为Dex型式的Bytecode之后,必须靠Dalvik虚拟机(VM: Virtual Machine)来执行。VM在Android平台里,扮演很重要的角色。   此外,在执行Java类的过程中,如果Java类需要与C组件沟通时,VM就会去载入C组件,然后让Java的函数顺利地调用到C组件的函数。此时,VM扮演着桥梁的角色,让Java与C组件能通过标准的JNI介面而相互沟通。   应用层的Java类是在虚拟机(VM: Vitual Machine)上执行的,而C件不是在VM上执行,那么Java程式又如何要求VM去载入(Load)所指定的C组件呢? 可使用下述指令:   System.loadLibrary(*.so的档案名);   例如,Android框架里所提供的MediaPlayer.java类,含指令:   public class MediaPlayer{   static {

JNI学习笔记

杀马特。学长 韩版系。学妹 提交于 2019-12-06 08:25:27
1为什么使用JNI? JNI 的强大特性使我们在使用 JAVA 平台的同时,还可以重用原来的本地代码。作为虚拟机 实现的一部分,JNI 允许 JAVA 和本地代码间的双向交互。 请记住,一旦使用 JNI,JAVA 程序就丧失了 JAVA 平台的两个优点: 1、 程序不再跨平台。要想跨平台,必须在不同的系统环境下重新编译本地语言部分。 2、 程序不再是绝对安全的,本地代码的不当使用可能导致整个程序崩溃。 一个通用规则是,你应该让本地方法集中在少数几个类当中。这样就降低了 JAVA 和 C 之间的耦合性。 当你开始着手准备一个使用 JNI 的项目时,请确认是否还有替代方案。像上一节所提到的, 应用程序使用 JNI 会带来一些副作用。下面给出几个方案,可以避免使用 JNI 的时候,达到 与本地代码进行交互的效果: 1、JAVA 程序和本地程序使用 TCP/IP 或者 IPC 进行交互。 2、 当用 JAVA 程序连接本地数据库时,使用 JDBC 提供的 API。 3、JAVA 程序可以使用分布式对象技术,如 JAVAIDLAPI。 这些方案的共同点是,JAVA 和 C 处于不同的线程,或者不同的机器上。这样,当本地程序 崩溃时,不会影响到 JAVA 程序。 下面这些场合中,同一进程内 JNI 的使用无法避免: 1、 程序当中用到了 JAVA API 不提供的特殊系统环境才会有的特征

broken bash prompt wrap line

▼魔方 西西 提交于 2019-12-06 06:42:31
问题 I'm customizing my bash prompt on OsX to include git branch plus some marks of the branch state. This breaks line wrap. I know that I have to add \[ and \] to prevent this issue, but doing so in the functions does display \[ and \] litteraly. What can I do to escape such sequences in those functions? Disclaimer: those are my first attempts in bash scripting. function parse_git_dirty { # TODO make git status response a variable # [branch+] : working dir has staged changes if [[ $(git status 2>

how to show current directory in ipython prompt

风流意气都作罢 提交于 2019-12-05 21:26:22
问题 Is there is way to show the current directory in IPython prompt? Instead of this: In [1]: Something like this: In<~/user/src/proj1>[1]: 回答1: https://ipython.org/ipython-doc/3/config/details.html#specific-config-details In the terminal, the format of the input and output prompts can be customised. This does not currently affect other frontends. So, in .ipython/profile_default/ipython_config.py, put something like: c.PromptManager.in_template = "In<{cwd} >>>" 回答2: You can use os.getcwd (current

Phonegap and prompt()

…衆ロ難τιáo~ 提交于 2019-12-05 19:20:27
问题 I was looking through the Phonegap sources for Android, and trying to verify that their notification.alert() method simply delegates to the native JavaScript alert() function. Their code does: Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) { var _title = (title || "Alert"); var _buttonLabel = (buttonLabel || "OK"); PhoneGap.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]); }; Which looks to me like "alert" will be

Equivalent of Alert() and Prompt() in PHP

戏子无情 提交于 2019-12-05 19:01:41
In JavaScript, we have Alert() and Prompt() which open up a popup box for the user. Is there an equivalent for PHP? $Get_['asdf'] is one way to get user input... any others? Also, one more question. Is it a requirement that PHP always be executed all at once? Or can it be like JavaScript, where it waits for the user input (e.g. popup box), then executes the rest of the code after that. PHP is a server side language, it can't do alert messages on the client side. But you can use javascript within the php to do the alert. <script type="text/javascript"> window.alert("Hi There, I am the Alert Box

How to enable Windows console QuickEdit Mode from python?

女生的网名这么多〃 提交于 2019-12-05 15:07:10
I'd like to force QuickEdit Mode in the console when running a python script and then disable it right before terminating. Is there a way to do that? You can use ctypes to call GetConsoleMode and SetConsoleMode . ctypes definitions: import msvcrt import atexit import ctypes from ctypes import wintypes kernel32 = ctypes.WinDLL('kernel32', use_last_error=True) # input flags ENABLE_PROCESSED_INPUT = 0x0001 ENABLE_LINE_INPUT = 0x0002 ENABLE_ECHO_INPUT = 0x0004 ENABLE_WINDOW_INPUT = 0x0008 ENABLE_MOUSE_INPUT = 0x0010 ENABLE_INSERT_MODE = 0x0020 ENABLE_QUICK_EDIT_MODE = 0x0040 ENABLE_EXTENDED_FLAGS

Interaction between Python script and linux shell

泪湿孤枕 提交于 2019-12-05 13:29:50
I have a Python script that needs to interact with the user via the command line, while logging whatever is output. I currently have this: # lots of code popen = subprocess.Popen( args, shell=True, stdin=sys.stdin, stdout=sys.stdout, stderr=sys.stdout, executable='/bin/bash') popen.communicate() # more code This executes a shell command (e.g. adduser newuser02) just as it would when typing it into a terminal, including interactive behavior. This is good. Now, I want to log, from within the Python script, everything that appears on the screen. But I can't seem to make that part work. I've tried