« first day (3176 days earlier)      last day (1776 days later) » 
02:00 - 17:0017:00 - 00:00

2:49 AM
i have a the question : So, if we use this question in javascript array objects. how we do that?
 
1 message moved to Trash can
@NguyenTungs Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
Can anyone help me?
`
[{
    id: 1,
    properties: {
        'property1': 'value1',
        'property2': 'value2',
        'property3': 'value3',
        'property4': 'value4',
        'property5': 'value5'
    }
},
{
    id: 2,
    properties: {
        'property1': 'value1',
        'property2': 'value2',
        'property6': 'value6',
        'property7': 'value7',
        'property8': 'value8',
        'property9': 'value9'
    }
},
{
    id: 3,
    properties: {
        'property9': 'value9'
    }
}]
`
I want get Percentage Matched property in percentage using javascript ?
result:
```
find
{
    'property3', 'value3',
    'property7', 'value7'
}
```
I would like to search for couple of property and i am looking for atleast 50% matches which is atleast 1 property should match with any of the two input Input Query
Can anyone help me? :(
 
 
3 hours later…
5:53 AM
@TylerH lol I do.
 
 
1 hour later…
7:07 AM
who uses vue.js here?
 
@NguyenTungs you need to make a pass for every object and for every property, and get each property value and its count
Then you only return the property values whose count is greater or equal to the half of the sum of all counts
 
7:22 AM
hey guys
hello, Neil the cat.
can anyone tell me is it possible to store a javascript in codepen.io and then call it by using the url of codepen? to save space in javascript section of Pin demos
 
what do you mean with "store a javascript"?
the codes? or just some data info
if talking about using it as a script source: answer is no.
 
@ARr0w yo
you could conceivably commit to a git hub repository and use the raw data link of the js as input to your web site
but I imagine that would lead to all sorts of problems, including your account being banned if they found out
 
@KarelG followed this guide (CodePen)[blog.codepen.io/2016/02/22/…
ah nevermind
@KarelG the code only
@KarelG ohkay
@Neil lets not do that then, cause my github account is important to me.
 
@ARr0w No, lets not :)
My point was that there may be ways, but unless the intended usage of the site is to store javascript scripts for you, then it probably wouldn't end well, nor would it be particularly stable
why can't you save it locally?
 
0
Q: Convert UTC date time According to User's Timezone Angular

Ram SinghI have to show date and time according to user's timezone. I have saved the UTC date time while insertion into DB. I have tried below code but it is working only in Chrome: let dateTimeConverted = new Date(new Date(jsonObject.calculationDateTime) + '.000Z'); I am able to get current user's tim...

 
7:44 AM
unfortunately my question is still hanging there without an answer :D
 
you can use a file hosting service (eg dropbox)
but they will throttle traffic if you are making too many requests
 
yeah that's not really it's intended use
 
You can use Github pages.
 
well, since he said that it is for demo purposes ..
 
pretty sure dropbox has checks to ensure that you're not abusing the service in that sense
 
7:45 AM
I did that when I was a student
 
good point
aren't there like online ides out there where you can host a web application and "host" a javascript link?
That would probably be most flexible as well, as you could add css or whatever and you're not even using it so much differently than its intended usage
 
Github
Pages
 
@RamSingh please don't post your question often. You have posted one. If someone here can help and has time for that, he could do that. Please check the room rules for that.
 
@RamSingh What's wrong with the solution posted by schoolcoder?
browsers are finicky creatures. the last line of defense against browsers are libraries which deal with all these inconsistencies
Either you understand them and you fix them yourself or you depend on these libraries
 
Moment Js in Angular
 
7:59 AM
not everything has to be an angular extension
 
@KarelG

checkout the live chart :D

https://codepen.io/AkifAziz/pen/ewBYEO
 
@Neil meh, they should have done the Date API correctly before. Java did the same mistake with their pre- java.time API time classes
 
i have also added the bar chart full stack. but its incomplete
by the way, i can't able to smooth the transaction (left sliding) of this line chart
i'd really appreciate if you'd guide me what i am missing here.
 
@KarelG they've redone dates more than once for that matter
how they thought depending on a Calendar instance was ever a good idea, I'll never know
 
you don't say? At least they got it right with the new java.time
 
8:01 AM
@Neil dude i'm excited atm. Stop talking and go check it out.
:D
 
@ARr0w d3 is a decent library
more importantly perhaps is that it's flexible
 
@ARr0w I am bit too busy to check your codepen atm
 
@ARr0w my compliments, very fine work, sir :)
 
@Neil ty
 
0
Q: Putting value in a props from child to parent in vue.js is Error

AppleCiderYummyGood day, I'm trying to pass a value from child to parent using the props but I'm having an error that says, Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop bei...

 
8:06 AM
Broken for me
 
@BenFortune that's the array in tick, didn't declare it as an array.
but i've been struggling with the "too late, already running" one
there. Done. declared it as an array.
 
A quick google says you can cancel the current transition using .transition() before running the next one
eg: svg.selectAll('.x').transition().transition(tr).call(x.axis);
Your X axis transition doesn't line up with the chart data either, looks weird
 
Hey guys, wondering if possible to download and rename files on fly. Something like www.example.com/image-1.jpg, 2.jpg, 3.jpg to newname-01.jpg, 02.jpg, 03.jpg etc ? save it as zip on click ? any ideas ?
 
@Andie31 Yeah, are you in control of the server?
 
8:31 AM
@BenFortune thank you, maybe i'm not good with the google keyword search
 
@BenFortune unfortunately not :(
@BenFortune any ideas ? please please :)
 
8:51 AM
 
hey guys
 
@Andie31 since you don't have a server, better to keep it simple and let the user download those images one by one (check the link that Ben just posted here for that)
 
@KarelG Thank you guys but one by one would be a pain :(
 
it just a click event on those images?
 
something like that I have in my mind but dunno if possible to realize...an html form that user inputs the old name and the new name and it downloads them
 
8:59 AM
click on it -> get that image data -> put as blob -> instant download
@Andie31 you need a server for that. Bundling multiple blobs in javascript is a PITA
(or check for js zip tool)
 
All i have right now is this : codepen.io/anon/pen/gNXPaY
using already jszip
but can't figure out how to rename
 
Fancy that, missing out vital information
 
Ben Fortune - yeah, like renaming at first would be nice :( dunno how to achieve that
 
hey what is the FASTEST method to check if
3 is inside y=[1,2,3,4,5,6] ?
 
y.includes(3)
 
9:15 AM
if (y.includes(3) ){
   // code
}
that is the fastest processing way ?
 
It's usually on par with indexOf nowadays
 
it uses .indexOf internally
a bit additional checks but those are really negligible performance wise
 
@Andie31 You can change the name of the zip in the saveAs function provided with jszip
 
@BenFortune we are from that generation that actually checks the documentations 😛
 
RTFM
 
9:21 AM
but you can do that when adding the files to the zip tho
the first arg is the name you want
second the image data
then whatever options you want to use
 
I have this array which is coming from PHP script and I want to read it in javascript . Someone please help. pastebin.com/Q91c2LZD
 
json_encode it and read it in JS with JSON.parse
Assuming you're using AJAX, if you're embedding it inline you can do something like var foo = <?php echo json_encode($my_array); ?>;
 
Thanks.. actually I am creating HTML at server side and send it to ajax & then appending it at table body
 
Then try asking the correct question in future, because that's not what you asked.
 
But your answer worked which means my question is correct and you understood it correctly
 
9:32 AM
lol why did I come back
 
he's gotcha there ;)
 
9:45 AM
@Exception did you json encode a html string?
._.
 
@KarelG na .. array
 
why did you say
> Thanks.. actually I am creating HTML at server side and send it to ajax & then appending it at table body
 
what if you want to check if (x-0.5 or x+0.5) is inside y=[1,2,3,4,5,6] where x = [2,3,4,5] and if anyone of them hits i should execute a function ?
 
filter
 
@KarelG ohh my printing mistake
 
9:47 AM
@JRick .reduce + .filter
 
how would that work ? also all the numbers are strings
 
map and filter
 
could you give me an example ?
 
!!afk reviving a server
 
9:50 AM
F
 
@BenFortune problem is that I cant get total count of these elements using .length property
 
Give us something to work off.
 
ok
I have an image .. How to show here. is there any site like pastebin for images?
 
ok it's not working
 
Got it..
 
10:00 AM
because it's not a list any more
x can be any float number
 
@BenFortune How to count such elements?
 
y= [1.2.3.4.5.6.8.9.0.3.2.5]
x = [0.01,0.02 ~ 1000]
i just want to check if y.includes(x inbetween x+0.5 or x-0.5) {
 return int(x);
}
is that possible ?
like when x hits range between 0.5 to 1.5 it should return 1
 
It's an object
 
object?
 
Sorry that was to @Exception
 
10:05 AM
oh ok np
 
You have arbitrary properties along with your items
How are you getting your data @Exception?
@JRick I've told you, filter.
Stop fucking vamping
 
okay.. it was an array in PHP then I just json_encode it then in javascript I am doing like this-
result = JSON.parse(result);
and I am getting result like I shown in that image
Then I will for loop it and will create <tr></tr> and append it to table body
 
@BenFortune lol sorry , but i'm not vamping , iam getting data out from a stopwatch that is not hosted by me and i dont have access to
but iam building extention for an event using it
so x ( the stopwatch time ) can be any float number , it's not a list
i should just send certain events at certain time
anyway i will read more about the filter and see what we can do
 
10:23 AM
@Exception fyi image not found
just print the result in pastebin and post it here
 
click on that image please
I can see
 
> image not found
probably a routing problem from my end.
okay. php delivers an ugly encoding
just loop through the object properties using for of, object.keys or object.values (preferred)
 
10:42 AM
whenever you have time, i'll appreciate if any of you can help in smooth transition() of chart
thanks
 
11:29 AM
 path.data(obj.data).attr('d', line).attr('transform', function(d) {
                                return 'translate(' + x(new Date(d[obj.dataKeys.keyX])) + ',0)';
                            }).transition().transition(tr);
didn't work :@
 
@BenFortune I was wondering if I can change the name of the jpg files, not the zip filename...that doesn't matter to me :( sorry if too many questions
 
You've got your answer above
2 hours ago, by KarelG
https://stuk.github.io/jszip/documentation/api_jszip/file_data.html
 
11:45 AM
*sings RTFM*
 
Hi Abhishek. *sings RTFM loudly *
 
screams RTFM
 
is there a any calendar plugin to make a calendar like google calendar
?
 
yeah many
 
11:47 AM
I think google calendar has a plugin that lets you use a calendar like google calendar
 
Why not just use google calendar
 
^
 
In fact the plugin is called google calendar
 
umm, I'm working on leave management application, now client wants a calendar like google so they can just see on what date they have applied the leave
sort of event calendar
 
> I want something like X
> Why not just use X
 
11:50 AM
haha
I'm afraid of complication of integrating it
 
It's definitely going to be more complicated to roll your own
considering you need to build the back-end too
 
^
 
@BenFortune yeah, I understand
 
don't let it intimidate you
check it out, see if it fits
worst case scenario is that it's more trouble than its worth
 
is it a part of G suit?
suite**
 
12:01 PM
lmao
user image
4
 
HAHAHAHA
 
 
1 hour later…
1:06 PM
is there is a way i can say y.includes (range of numbers between x-0.5 ,x+0.5)
where y = [-2,-1,0,1,2]
 
3 hours ago, by KarelG
@JRick .reduce + .filter
in case you missed that comment earlier
 
it is just y.filter(value => x-0.5 >= value && value <= x+0.5)
if x is not a single value (array as you said) use .reduce. Read the documentation.
 
@Neil thanks !
 
@KarelG You mean filter, right?
 
OINK
thanks
 
1:09 PM
@KarelG ohh ok that sounds simple , i was trying to use filter , i couldnt get it done as the stop watch works really fast
 
you have 1 seconds time for that
 
i need like 100ms
i will check the reduce documentation hopefully its simple enf
thanks a lot !!
 
many CPU's are > 1GHz nowadays, so you have in theory room for 1 000 000 000 instructions per seconds
that line I just gave to you does not even lead into 1000 instructions
 
yea that is pretty fast !!
 
in practice most CPUs have CISC design and therefore occupy multiple cycles
if it had been RISC architecture, then you could say that for sure
 
1:14 PM
but since it's not a single value and iam going to use reduce and probably creating a new array every part/ sec , it might get some challenging for certain cpus
 
if branches will require at least one nop operation
and multiplication requires several steps (2?)
 
I really should stop drinking.
I'm inside my apartment, but can't remember where I left my keys when I came home last night.
 
Is it 1199 room? :D
 
Is there a good and popular fetch wrapper library that gives you all the bells and whistles you want and has a lot of support?
 
> I picked the wrong day to stop drinking..
 
1:27 PM
The best day to stop drinking is always "tomorrow".
 
@zbeedatm Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
1:42 PM
@Hypersapien fetch library? as in ajax?
 
@Hypersapien axios
 
2:21 PM
@MadaraUchiha I need enlightenment, why do people reccomand axios over fetch api ?
 
@Baldráni It's a unified API between NodeJS and the browser.
Also, the fetch api is only nice if you need simple things.
 
right
Never was in a place where i need complicated thing from fetch
Could be a reason
 
Hmm define "simple"/"complex"?
The fetch API is quite basic - but I can't really see how you would need more.
 
2:35 PM
@paul23 Downloading/uploading files, for example
Also, that you need to know to do res.json() and that it returns a promise, and that it's stateful (you're only allowed to call it once), etc.
These are low-level concepts that you shouldn't need to be aware of to write an application that fires HTTP requests.
 
@paul23 A 'finally' callback, a timeout parameter
A 'beforesend' callback
Not having to have two separate .then() callbacks to interpret json
The ability to post values as an object instead of a string.
 
It's just a nicer API overall, even for the simpler case.
And, as mentioned, it's also the same between Node and the browser.
So if you, for example, want to share JS files (models, services, etc) between the backend and frontend, you can do it more easily.
 
2:59 PM
Hmm I guess that's fair (especially the fact that reading data behaves like C++ input iterators/fetch object is stateful): but I always wrap request apis anyways. Doing that is almost a requirement for making mocks/stubs.
 
3:20 PM
@paul23 why? that makes it clumsy.
 
i don't understand why is this simple function not working properly
it's suppose to give me result ( 2 )
 
btw, IIRC there is a library that allows you to mock axios easily. It is just a wrapper around that
 
jsfiddle.net/fkdvamox or orgonized version of it
 
just check your condition in the filter?
it is wrong
 
it's wrong both ways
it results 0,1,2 instead of just 2
any idea why ?
 
3:31 PM
do the math
 
y.filter(value => x-0.5 <= value && value <= x+0.5) ;
got it !
thanks :D
 
:)
 
if anyone was interested here is the final result jsfiddle.net/fkdvamox/2
 
@JRick A more mathematically accurate form would be y.filter(value => Math.abs(x - value) <= 0.5)
i.e. "the distance between x and value is less than or equal to 0.5"
 
@MadaraUchiha sounds a bit intelligent but i don't know why
"Math.abs(x - value) <= 0.5"
Math.abs(x - value) , value is unknown at that point
 
3:45 PM
@JRick of course value is known. Value is the current element looked at by .filter().
 
oh yeah!! i forgot
 
3:58 PM
In angular cli 7/8.. what is the best practice for getting the value of this input control?
      <input
        id="color-picker-input"
        class="input-color"
        type="color"
        colorpick-eyedropper-active="false"
        (change)="changeColor(this)"
      />
  changeColor(element) {
    console.log(element.value());
  }
 
4:15 PM
I'm working with some legacy angularJS code here, and I'm trying to update the build process for it
but I don't really know all the different front end technologies (I barely know how to use npm) so I'm struggling
basically our source code consists of a bunch of angularJS code, a bower.json with our dependencies, and a bunch of SASS
oh, and a template index.html, without the script tags
I need to pull the deps, compile the sass to css, and inject the deps, our JS code, and the CSS into the index.html
what would be the simplest and most natural way of doing that?
I looked at webpack, but it doesn't seem adapted to our use case at all since it only injects code that it can reach through the import graph
which seems like I'd have to go through our code figuring out who uses what and adding imports everywhere
 
4:29 PM
How did it work before?
I tend to avoid wholesale replacing a working build process for an old project, instead opting for doing more incremental updates like bumping versions but leaving the general process in place.
 
I've basically got the codebase forked and I'm exploring options
 
@KarelG So I can pass a "unified" fetcher to my business class objects. Which then call functions on that fetch object. By making a wrapper, and mocking that wrapper I have full control over what is and what is not visible. Instead of having to first think how the fetch/axios class actually works.
 
the build process is currently gulp based and is broken and difficult (at least for me) to debug, so I'm considering just ripping it out and putting in something fresh
essentially the old way was to run "gulp build" and it did everything for us by pulling in a bunch of gulp plugins
 
@paul23 ehm ... why would you want to make this function or that function visible or not?
 
given the current programming culture, i would go forward with the best practice
 
4:39 PM
let's simplify it: assume that you are providing axios as an API interface and it has 5 functions. You are using 4 of them. So one of it is hidden
 
To make sure everything that can be used is fully tested/covered in the mocks/stubs.
 
ofc it helps if you want to swap libraries but ...
well, test axios itself?
 
Well it's exactly that: I switch between axios and a stub.
But it also makes it easier to later on use another api (ie socket.io): it decouples business code from the technology.
Obviously there are other techniques, in python I would use inheritance which allows for super class injection, allowing to override functionality.
 
is it just me? Does this demo I found work for anyone else?
http://jsfiddle.net/7f5ya562/103/
 
user1596138
@JoJo Open. Your. Console.
 
user1596138
4:49 PM
angular is not defined
 
@DJSpud roger wilco
I think this might be a modern approach I can look at for getting html5 input color value
0
Q: Set css variable with HTML5 color picker in Angular 5?

SteveI have an Angular 5 application with items styled in CSS with CSS variables, as in --color-links: #0000ff; a { color: var(--color-links); } So, I was trying to wire up an HTML5 color picker to allow changing this variable on the fly. I saw this article which showcases this pen where the autho...

 
user1596138
Foxtrot India November Charlie Hotel Alpha Tango
 
I am new to angular but it looks recent
over
 
user1596138
@JoJo It should work if you change the angular.js request to use a valid link
 
user1596138
The one in the Resources tab returns a 404
 
4:51 PM
@DJSpud looking
 
@JoJo Who gets to decide wha the best practice is?
 
user1596138
It's Angular 1 tho
 
user1596138
!!stat
 
@DJSpud You (https://stackoverflow.com/users/1596138/djspud) have 2508 reputation, earned 10 rep today, asked 8 questions, gave 31 answers, for a q:a ratio of 8:31.
avg. rep/post: 64.3. Badges: 1g 19s 41b
 
user1596138
Woot lol 2500 passive rep
 
4:52 PM
!!stat
 
@KevinB You (https://stackoverflow.com/users/400654/kevin-b) have 87100 reputation, earned 9 rep today, asked 7 questions, gave 2312 answers, for a q:a ratio of 7:2312.
avg. rep/post: 37.55. Badges: 13g 145s 163b
 
you have spent a lot on dv's tho
 
!!stat
 
@JoJo You (https://stackoverflow.com/users/443613/jojo) have 1348 reputation, earned 0 rep today, asked 138 questions, gave 0 answers, for a q:a ratio of TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡.
avg. rep/post: 9.76. Badges: 7g 31s 59b
 
user1596138
Hell yes I have
 
4:53 PM
Lol, I meant Kevin
 
i wonder how close to 100k i'd be if i hadn't cast 20k downvotes
err
28k
 
user1596138
Are you a bot
 
user1596138
holy
 
@KevinB my team environment. absolute must use latest / best practices
 
sad that you cannot track your own downvotes
 
user1596138
4:54 PM
@JoJo WHat's with the Angular 1 fiddle you posted? haha
 
I would find some stupid posts
 
@JoJo Right, but, who decides which practice is best?
 
to chuckle a bit
 
@DJSpud not mine, one I found trying to capture a input type color in angular.
 
user1596138
Right but if you're using best practices/latest code you wouldn't just be gogling for outdated angular 1 fiddles lol. You'd probably read the current documentation
 
user1596138
4:55 PM
Just my opinion
 
In JS i would be done by now....
      <input
        id="color-picker-input"
        class="input-color"
        type="color"
        colorpick-eyedropper-active="false"
        (change)="changeColor(this)"
      />
  changeColor(element) {
    console.log(element.value());
  }
 
that looks pretty simple
 
What is best approach in Angular 8 to capture this value?
 
What is `element?
stop asking for the "best"
 
I am trying to pass in this
 
4:56 PM
that's so useless
 
ok
 
So, what you have now
why isn't it working?
If you're asking us to rewrite stuff form angular 1 in angular 8, you're barking up the wrong tree
 
it says element.value is not a function
 
Ok, then what is it if it isn't a function?
 
a property
 
4:58 PM
add a breakpoint and find out, or log it
don't guess
 
I will console log it.
 
02:00 - 17:0017:00 - 00:00

« first day (3176 days earlier)      last day (1776 days later) »