mobile input number without triggering the digit keyboard - dart

In my mobile application I would like to provide an efficient way to enter digit but without triggering the digit keyboard...
In my idea I would like to display 2 big digits and slide on it in order to increase/decrease the value
a bit like the 2 last left items that http://media.mediatemple.netdna-cdn.com/wp-content/uploads/2013/05/mobile-input-type-date_mini1.jpg
I didn't find something that fits my needs in polymer element core/paper.
I saw that paper slider
is great for little value but greater than 20 it's not easy to use
Do you guys know a lib or something ? thank you !
update
to be more precise, < input type="time"> is what I would like in terms of design :)

Checkout this component it's pretty good and it works well with the latest version of polymer (0.5.1)
It fits Google's material design specifications.
I have used it after some modifications.
Here is a live demo.

Related

Parsing one number into multiple tokens in ANTLR

I am trying to use ANTLR as a parser for my company's latest project. I have been unable to find any information on how to parse one number, say (0005039906179210835699175654) into multiple tokens (a 5 digit number, a 3 digit number, a 14 digit number, and a 6 digit number).
My current code spits back an error,
line 1:1 no viable alternative at input '0005039906179210835699175654'
Also, on another note, does anyone know how to get the name of a token by using a listener? That's just a bonus question I guess :) Thanks in advance to everyone who responds!
EDIT:
To clarify the whole problem, my company receives information in a legacy format from automated systems. This information must be parsed into POJOs for further processing. I am trying to use ANTLR as an easy, smooth, readable, and expandable solution to this. One example is this line:
U0005138606179090232769522950 0863832 18322862 0284785 3
Which must be parsed into the sections: U, 00051, 386, 06179090232769, 522950, 0863832, 18322862, 0284785, and 3. Obviously the sections separated by white space are easy to parse but I have been unable to find a way in ANTLR to parse the values not separated by white space. Any help would be appreciated, thanks!
EDIT2:
To be perfectly clear as to why I'm using ANTLR instead of just java, my company receives messages in 5 legacy formats, and the system implemented to parse them must be easily expandable to accommodate more in the future. ANTLR is easy to read and understand. Plus, it will be easier to construct additional grammars and listeners than try to maintain a random mess of java.
EDIT3:
I thought of a solution but it is pretty janky. My idea is to parse the 28 character number as one token, then split it using java from a listener since it is broken up the same way each time. I'll report back later today on whether I got it to work.
EDIT4, FINAL UPDATE:
I have chosen to go my solution mentioned in edit3. It is not pretty, but it works and it is fast enough. Thank your very much to everyone who commented, shared ideas, and stimulated thought!

Implementing Autocomplete in iOS

I am creating an application where I need to implement autocompletion when a user is typing into an text input, with the 10 nearest/highest ranking words appearing below the text field.
I've been given a fairly big list of around 80,000 words and their respective 'priority' - a number which determines how high up they appear in the autocomplete depending on the size of the number, like this:
"transport international";19205
"taxi";18462
"location de voitures";18160
"police";18126
"formation";17858
I am kinda new to iOS development and was wondering what is the best way to do this - should I split the 80,000 phrases into smaller files, or just keep it in one? What would be faster?
I have seen autocompletion used in an example for iOS but it was for a very small amount of suggestions - I haven't seen it done using a file this large before, and obviously I would like to make it as fast as possible for added user experience.
Any suggestions as to examples, tutorials or code suggestions would be greatly appreciated, thanks.
If you prefer something that does autocomplete but is a direct subclass of UITextField, then MLPAutoCompleteTextField may be of interest to you.
MLPAutoCompleteTextField works by simply asking its autocomplete datasource for an array of autocomplete suggestions each time the text in the textfield changes. It can even automatically sort words so that the ones closest to what the user is typing will appear at the top of the autocomplete list (using a Levenshtein Distance algorithm). Autocomplete suggestions can be simple strings, or objects that implement MLPAutoCompletionObject protocol.
Tip: For a large dataset of autocomplete terms, you'll probably want to break up your list based on starting letters. (Example: When the user enters the letter F, you give the autocomplete textfield only a list of words that start with F.)
MLPAutoCompleteTextField can efficiently sort several thousand suggestions in a reasonable amount of time, and will never block the UI while it sorts.
At the moment, weighted suggestions (that override the default sorting) aren't possible but it's a planned feature.
You may want to use this repo HTAutocompleteTextField, perfect solution.
https://github.com/TarasRoshko/TRAutocompleteView
Just conform TRAutocompleteItemsSource protocol and that's it. Protocol is designed with async support in mind. Demo app and sample TRGoogleMapsAutocompleteItemsSource should greatly help you with it.
This link worked well for me. Depending on your code, just don't miss the difference between UITextField and UITextView.
No extra libraries, just an easy custom UITableView and search function.

How should I do a date and time range selection in my Delphi application?

I want the user to be able to specify something like "Tuesday , from 10am till 11am".
Can I do this with one complex control, or would I be better off with 3 separate simpler controls, such as combo boxes, one for day and one each for start/stop times?
Would I be better off with 3 combo boxes, one for day and one each for start/stop times?
Go for whatever solution doesn't require natural language processing. It's less "cool" and might look a bit obsolete, but I bet it's easier for users because they can do all the selection with the mice and always know they get what they want. Natural language is hard, people might miss-spell things, enter impossible data or confusing data. What do you do if they enter something like this:
"Marţi, de la 22 la 21"
(intentionally written in non-English, with reversed hours in 24 hour format!). And don't even think about asking non-native-English speakers to WRITE dates in English, it's torture.
In other words, unless you have Google's ability to process natural languages in multiple languages, go for a plain multi-combo-box setup, with proper editors for each segment: one for date, two for times.
The JEDI VCL has a plethora of options.
If you want to be able to do something like the Google Calendar where you can select a range from say, 9 to 11 am visually, on a particular day, you can use the JvTimeFramework (personal organizer) components. For a single day view with times from a particular range to another particular range, the TJvTFDays component is ideal:
You click on the time where you want to start, like Google Calendar does. Then you type "Lunch with dave" and hit enter, then you grab the bottom of the square and drag it up and down to fix the duration, or drag the top of the square up and down to change the start time. If you double click it, you can directly input using a dialog box -- the Add Appointment dialog shown in the screenshot is only one option users have. They can work without that, and just directly input onto the day-timer page control.
Otherwise, if you want to stick to text entry, I would combine several controls, including a JvDateTimePicker.
Check out the examples\JvTimeFrameWork\PhotoOp demo in the JVCL examples folder for the above program.

Is it possible to tweak Solr hit relevance score based on length of content?

I have a Rails app using sunspot to do searches against a table with records of varying sizes. I want to adjust the score of the hit depending on how large a certain field is. This is to punish articles that have very little content but happens to have the term being searched for showing up at the top. Is that possible?
One technique: compute the body length at insertion time and give the whole document a Boost based on its higher length - you'd supply this Boost manually, for each document at index-time.
See this FAQ: http://wiki.apache.org/solr/SolrRelevancyFAQ#How_can_I_increase_the_score_for_specific_documents
This mailing list thread seems to kind of answer your question - and brings up another point that you might be thinking about this wrong.
http://osdir.com/ml/solr-user.lucene.apache.org/2010-05/msg00916.html
This quote is illustrative: "I have to ask, though, why you want to sort this way? The relevance calculations already factor in both term frequency and field length. What's
the use-case for sorting by field length given the above?"

How to Convert English to Cron?

I did some searching but haven't landed anything that looks useful yet but I am wondering if anyone knows of something (tool,lib etc) that can parse English phrases and translate them into a cron string.
For example: Every Tuesday at 15:00 converts to 0 15 * * 2
It seems like something that would have lots of gotchas and it would be preferable to benefit from someone elses work. You see it in a few nice sites/apps that can work out what you mean from a simple phrase rather than having some hideous user interface.
Thanks in advance.
Though this is an old question I would like to list out all libraries/tools that I know so far, so that this answer might help others who arrive on this page looking for the same thing:
JavaScript:
natural-cron.js (link)
friendly-cron (link)
PHP:
natural-cron-expression (link)
Ruby:
whenever (link)
Feel free to reply in comments, if you know about any other library which is not listed here :)
(Full disclosure: natural-cron.js has been developed by me & my friend, when no other library satisfied the needs of our project)
For Ruby there's "Whenever" which might provide a starting point: It translates quasi-english (actually it's valid Ruby) into cron strings.
Depending on how flexible you need it to be, and how willing to roll up your own sleeves you are, you could define a simple grammar for this.
Every would be a quantifier. You may need others but I can't think of any. Valid syntax might be:
Every (day-spec) AT (time)
Where day-spec could be a literal day (ie. Monday) or be a day of the month (ie. 30th Day) or some other syntax (I'd suggest fortnights but I'm not sure if Cron can represent those well).
Time could be specified using either 24 hour (16:00) or 12 hour (4:00pm) format.
Another syntax that you might want is:
Every (frequency) From (time) where frequency is basically (quantity) (unit) (ie. 10 Minutes). The from time enables you to set an offset (eg. Every 30 Minutes From 01:10am).
You'd probably need to sit down and figure out these details a bit more. But a rigid grammar could be implemented relatively easily using recursive descent.
Hmm, about those gotchas... How about also writing one that translates the cron params back to English? That way you can see if the parser "understood" you.

Resources