user-input

making valgrind able to read user input when c++ needs it

此生再无相见时 提交于 2019-11-29 14:50:10
I am trying to run my c++ program with valgrind, however I have some points in the program which require user input from stdin, but when i run with valgrind, it wont let the user input anything for the program, is there a way around this? Been searching all around but have not found the answer. I haven't tried it, but I found this in the man pages: --input-fd=<number> [default: 0, stdin] Specify the file descriptor to use for reading input from the user. This is used whenever valgrind needs to prompt the user for a decision. What happens if you specify a different fd (say, 3) for valgrind to

How to export user inputs (from python) to excel worksheet?

这一生的挚爱 提交于 2019-11-29 13:02:19
I am trying to develop a user form in python 2.7.3. Please note that I am a python beginner. How to export user inputs (from python) to excel worksheet? Thanks For writing your form, you may want to use Tk - it's built into Python ( import Tkinter ). For exporting to Excel, there are several options: write your data to a .csv file ( import csv ) then load it with Excel use a module to write to an .xls file use .COM automation to "remote-control" Excel Edit: ok, here's a more specific answer using Tkinter and xlwt: import Tkinter as tk import xlwt from xlwt.Utils import cell_to_rowcol2 class

Check if an Edit Text that only accepts number is not empty and the number is equal or less than 100

自闭症网瘾萝莉.ら 提交于 2019-11-29 12:47:05
I'm building an application for receiving grades and I want to make sure that the Edit Texts are not empty and the values are less or equal to 100 I wrote this line but it crashes the application if(Integer.parseInt(editText.gettext().toString()) > 100 || editText.getText().toString().trim().length() == 0) { //Error message for example } and this is the logCat 09-04 18:21:06.331 8649-8649/com.example.nima.myapplication E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.example.nima.myapplication, PID: 8649 java.lang.IllegalStateException: Could not execute method of the activity at android

Detecting that the user is away from the PC with .NET

梦想与她 提交于 2019-11-29 12:04:13
I have a desktop application in which I would like to know two things: Is the user currently on the PC (more specifically, is he giving any input to the PC), so I can change his state to "away" if needed; and Is the screensaver running right now, so I can perform more CPU intensive work during that time. I'm using C#/.NET. How would you suggest to tackle these two tasks? NOTE : WIN32 invocation will be just as good, as well as any unmanaged code solution. Phill http://dataerror.blogspot.com/2005/02/detect-windows-idle-time.html ^ Detect Windows Idle Time. :) The enabler for this feature is the

How can I use powershell's read-host function to accept a password for an external service?

扶醉桌前 提交于 2019-11-29 11:00:37
问题 I have a script I'm writing that makes a connection to a SOAP service. After the connection is made, I need to pass in a the username/pass with every command I send. The problem I have is that when I use read-host to do this, my password is shown in cleartext and remains in the shell: PS C:\Users\Egr> Read-Host "Enter Pass" Enter Pass: MyPassword MyPassword If I hide it with -AsSecureString, the value can no longer be passed to the service because it is now a System.Security.SecureString

How to create a function for recursively generating iterating functions

独自空忆成欢 提交于 2019-11-29 07:16:23
I currently have a bit of Python code that looks like this: for set_k in data: for tup_j in set_k: for tup_l in tup_j: The problem is, I'd like the number of nested for statements to differ based on user input. If I wanted to create a function which generated n number of for statements like those above, how might I go about doing that? def nfor(data, n=1): if n == 1: yield from iter(data) else: for element in data: yield from nfor(element, n=n-1) Demo: >>> for i in nfor(['ab', 'c'], n=1): ... print(i) ... ab c >>> for i in nfor(['ab', 'c'], n=2): ... print(i) ... a b c 来源: https:/

Linux/X11 input library without creating a window

一笑奈何 提交于 2019-11-29 06:57:37
Is there a good library to use for gathering user input in Linux from the mouse/keyboard/joystick that doesn't force you to create a visible window to do so? SDL lets you get user input in a reasonable way, but seems to force you to create a window, which is troublesome if you have abstracted control so the control machine doesn't have to be the same as the render machine. However, if the control and render machines are the same, this results in an ugly little SDL window on top of your display. Edit To Clarify : The renderer has an output window, in its normal use case, that window is full

Correct way to escape input data before passing to ODBC

与世无争的帅哥 提交于 2019-11-29 06:55:09
I am very used to using MySQL and mysql_real_escape_string(), but I have been given a new PHP project that uses ODBC. What is the correct way to escape user input in a SQL string? Is addslashes() sufficient? I would like to get this right now rather than later! Instead of string escaping the PHP ODBC driver uses prepared statements. Use odbc_prepare to prepare an SQL statement and odbc_execute to pass in the parameters and execute the statements. (This is similar to what you can do with PDO). 来源: https://stackoverflow.com/questions/5713837/correct-way-to-escape-input-data-before-passing-to

How to preform whitelist-based CSS filtering in PHP

心已入冬 提交于 2019-11-29 06:39:27
I am working on a site and I would like to make a user able to enter custom CSS into that will be publicly displayed. However, seeing as a good deal of XSS attacks can be preformed through CSS, I would like to be able to find a way to "clean" the CSS output, similar to how HTML Purifier works, by parsing the CSS, running the parsed CSS against a whitelist, and then outputting a new stylesheet based on the parsed and whitelisted CSS. Is there already a library like this out there? If not, is there a CSS parsing library that can be used to create a custom implementation? I guess you're going to

jQuery - remove user input text from textarea

∥☆過路亽.° 提交于 2019-11-29 06:11:35
问题 Okay I have a list of devices where i can select which to edit. I have 3 states for the edit. When no devices are selected, when 1 device is selected or when x devices are selected. The problem i have is when a user type some text in the textarea (commentField) and cancels the edit to edit another device, the text there was typed in the textarea won't disapere. It stays so when i get the new dialog for the new edit, the commentfield has the text from the old commentField (as if it wasn't