user-input

How to protect against diacritics such as Zalgo text

狂风中的少年 提交于 2019-11-28 04:20:47
The character pictured above was tweeted a few months ago by Mikko Hyppönen , a computer security expert known for his work on computer viruses and TED talks on computer security. In respect for SO, I will only post an image of it, but you get the idea. It's obviously not something you'd want spreading around your website and freaking out visitors. Upon further inspection, the character appears to be a letter of the Thai alphabet combined with over 87 diacritics (is there even a limit?!). This got me thinking about security, localization, and how one might handle this sort of input. My

Drag the Range of a UI Input Range Slider

被刻印的时光 ゝ 提交于 2019-11-28 04:10:34
<---------[]=====================================[]--------> 0 10 90 100 I need an input range slider with two handles to select a range, and the ability to drag the range (the equals signs in the above diagram). So, in the above example, start=10 and end=90, and it is dragged left by shifting the entire line between the two handles: <[]=====================================[]------------------> 0 80 100 Now Start is 0 and End is 80, accomplished without dragging the handles. What library offers this functionality? Thank you. Overview jQuery UI Slider widget extension for a rangeDrag feature.

Using wxPython to get input from user

こ雲淡風輕ζ 提交于 2019-11-28 04:03:34
问题 Suppose I need to replace the raw_input function in the following code with a wxPython dialog box that asks for user input and returns the value to program: ... x = raw_input("What's your name?") print 'Your name was', x ... I'm just looking for a simple way to do that. Thanks 回答1: Here is another simple way that does what I was looking for: import wx def ask(parent=None, message='', default_value=''): dlg = wx.TextEntryDialog(parent, message, defaultValue=default_value) dlg.ShowModal()

Correct way to escape input data before passing to ODBC

喜夏-厌秋 提交于 2019-11-28 00:20:04
问题 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! 回答1: 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

Python - Infinite while loop, break on user input

跟風遠走 提交于 2019-11-28 00:13:34
I have an infinite while loop that I want to break out of when the user presses a key. Usually I use raw_input to get the user's response; however, I need raw_input to not wait for the response. I want something like this: print 'Press enter to continue.' while True: # Do stuff # # User pressed enter, break out of loop This should be a simple, but I can't seem to figure it out. I'm leaning towards a solution using threading, but I would rather not have to do that. How can I accomplish this? I think you can do better with msvcrt: import msvcrt, time i = 0 while True: i = i + 1 if msvcrt.kbhit()

Shrinking font-size at a user types to fit in an input using Javascript

≯℡__Kan透↙ 提交于 2019-11-27 22:25:31
Apple's MobileMe uses javascript to change the font size in the email login on its homepage as the user types so that the text always fits in the available space without overflow scrolling. While I can see how how to execute a function on each keypress, I'm curious how one would go about caluclating the font-size each time so that it always fits into the input field. Is there a way to measure the length of a piece of text with a variable width font? How do they accomplish this effect? Try it out to see what I mean: http://www.me.com/ I've done this in the past using jQuery. You can measure the

Limiting Python input strings to certain characters and lengths

こ雲淡風輕ζ 提交于 2019-11-27 20:13:35
I just started learning my first real programming language, Python. I'd like to know how to constrain user input in a raw_input to certain characters and to a certain length. For example, I'd like to show an error message if the user inputs a string that contains anything except the letters a-z , and I'd like to show one if the user inputs more than 15 characters. The first one seems like something I could do with regular expressions, which I know a little of because I've used them in Javascript things, but I'm not sure how to use them in Python. The second one, I'm not sure how to approach it

Integer.parseInt(scanner.nextLine()) vs scanner.nextInt()

て烟熏妆下的殇ゞ 提交于 2019-11-27 19:56:32
My professor tends to do the following to get a number from the user: Scanner scanner = new Scanner(System.in); Integer.parseInt(scanner.nextLine()); What are the benefits as opposed to simply doing scanner.nextInt() ? java.util.Scanner.java has the following in it: public int nextInt() { return nextInt(defaultRadix); } public int nextInt(int radix) { // Check cached result if ((typeCache != null) && (typeCache instanceof Integer) && this.radix == radix) { int val = ((Integer)typeCache).intValue(); useTypeCache(); return val; } setRadix(radix); clearCaches(); // Search for next int try {

What is the difference in these ways to read in user-input?

Deadly 提交于 2019-11-27 18:48:36
问题 I came across this topic How to get basic user input for java and although the answer for this particular question was sufficient, I wondered why there are so many different ways to read in user-input. In particular what are the pros and cons of these different ways to read in user-input? When would it make sense to use one over the other? These where the possible ways mentioned in that post. Scanner class BufferedReader and InputStreamReader classes DataInputStream class Console class 回答1:

Simulate user input in bash script [closed]

拈花ヽ惹草 提交于 2019-11-27 18:42:20
I am creating my own bash script, but I am stuck at the moment. Basically, the script would be used to automate server setup in CentOS. Some software normally asks the user to type a password. I want the script to put the password that I have generated and stored as a variable instead of asking the user. When the message "New password:" appears during install, how can I make the script put the value stored in a variable $key as if the user had typed it, with a bash script? You should find the 'expect' command will do what you need it to do. Its widely available. See here for an example : http: