« first day (2447 days earlier)      last day (2503 days later) » 

12:00 PM
wtf, they replaced the Android SDK Manager entirely with that POS Android Studio
 
@amarghodke All you've done is return the first even value, what if there's another further in the array?
 
@rlemon omg
 
@BenFortune : i think my for part and if part is not perfect. how do test for even and odd ones ? any direction ??
 
man, he must have spent lots of time to setup that
 
12:09 PM
@rlemon woah that looks cool
 
@amarghodke you're on the right track but you didn't think further. There is an odd array but you never populate it. And you are already using return when the first odd number is encountered... Just think a bit further.
 
@amarghodke your solution doesn't work.
 
@BenjaminGruenbaum : only i have problem with even number of odd and vice versa.. any hint how i can pick evens and odds..?
 
@amarghodke The opposite of how you're testing for even.
 
12:19 PM
Don't overthink it, check the first 3 numbers, if they're all even or all odd then you know the outlier is the first you'll find that does not match them - if they're not all of the same %2 value just print the different one.
 
@amarghodke You're also pushing an odd number to the even array
 
do you use sockets to determine if a user who hasn't logged off is offline (because for example the user just closed the tab)?
or is there a better way?
I don't want to reply on window.onclose or similar, because maybe they just don't have an internet connection anymore
 
function outlier(str) {
  const arr = str.split(" ").map(Number);
  if(arr.length < 3) throw new Error("No outlier in under 3 items");
  let [a, b, c, ...rest] = arr;
  if(a % 2 !== b % 2 || b % 2 !== c % 2) {
    if (a % 2 === b % 2) return c;
    if (b % 2 === c % 2) return a;
    return b;
  }
  const normal = a % 2;
  return rest.find(x => x % 2 !== normal);
}
 
This is sweet for the price
Hi Bens!
 
and if a socket just doesn't get a reply within a certain amount of time and after a few tries, then you can know that the user is not online, right?
 
12:22 PM
@amarghodke 5 * ^ @Kramb
 
@ndugger wow.
@towc there is the navigator beacon api
and then there is good old heartbeat
and there is no way to detect if they closed the browser vs they just got disconnected
 
@BenjaminGruenbaum Why only the first 3?
 
@Shrek yeah, that's fine
 
I mean you can kinda sorta give them a one time token and not store it anywhere
 
looking at navigator.sendBeacon
 
12:24 PM
and expect them to send it back when they reconnect, but its not gonna do you any good, a smart user can just copy this and send it back to you
 
@BenFortune it checks the rest eventually - but 3 is what you need to figure out if the outlier is even or odd.
 
@Shrek wow what?
 
@BenjaminGruenbaum What if your array has 10 items?
Or 100
 
@ndugger Your Vue.js definition
 
@BenFortune it finds out if all the first 3 are even or odd - and then finds the first one that does not match them. That's the find in the last line.
If they're different however, it will just return the different one.
Actually maybe I can just check the first two?
 
12:26 PM
Ah I see
 
Nah, need 3
 
@Shrek it's true
 
There is no "odd one out" with 2
 
@Shrek I don't really see how that plays in :/
 
@ndugger I know, still, it was too graphic for my tastes
 
12:27 PM
Lol
 
@towc sendBeacon will tell you the browser tab closed. How you map to ws is on your server. If you want to do this ws only, the heartbeat is your only chance
what are you trying to achieve?
 
oh yeah, but doesn't fix the issue of no internet
 
Timeouts :P, nothing else can fix the issue of bad internet
 
I'm just trying to figure out when a user goes offline
 
Time him out
 
12:28 PM
@Shrek Elon Musk can ;)
 
@rlemon Elon Musk is not a thing
 
0
Q: percentage and vice versa calculations has issue in points jquery or javascript

Ram SinghI have three textboxes one for Quantity, second for amount and third for percentage. If i enter any value in quantity then according to it, i have to calculate the other two things and need to do this for all textboxes. I have separately the total amount of quantity and all other factors. Please ...

please help me
 
neither is your hair, but we can still talk about it
 
I think my best bet is what I said before: send socket data every minute or so, and if something doesn't come back, send again in 5 seconds, and if that doesn't come back, within 10 seconds, the user is offline (which just means not using the app)
 
#ohhburn
 
12:30 PM
that's a lot of sockets though
 
Wait nvm, Math for Dummies.
 
@BenjaminGruenbaum thanks but it is returning there direct values i want to return there index position i.e 3 and 2.
 
@amarghodke even easier
function outlier(str) {
  let [a, b, c, ...rest] = str.split(" ").map(Number);
  if(a % 2 !== b % 2 || b % 2 !== c % 2) {
    if (a % 2 === b % 2) return 2;
    if (b % 2 === c % 2) return 0;
    return 1;
  }
  return rest.findIndex(x => x % 2 !== a % 2);
}
 
hi guys
Q: I searched a lot, but I really can't find the option to create keyfile.json for google services to use their npm modules ... what I have is an API key, but where do I download that keyfile.json???
https://github.com/GoogleCloudPlatform/google-cloud-node
 
@BenjaminGruenbaum :findIndex is new function ??
 
12:34 PM
If you call "2 years old" new, sure
 
@rlemon wow.
 
@Suisse Download it from the developer console
 
@OliverSalzburg I am in the console - everything I see is the API Key of the cloud vision api I want to use - but nowhere this keyfile.json
wait I think it also works with the api-Key only
I'll try
 
@suraj : thank you..
 
12:42 PM
11
Q: How/where to obtain a .p12 key file from the Google Developers Console?

DrewdavidI am using a custom component with Talend Open Studio that allows me to connect to Google Analytics Part of the setup requires specifying the location of a .p12 key file I have created a Project in the Google Developers Console, but so far not able to find any mention of downloading a key file ...

 
Service account key! ahaaa thanks!!
 
where is my chibi panda
 
@FlyingGambit 🐼
2
 
morning cats
 
12:57 PM
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Oh fuck
 
In VS Code, how do I make it create the new file in the directory currently selected in the project tree?
Like, when I press Ctrl+N, it simply creates a new file that is stored nowhere
 
@KarelG how the hell did you fit that panda in a comment
 
@BenFortune Quick! Panic!
 
@FlyingGambit it's an emoij
🙃
 
stuck with changing css of ng-select in angular 2. Any help?
-1
Q: Changing css class properties based on condition (*ngIf in angular 2)

Rahul DwivediI want my css class to change based on condition. I'm trying to use this: <div *ngIf="dropDownBg==='Active'"> <style type="text/css"> .ui-select-toggle{ background: green !important; } </style> </div> <div *ngIf="dropDownBg==='Suspended'"> <style type="text/css"> .ui-select-toggle{ ...

if nothing, I'd appreciate a couple of upvotes so that it could be viewed by more people
 
1:02 PM
I just discovered something strange with password fields
 
do not ask for upvotes please
 
if you change it to type="text" and then focus on it. Press then the down key
I saw used passwords o.O
 
@ndugger "angular raped and murdered react".... when did angular murder react ?
 
Upvote plz
 
hey guys am running angualr2 applicaiton locally on two different browsers, the changes and navigations i do on one browser is reflected on other browser. what is the reason?
 
1:04 PM
Vap0r
 
@KarelG dv?
oh
downvote :(
 
still trying to make sense of mobx today without making spaghetti code :\
 
Make spaghetti code, make sense of it, and refactor?
 
TIL there is a weekday name tag
 
1:16 PM
you just make objects with whatever lifecycle you want. A long lived 'app store', possibly some longe lives 'domain stores', A 'ui store' that lives as long as the view is open (may be combined into the rect component, but doesn't need to be)
 
@FlyingGambit [tag:just-something-shit] gives
 
The only awkward part of mobx is that sometimes you want to de-reference a property later than you might naturally for efficient rendering
 
Does react have custom event listeners I can bind to for componentWillUnmount without having to write code in the unmount?
I'm trying to bind to any AJAX call made in the component, and fire aborts on all of them if it unmounts
 
the docs for componentWillUnmount tell you how to use it
unless i misinterpret the question
 
Yeah, a little bit. Let me write some simple code real quick.
 
what's that for a site
 
@Luggage we currently have something like this:
https://gist.github.com/michaelrwiley/9e2bd4102a590898bfe7d1921c799144
AjaxRequest is pretty much just a super simple wrapper that gives us reference to the AJAX call so we can call abort on it later.
I don't want to do this
 
meh
it's better than making your view component know more about the ajax call than it already does
 
Ideally I would like to be able to call my AJAX once, with a wrapper if needed, maybe passing in a reference to the component, and then have the wrapper class "listen" for componentWillUnmount. But I don't know if this is possible.
But I guess the root question is what is the best pattern/simplest way to make your component abort all AJAX requests in componentWillUnmount? And is there any solution that allows it without actually writing the abort into there?
 
1:25 PM
Not a good one that I can think of. I don't know of a way to listen for lifecycle events on other components.
and it feels wrong to
 
@KarelG Just something I built once. Domain is about to expire :'(
 
hmmm darn. So if we have this requirement then that wrapper is an ok way to do it...
 
ignoring the fact that the view triggers data loading which is discouraged.. yes
 
Ok, ideally that would be handled by what?
 
ideally triggered by a router or your own logic for loading and swapping views
 
1:28 PM
gotcha. Yeah we have some work to do here. state-management is kind of weird. We're using a couple of "contexts" stored in localStorage
 
how does that example even render before the data is loaded?
And does it update the component state to trigger a re-render? I dont' see that in the example
 
@Luggage yeah sorry I wasn't trying to illustrate that.
 
tell me more of these contexts.
 
@KendallFrey too soon
 
Oh sorry, the $.get callback would call setState
forgot to include that.
 
1:31 PM
ok. one small thing, none of the lifecycle methods need the = () => syntax.
 
It would set whatever data it got from the endpoint in state, and IsLoaded to true
 
useless bind
Since you do this on comonent mount/unmount today one way to get this out of every view without a major re-write is to make a wrapper or 'high level' component to do the data loading
and then just pass the fetched data down to the child as props
basically a generic component that accepts the component to put at "// WHATEVER" as a prop
 
@Luggage yeah we're well aware. We're doing it because a couple devs got confused and kept using function() {}.bind(this) because they didn't understand so the boss said to use the arrow syntax anywhere you specifically don't need function(){}
 
and the function for fetch data with
 
> basically a generic component that accepts the component to put at "// WHATEVER" as a prop
I'm not sure I'm understanding this part
 
1:34 PM
@KarelG
 
Do you have the other HLC examples I've given you in the past?
 
HLC? And no I lost most of the examples when I moved job positions
 
high level component
 
no, no and no.
one of those isn't even JS
 
1:37 PM
well yeah that was just cause I had it :)
 
it takes a component as a property
 
hrm, 9:30 and I already have to 💩
gonna be a long morning
 
[
    'handleChange'
].forEach(fnName => this[fnName] = this[fnName].bind(this));
We spoke about this before, but now I don't understand it. Why do you not have access to this.props inside handleChange?
 
this is just an alternative to the class property syntax you are using that I spoke about a few minutes ago
only I am only doing it for non-lifecycle methods that need it
 
oh ok gotcha.
 
1:41 PM
do you use mutiple "getMyEndpoint"s in some components?
btw getMyEndpoint would be what you name a function that gets / creates comething, not a variable to hold an already created one
 
Js Oracles, I summon you and need your assistance.
 
const getName = "bob";
 
Lol yes I think I've seen up to 3 or 4
 
@Vap0r That looks like it could be simplified
 
that's mine.
 
1:43 PM
I suppose you're going to suggest some type of array/queue management modification of AjaxRequest
 
and i use class properties these days
 
Also the name scheme is for consistency
 
Well, I was mostly referring to the part where it's looping over a fixed array of 1 element
 
that's because it's not always one item
and I don't re-write when i go from 2 to 1 and 1 to 2
 
@Luggage we do something like this for all our endpoints
 
1:44 PM
Alright, you'll get a pass this time
 
thanks. i'll be more careful
 
I need some suggestion on the optimal solution for my problem. TL;DR I'm trying to access a global variable that may or may not be set by the time my code runs. I know this is shifty but it's beyond my control. So I need to watch for an object and see when it has attributes inside. I've come up with 2 solutions thus far.
 
// top of file below imports
const endpointGetOffer = "/api/OffersAPI/GetOfferById"
// in constructor
this.getOffer = new AjaxRequest();
 
One is to create a timer and watch for the var to exist - jsbin.com/jikawasiwu/edit?js,console
 
1:45 PM
i see. it's named after the operation
 
The second one is to use the object.watch property with polyfills - codepen.io/Thaenor/pen/pwpyVo
which one's best?
 
@Thaenor The former, but your implementation sucks
 
Yes, I guess the implementation is so-so but if you're going to have data ops in your components I do actually like the name scheme
 
@Thaenor Don't use an interval, use timeouts. Start a new timeout when your previous check completed. Optionally increase delay. Plan for bail-out after X iterations
 
Vap0r i'll give you a sample of what i mean with a "hlc" / wrapper. you can decide if it'll work for you
give me a minute
 
1:48 PM
k thanks
 
You don't use an interval, because it could start a second check before the previous run completed btw
That is something to look out for in general
 
So you mean create a new timeout once the previous one ends?
Almost like a recursive function?
 
Alright, I'll update the code in a bit and see if I can get that to work.
 
hello
 
1:51 PM
Also consider the variable already existing when you start your checking operation
It could be beneficial to wrap the whole thing into a promise as that is a widely understood concept
 
@Luggage aaand ... the minute is over
 
take your time :)
 
Im a student and i have a work where i have to create a game in canvas, i have a problem with drawing, that is when pass 1 min or less it starts lagging and i cant figure out why i already tried set interval and done set the time to delta / (1000 / 60) and it got worst than i have got now. Even my teacher couldnt say what was wrong. Can anyone help? Code: pastebin.com/v1JkGR7i
 
listen to this while you wait
 
does anyone know when decorators are being added to javascript in general?
 
1:58 PM
@AndréMarques Open the Performance panel in your Chrome DevTools and dig in
 
Vap0r gist.github.com/luggage66/ea156478eb08ab796568f2a312477f14 This just moves the dataloading and aborting into it's own component so it does not need replicated every time you use it
 
@AndréMarques you need to use paths
 
not complete. i don't really use your "ajax" object.
 
implicit paths can be created and not closed otherwise
causing performance hits
 
@Luggage reading now
 

« first day (2447 days earlier)      last day (2503 days later) »