user-input

User input parsing - city / state / zipcode / country

徘徊边缘 提交于 2019-12-04 23:42:09
问题 I'm looking for advice on parsing input from a user in multiple combinations of City / State / Zip Code / Country. A common example would be what Google maps does. Some examples of input would be: "City, State, Country" "City, Country" "City, Zip Code, Country" "City, State, Zip Code" "Zip Code" What would be an efficient and correct way to parse this input from a user? If you are aware of any example implementations please share :) 回答1: The first step would be to break up the text into

How to allow caps in this input box program for pygame?

随声附和 提交于 2019-12-04 22:09:07
I found this input box module on the internet but it only allows lower case no upper. So could someone tell me what to change in the module to allow caps as im creating a small multiplayer game and i need login system and chatbox. Here is the code example I am working with # by Timothy Downs, inputbox written for my map editor # This program needs a little cleaning up # It ignores the shift key # And, for reasons of my own, this program converts "-" to "_" # A program to get user input, allowing backspace etc # shown in a box in the middle of the screen # Called by: # import inputbox # answer

taking user input array in java using scanner class [duplicate]

余生长醉 提交于 2019-12-04 21:59:26
This question already has answers here : How to put a Scanner input into an array… for example a couple of numbers (11 answers) Closed 5 years ago . How to take input from user side for array using scanner class? Any other method will also be appreciated. for example, if we need to create an array and then taking input from user side. Thank you!! SureshBonam Check the following code...It is for reading integer array public class TakingInput { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("enter number of elements"); int n=s.nextInt(); int arr[]

How to detect user presence in android?

二次信任 提交于 2019-12-04 20:18:00
问题 I know in Galaxy Samsung SIII it is possible to configure in settings an option to avoid the screen turns off when user is looking into the screen. I think the phone uses the camera or a kind of a sensor of presence. is it possible to do it programmatically? even if yes, some devices won't be capable to do that. I imagine some possibilities here: using the camera, accelerometer, or even user activity: if the screen is on, touches, I don't know. There is a specific library about "user presence

Multiple Key Gestures for custom keyboard shortcuts in WPF

旧巷老猫 提交于 2019-12-04 19:29:37
Does anyone know if it's possible to have key combinations for keyboard shortcuts in WPF? Right now if I want to use CTRL + S as a shortcut I can do the following: InputGestures.Add( new KeyGesture( Key.S , ModifierKeys.Control )); But if I want to use CTRL + S , D ... I don't have an overload that takes the D . Is there a way to override this an accept combinations? 来源: https://stackoverflow.com/questions/2194714/multiple-key-gestures-for-custom-keyboard-shortcuts-in-wpf

Ruby .gets doesn't work

ε祈祈猫儿з 提交于 2019-12-04 17:07:11
I'm trying to get simple user input in Ruby, but I can't get it working. I'm using the gets method, but the program never stops to ask me for input. I'm using Sublime Text 2 as my text editor, and I run the program in it, too (if this makes a difference). Here's my code: puts "What is your name?" name = gets puts "Hello " + name + ". How are you?" And here's the error (and output) given to me: C:/Users/Sten Sootla/Desktop/Ruby workspace/exercise.rb:3:in `+': can't convert nil into String (TypeError) from C:/Users/Sten Sootla/Desktop/Ruby workspace/exercise.rb:3:in `' What is your name?

Javascript search and display divs with matching keywords

让人想犯罪 __ 提交于 2019-12-04 13:18:45
问题 What I'm looking for: I'm working on creating an easy way for a user to search a list of people, and for results to instantly display below the search field. The results MUST display "close" results, rather than exact. For example: User searches for "Mr. Smith" and The following existing result is displayed: "John Smith" (since there is no "Mr. Smith" entry, it displayed one with the keyword "smith") What I have: I have a working code that lets the user enter some characters and all divs that

User input filtering - do I need to filter HTML?

寵の児 提交于 2019-12-04 12:27:50
问题 Note: I take care of SQL injection and output escaping elsewhere - this question is about input filtering only, thanks. I'm in the middle of refactoring my user input filtering functions. Before passing the GET/POST parameter to a type-specific filter with filter_var() I do the following: check the parameter encoding with mb_detect_encoding() convert to UTF-8 with iconv() (with //IGNORE) if it's not ASCII or UTF-8 clean white-spaces with a function found on GnuCitizen.org pass the result thru

What is the fastest way to determine a key press and key holding in Win32?

℡╲_俬逩灬. 提交于 2019-12-04 10:34:21
问题 What is the fastest way to determine a key press and also how to determine if a key is being held? It appears that window messaging is slow. Please provide an example of how to do so, and why it is faster than an alternative. To be clear, this for a real time loop (a simulation) so I am looking for the fastest way to determine if a key has been pressed and also to check to see if it is being held. 回答1: GetAsyncKeyState() is what you're looking for. It reads the physical state of the keyboard,

What are the difference in usage between Either and Except in Haskell?

淺唱寂寞╮ 提交于 2019-12-04 07:59:38
I have a class that can be created from several arguments in Haskell which requires some complex validation of those arguments. Currently I have something like makeAThingExcept :: String -> String -> ... String -> Except ThingError AThing makeAThingExcept s1 s2 ... = do unless (s1CheckPasses s1) (throwError (BadS1 s1)) ... data ThingError = BadS1 String ... instance Show ThingError where show (BadS1 s) = "Bad S1: " ++ s makeAThing :: String -> String -> ... String -> AThing makeAThing s1 s2 ... = case runExcept (makeAThingExcept s1 s2 ...) of Right thing -> thing Left err -> error (show err)