Custom JQuery inputmask including time - jquery-inputmask

I'm using JQuery Robin Herbots' plugin. Please help me create period mask with placeholder:
"dd:hh:mm".
Where "dd" allows any number of days(from 0 to infinity),
"hh" - hours(00-23),
"mm" - minutes (00-59).
Tried via regex, but failed join it with placeholder. Thanks in advance!

Hope it will help someone spend less time on researching topic. Correct mask is:
$('#element').inputmask({
mask: "9{1,10}:h:eg",
clearIncomplete: true,
definitions: {
'9': {placeholder: "дд"},
'h': {placeholder: "ч"},
'e': {validator: "[0-5]", placeholder: "м"},
'g': {validator: "[0-9]", placeholder: "м"}
}
});

Related

How to get the actual meridiems in luxonjs?

So i tried to get the meridiems on luxon.js because i'm going to move my discord.js bot that is using momentjs to luxonjs because i like it more. But i got the problem that i just can't figure out how to get the meridiems of the timezone that i especify, could you help me out?
I've tried
Info.meridiems()
but i don't know how to use or what do i do with the Info part,
And then i don't understand the parameters that the give in their documentation as an example
Info.meridiems({ locale: 'my' })
it was kinda easy but i will not delete this post if someone needs it.
Basically what i did is to get the date in the format that i wanted
const time = DateTime.local().setZone('tz').toFormat("HHmmss");
in .setZone('tz') you should just put the time zone you want according to the luxon docs.
Then i would just use an if for it
const smartMeridiems = (am, pm) =>{
if(time > 120000){
pm = 'PM'
return pm;
} else{
am = 'AM'
return am;
}
}
And that is basically it
The meridiem for a DateTime can be accessed by the "a" format token:
DateTime.local().setZone(z).toFormat("a") //=> "PM"
The Luxon Info methods are for finding out what the meridiems are called in different human languages.

Couchbase Reduce function

I am trying to learn how to use map reduce functions with Couchbase. until now i created reports engines based on SQL using Where with multi terms (adding and subtracting terms) and to modify the group part.
I am trying to create this report engine using views.
my problem is how to create a report that enable users to dive in and find more and more data, getting all the way to individual ip stats.
For example. how many clicks where today ? which traffic source ? what did they see? which country ? and etc..
My basic doc for this example look like this:
"1"
{
"date": "2014-01-13 10:00:00",
"ip": "111.222.333.444",
"country": "US",
"source":"1",
}
"2"
{
"date": "2014-01-13 10:00:00",
"ip": "555.222.333.444",
"country": "US",
"source":"1",
}
"3"
{
"date": "2014-01-13 11:00:00",
"ip": "111.888.888.888",
"country": "US",
"source":"2",
}
"4"
{
"date": "2014-01-13 11:00:00",
"ip": "111.777.777.777",
"country": "US",
"source":"1",
}
So i want to allow the user to see at the first screen , how many clicks per day there are at this site.
so i need to count the amount of clicks. simple map/reduce:
MAP:
function (doc, meta) {
emit(dateToArray(doc.date),1);
}
Reduce:
_count
group level 4, group true
will create the sum of clicks per hour.
Now if i want to allow a break down of countries, so i need a dynamic param to change.. from what i am understand it can only by the group level..
so assume i have added this to the emit like this:
emit([dateToArray(doc.date),source],1);
and then grouping level 5 will allow this divide, and using the key too focus on a certein date.. but what if i need to add a county break down? adding this to the emit again?
this seem to be a mess, also if i will want to do a country stats before the source.. is there any smarter way to do this?
Second part...
What if i want to get the first count as follow:
[2014,1,28,10] {ip:"555.222.333.444","111.222.333.444","count":"2"}
i want to see all the ips that are counted for this time...
how should i write my reduce function?
this is my current state that doesnt work..
function(key, values, rereduce) {
var result = {id: 0, count: 0};
for(i=0; i < values.length; i++) {
if(rereduce) {
result.id = result.id + (values[i]).ip +',';
result.count = result.count + values[i].count;
} else {
result.id = values.ip;
result.count = values.length;
}
}
return result;
i didnt get the answer format i was looking for..
i hope this is not to messy and that you could help me with this..
thanks!!
For the first part of your question, I think you are on the right track. That is how you break down views to enable coarse drill down. However, it is important to remember that views are not intended to store your entire documents, nor are they necessarily going to be able to give you a clean cut swatch of data. You probably will need to do fine-filtering within the access layer of your code (using Linq perhaps).
For the second part of your question, a reduce is not the appropriate mechanism to accomplish this. Reduce values have a very finite (and limited) size and will crash the map/reduce engine once they get too big. I suspect you have experimented with that and discovered this for yourself.
The way you worded the question, it seems like you wish to search for all IP addresses that have been counted "X" number of times. This cannot be accomplished directly in Couchbase's map/reduce architecture; however, if you simply want the count for a given IP address, that is something the map/reduce framework has built-in (just use Date + IP as a key).

Nokia Places API? Is there a detailed description of search results? And how heavity is this api used?

Has anyone worked with Nokia places API. I am not seeing a lot of activity on the community forum? I was curious about the level of use that it has in the industry? here is my question:
1) What is meaning of having []? What could have been specified here?
2) What is the unit of distance? is it meters? feet?
3) how accurate is vicinity? is this the real address of starbucks or just an approximation?
if approx. how accurate is it?
{ Starbucks } { position: [ 40.74864 , -73.98841 ] distance: 270 title: Starbucks averageRating: 0.0 category: { Coffee/Tea } icon: http://download.vcdn.nokia.com/p/d/places2/icons/categories/23.icon vicinity: 906 6th Ave ↵
New York City NY 10001 ↵
USA having: [ ] type: urn:nlp-types:place href: http://demo.places.nlp.nokia.com/places/v1/places/840dr5ru-846b0ffe4ec64caf83a11bafd4b5a5b9;context=Zmxvdy1pZD04ZWY4YTY4Ni1iN2RhLTVhYTEtOGM0Mi1kNjYxNTM0NGEyNThfMTM2MzAzNjEyNDY1Nl8wXzQ3NTEmcmFuaz0x?app_id=myappid&app_code=myappcode id: 840dr5ru-846b0ffe4ec64caf83a11bafd4b5a5b9 } ,
...Nokia places API. ... the level of use that it has in the industry?
The RESTful places API is used as a back-end service by here.com, so a places request is made to the service whenever a user requires more details about a place. As regards third party usage I haven't got the details. Personally I see using a place service as a good way of easily adding value to an app without much effort - say for example your organization has data about country-side walks - you could easily add value to your app by finding "places to eat and drink" near to your route(s) without needing to become an expert on pubs and restaurants - which would be outside of your domain of expertise.
1) What is meaning of having []? What could have been specified here?
I can't see having [] as being documented in the current release documentation - I believe it is a place holder for further information - if you read the definition of the extensible contract you will see that additional elements may be added to the feed at any time - your best bet here is to ignore the attribute for now.
2) What is the unit of distance? is it meters? feet?
Distances are in metres - you can use a function like the one below to convert
function calculateDistance(distance){
if (metricMeasurements){
if (distance < 1000){
return "" + distance + " m.";
} else {
return "" + Math.floor(distance/100)/10 + " km.";
}
} else {
if (distance < 1610){
return "" + Math.floor(distance/1.0936) + " yards";
} else {
return "" + Math.floor(distance/160.934)/10 + " miles";
}
}
}
3) how accurate is vicinity? is this the real address of starbucks
or just an approximation? if approx. how accurate is it?
Vicinity is described in the documentation here - it can be used to filter out more distant places if necessary. For an individual place the address element holds the full address details, with the address.text holding the formatted address. Regarding the specific place query - here.com has a Starbucks at 906 6th Ave. This can be confirmed by another source here.

google charts datetime type

Is it possible to use literal strings when instantiating a datetime type? (If no, skip) If so, does the - need to be a /? If that doesn't matter, please tell me what's wrong with this:
var data = new google.visualization.DataTable({cols:[{label: 'date', type: 'datetime'},
{label: 'power', type: 'number'}], rows: [{c: [{v:2007/12/01 00:12:00},{v:0}]},
{c: [{v:2007/12/01 01:12:00},{v:101}]}, {c: [{v:2007/12/01 02:12:00},{v:201}]},
{c: [{v:2007/12/01 03:12:00},{v:302}]}]});
(I already tried quoting literal datetimes.)
-Shawn
You might have to put it in Epoch format. try something like this
new Date("#epoch_seconds_go_here");
Here is the link that might help you

Flex: Binding to an MXML-esque "binding string" in action script?

Is it possible to specify MXML-esque "binding strings" in ActionScript?
For example, I want to be able to do something like:
MXMLBinding(this, "first_item",
this, "{myArrayCollection.getItemAt(0)");
MXMLBinding(this, ["nameLbl", "text"],
this, "Name: {somePerson.first} {somePerson.last}");
Edit: thanks for the responses and suggestions… Basically, it seems like you can't do this. I've dug around and figured out why.
(Shameless plug)
BindageTools can do this:
Bind.fromProperty(this, "myArrayCollection", itemAt(0))
.toProperty(this, "first_item");
Bind.fromAll(
Bind.fromProperty(this, "somePerson.first"),
Bind.fromProperty(this, "somePerson.last")
)
.format("Name: {0} {1}")
.toProperty(this, "nameLbl.text");
Note that BindageTools puts the source object first and the destination last (whereas BindingUtils puts the destination first and the source last).
Using ChangeWatcher (e.g., via BindingUtils.bindProperty or .bindSetter) is the way to go, yes. I admit it's a strange notation, but once you get used to it, it makes sense, works perfectly and is quite flexible, too.
Of course, you could always wrap those functions yourself somehow, if the notation bugged you -- both methods are static, so doing so in a way that feels more appropriate to your application should be a fairly straightforward exercise.
I could use BindingUtils or ChainWatcher, but then I'd end up with code that looks something like this:
…
BindingUtils.bindSetter(updateName, this, ["somePerson", "first"]);
BindingUtils.bindSetter(updateName, this, ["somePerson", "last"]);
…
protected function updateName(...ignored):void {
this.nameLbl.text = "Name: " + somePerson.first + " " + somePerson.last;
}
Which is just a little bit ugly… And the first example, binding to arrayCollection.getItemAt(0), is even worse.
Does the first parameter (function) of BindingUtils.bindSetter method accept anonymous methods?
BindingUtils.bindSetter(function()
{
this.nameLbl.text = "Name: " + somePerson.first + " " + somePerson.last;
}, this, ["somePerson", "last"]);
I hate anonymous methods and obviously it's even more uglier - so I won't recommend that even if it works, but just wondering if it works.
Never the answer anyone wants to hear, but just manage this stuff with getters/setters in ActionScript. With a proper MVC, it's dead simple to manually set your display fields.
public function set myArrayCollection(value:Array):void {
myAC = new ArrayCollection(value);
first_item = mcAC.getItemAt(0); // or value[0];
}
etc....
Alright, so I've done some digging, and here's what's up.
Bindings in MXML are, contrary to reason, setup by Java code (modules/compiler/src/java/flex2/compiler/as3/binding/DataBindingFirstPassEvaluator.java, if I'm not mistaken) at compile time.
For example, the binding: first_item="{myArrayCollection.getItemAt(0)}"` is expanded into, among other things, this:
// writeWatcher id=0 shouldWriteSelf=true class=flex2.compiler.as3.binding.PropertyWatcher shouldWriteChildren=true
watchers[0] = new mx.binding.PropertyWatcher("foo",
{ propertyChange: true }, // writeWatcherListeners id=0 size=1
[ bindings[0] ],
propertyGetter);
// writeWatcher id=1 shouldWriteSelf=true class=flex2.compiler.as3.binding.FunctionReturnWatcher shouldWriteChildren=true
watchers[1] = new mx.binding.FunctionReturnWatcher("getItemAt",
target,
function():Array { return [ 0 ]; },
{ collectionChange: true },
[bindings[0]],
null);
// writeWatcherBottom id=0 shouldWriteSelf=true class=flex2.compiler.as3.binding.PropertyWatcher
watchers[0].updateParent(target);
// writeWatcherBottom id=1 shouldWriteSelf=true class=flex2.compiler.as3.binding.FunctionReturnWatcher
// writeEvaluationWatcherPart 1 0 parentWatcher
watchers[1].parentWatcher = watchers[0];
watchers[0].addChild(watchers[1]);
This means that it is simply impossible to setup curly-brace MXML-style bindings at runtime because the code to do it does not exist in ActionScript.

Resources