« first day (2755 days earlier)      last day (2207 days later) » 

6:06 AM
@Traitor so u want the main array to equal the comparison array?
also those are objects not arrays
 
i want the main array to lose it's objects
because the comparitor array is dictating what is to be analyzed
 
mainArray = {};
 
for example, it's dates
 
mainArray = comparisonArray;
 
that will only set it as a reference
u want mainArray = JSON.stringify(comparisonArray);
 
6:09 AM
the comparitor array has dates [jan 3 2018, jan 4 2018,...
the main array has ALL of them
i just want the comparitor ones
 
can you make a jsfiddle? im not sure what you mean
if i understand, i could do it, im good with objects and arrays
 
so if comparitor array has jan 3 - jan 8, tell main array to become jan 3 - jan 8 with it's values instead of ALL of them
 
If the comparator array is a subset of the main array, why not use mainArray = comparisonArray?
 
mainArray = JSON.stringify(comparisonArray);
 
because comparison does not have any values except the dates
main array has dates + values
 
6:11 AM
so u want to add the 2 objects together?
 
i want the main array with ALL values (.length of 100) to what the comparison dictates (3)
based on dates
 
you are litrally making no sense at all lol
can you make a jsfiddle
 
imagine a main array containing your business transactions since the business started
i want transactions from jan 3 - jan 8
so main array has to be filtered
 
He has an array of dates. He needs to iterate through his main array of date/value tuples and keep each entry that matches a date in the comparison array. This would be .where in Linq in C#
 
ok, like a query
 
6:13 AM
input is date range, output is a filtered main.array
main.array has ALL transactions since start of business, i just want the input's date range
input has 3 values: month, day, year
use this to filter main array --> mainArrayfiltered
 
ok i understand 1 second
 
the reason i wont fiddle is because this object array is complex with many values that are obtained dynamically
a lot of code tha ti dont know how to quickly fiddle it out
atleast at my shitty programming level :/
@person27 yes
 
well first off, its a very bad way of doing it
 
yea...
 
but i can try
so the main objects keys are dates right?
or like this?
 
6:16 AM
1 message moved to Trash can
@RachelDockter Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
comparitorarray = {month: 4, day: 1, year: 2018}
 
{
one = {date: 23/23/06, id:2342342},
two = {date: 23/23/06, id:2342342},
}
this is such a messy way, do u know about sql databases?
that should be the go to for this
 
the array literally looks like this:
 
user9539196
so if you post unformatted code it gets auto removed by caprica ?
 
Yes, annoyingly.
 
6:18 AM
dateArray = {4, 4, 2018}
dateArray[0][2] = 2018
 
user9539196
kinda overkill
 
its more confusing to me how your calling them arrays
 
user9539196
anyways
 
mainarray is an object array
 
user9539196
shrugs
 
6:19 AM
  for (var r = 0; r < dateArray.length; r++) {

        if(CreditDataList[r].MONTH == dateArray[r][0] &&
            CreditDataList[r].DAY == dateArray[r][1]&&
            CreditDataList[r].YEAR == dateArray[r][2])
        CreditDataList =

    }
 
thats just an object
 
@RachelDockter I really don't understand why this doesn't help. Are there any problems in JS with that?
 
@HéctorÁlvarez what do u mean
 
thanks for the input Rachel
 
What's the problem with assigning it by reference?
 
6:20 AM
let me write this the long and shitty way
and then when i post it il take your advice to make it look nicer
 
@Traitor im 99% sure u cant refer to an object like obj[index]
 
doing array = comparisonArray?
 
ill show u
 
datearray is a regular array
main array is an object array
 
var y = [2];
var x = [1];

y = x;

x = [3];

console.log(y); //will output 3
thats why u have to stringify it
 
6:22 AM
   for (var r = 0; r < dateArray.length; r++) {

        for (var c = 0; c < CreditDataList.length; c++) {
            if(CreditDataList[r].MONTH != dateArray[r][0] &&
          CreditDataList[r].DAY != dateArray[r][1]&&
          CreditDataList[r].YEAR != dateArray[r][2])
                CreditDataList = SPLICE IT
        }


    }
 
dateArray is an object literal. It is strictly speaking, not an array at all. That's because it uses the {} syntax specifying an object literal. [] is used for arrays. [{}, {}] is an array of two objects, for example.
 
so based on datearray's length, i want to splice anything from creditDataList that does not match the date of the comparitor array (dateArray)
datearray = [], creditdatalist = [{},...]
 
u got urself in a real pickle here
 
im almost done
 
@RachelDockter It didn't for me.
 
6:23 AM
it's the longer way of doing it
 
Array(1)0: 1
length: 1
 __proto__: Array(0)
It says y = 1 in the fiddle.
 
thats weird
 
i was going by this principle
 
why are we talking about this?
i just said that the comparison array is a regular array
creditdatalist is an object array
 
6:27 AM
im too confused with your objects array
if u can get a jsfiddle going i can do it
 
@RachelDockter Oh, it does misbehave
 
no it's simple, [{month:, day:, year:
 
yeh, objects and arrays go by refrence instead of value if that makes sense
 
I'm surprised nobody has mentioned how simple this issue is to solve yet.
 
exactly
im doing it the long way, im sure theres an easy 1 line filter/map method
 
6:29 AM
if its that simple why dont u solve it @person27 lol
 
Oh, I can solve it three ways.
Set intersection,
.filter(),
and direct looping
Sort the dates array, then sort the objects in the main array by date. Iterate through each object in the main array until the date is <= the first date in the dates array. Start and keep adding each element to a new array until you reach the end of the main array or an element with date > the date array. Track the index in the date array as you do this so you don't have to compare frequently. O(n+k) complexity.
 
@RachelDockter Apparently Objects, Arrays and all those complex structures are assigned by reference, but not the primitive types. Guess you need .slice().
Sorry for the confusion, as I said I'm not a JS man.
 
  let mainArrayLength = CreditDataList.length;

    for (var r = 0; r < mainArrayLength; r++) {

        for (var c = 0; c < dateArray.length; c++) {
            if (CreditDataList[r].MONTH != dateArray[c][0] &&
                CreditDataList[r].DAY != dateArray[c][1] &&
                CreditDataList[r].YEAR != dateArray[c][2]) {

                CreditDataList = SPLICE IT
            }

        }


    }
 
yeh pretty much
 
^ long way
iterate the length of main array, then use for loop on the date array
 
6:33 AM
@Traitor so u have actually done it, u just want a better way?
 
splice what's not in datearray
what would a filter/map look like?
i hate using for loops because im not doing it the best way
and it takes more time
 
mainArray.splice(r, 0); ?
any function or filter is inevitably going to loop through it
 
gime 1 sec, testing it
 
Usually most people don't use for loops like I said in practice, and will stick with functions that take lambdas to operate over arrays, like .filter and .reduce. The point of my algorithm is that O(n+k) is faster than the usual O(n^2) you would get.
 
one might look prettier but under the hood its doing the same thing, if thats what ur worried about
!!> x=5; console.log(typeof x);
 
6:46 AM
@RachelDockter "undefined" Logged: "number"
 
!!> x=5.53543453; console.log(typeof x);
 
@RachelDockter "undefined" Logged: "number"
 
.splice(r, 0); not working
 
do console.log(mainArray[r]);
see if thats the index you want to splice
 
 
1 hour later…
7:55 AM
o/
 
Morning javascriptites
 
I'm pretty optimistic about this. One of the most headache inducing problems was with dealing with precision.
 
hi
i have a json output like
[
  {
    "id": "ami-0323927c",
    "region": "us-east-1"
  },
  {
    "id": "ami-a23e0cc7",
    "region": "us-east-2"
  },
  {
    "id": "ami-031b707b",
    "region": "us-west-2"
  },
  {
    "id": "ami-c3bb97ba",
    "region": "eu-west-1"
  }
]
and i need to transform this into
 
reduce
 
8:08 AM
1 message moved to Trash can
@TapasweniPathak 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
 
    {
      "us-east-1": {
        "ami": "ami-fa468a87"
      },
      "us-east-2": {
         "ami": "ami-5bb98f3e"
      },
      "us-west-2": {
        "ami": "ami-57089b2f"
      },
      "eu-west-1": {
        "ami": "ami-b81e55c1"
      }
    }
 
what Ben said
 
what have you tried and why didn't it work?
 
1 message moved to Trash can
@TapasweniPathak Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
8:13 AM
  var mapping = path.resolve(__dirname, '..', '..', 'abc', 'mappings', 'sample-file.json');
  var details = require(mapping);
  latest.forEach((image) => {
    if (!details[image.region]) return;
    details[image.region].ami = image.id;
  });
 
o/ @Unihedron
 
sorry @CapricaSix i thought that is just two lines of code which i have to add after the message
i tried pretty simple and boring approaches.
1. created a dict with only
"us-east-1": {
"ami": "ami-fa468a87"
}
then tried to append new keys and values to it, it didn't work.
2. i then tried to have a file like the output and did something like
1 min ago, by Tapasweni Pathak
  var mapping = path.resolve(__dirname, '..', '..', 'abc', 'mappings', 'sample-file.json');
  var details = require(mapping);
  latest.forEach((image) => {
    if (!details[image.region]) return;
    details[image.region].ami = image.id;
  });
i can make it work but think that there are better approaches to it
 
Yes, functionally composing with reduce with a memo object would be the best.
 
Just because I'm bored
arr.reduce((a, b) => {
	a[b.region] = { ami: b.id };
    return a;
}, {});
 
Your code is probably not working because of !details[image.region], where the scope only guards when the detail doesn't exist
Or otherwise - if the details already exists, you want it to not do anything, but your condition is if the details don't exist ; so it's backwards
@Ikari Heya!
 
8:17 AM
what brings you to the js room today
 
The BigInt news
 
oh :B
 
@Unihedron Whats the BigInt news?
 
google it
 
8:23 AM
We had a long discussion about BigInt today
 
yeah I looked it up and I'm reading it now
 
@TapasweniPathak you look so happy in your profile picture, that's awesome :D
 
A smile a day keeps the frown away
 
What you're doing with the mapping sounds fine, for what it's worth you don't atually need to do a path.resolve since require paths are uniform across platforms
@Unihedron it's actually pretty cool - I tried 100n ** 10000n and it works reasonably faste
 
I thought you couldn't call it an integer if it had a decimal aspect, rational or otherwise
 
8:27 AM
Yeah BigInts aren't decimals or fractions, BigInt(1.5) would be a RangeError
 
It doesn't have a "decimal aspect"
 
Technically an arbitrary precision number value is a BigDecimal, isn't it?
 
Yeah, and I don't expect people would write BigInts with the eplicit conversion rather than a constructor
@Neil we don't have a BigDecimal type in JavaScript yet
 
bigdecimal is not a thing yet; it's hinted at within the post but not actual news
 
@BenjaminGruenbaum Just being pedantic on the usage of "arbitrary precision integer number type"
 
8:28 AM
:P
 
Though I suppose arbitrary precision could work with "negative" precision
 
@Unihedron Oh wow! Yeah in my studies I remember any number which has more than 15 numbers in it causes JS to metaphorically shit the bed.
That is very cool!
 
like an integer which counts numbers of millions with 6 zeros to the right of any number
 
@New_2_Code 53 digits actually, but yeah
 
odd that it would be 53
 
8:31 AM
it should've been 69
 
That's just how IEEE 754 works, it's the same way with Java, C or most other languages
 
@Neil If I remember right it has to do with the whole 64bit floating points. * Checking notes *
 
At 10 digits (2^32) bitwise operators stop working, at 53 digits it's unsafe altogether
 
@Ikari ( Í¡° ͜ʖ Í¡°)
I'm sure there's a reason
Just not immediately clear what that reason would be
 
@Ikari HAHAHA, SO FUNNY, BECAUSE THE NUMBER 69 -_-
 
8:32 AM
Aah found it: 0-51 bits equals the number itself | 52-62 bits = the exponent | 63 bit = the sign (positive or negative)
 
@BenjaminGruenbaum HAHA, IKR :'D
 
Hi, what is the proper way to connect to a postgreSQL database from JavaScript? I'm not able to make it works. I'vae made a question but I've tried the answer and I'm still stuck. Thanks in advance.
 
interesting
 
@Aker666 Welcome to the JavaScript chat! Please review the room rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
some languages like python and ruby then made their own "big integer" type that lets you keep magnitudes of precision on demand for integer types, floats are usually still IEEE754
 
8:33 AM
@Aker666 hey, is it safe to assume you're using Node.js?
 
yes
 
morns
 
yes, you can see the details on my question: stackoverflow.com/questions/50061095/…
 
@Aker666 are you able to connect to postgres from the CLI?
 
8:37 AM
New workstation arrived \o/
Time to set it up!
 
yes
 
@OliverSalzburg send photos when you finish
 
@OliverSalzburg nice!
 
@Aker666 I think that if the CLI connects and your code doesn't it's probably a bug with your particular setup and the pg client. You can try another driver and please consider reporting the issue upstream. Note that pg is very stable in my experience and I've used it tens of times and thousands of people use it . - so I suspect something different in your setup.
A good next step would be to run postgres locally and see if that connects, you can also try in the nodejs/help repo (StackOverflow is more for questions one can reproduce)
 
Ah, ok. I will try, thanks for the help.
 
8:44 AM
Sure
 
9:01 AM
@Aker666 I can't make sense for your question. It's hard to follow what you really want and how you test. Did you notice that client.query is asynchronous and that you don't await the result ?
(BTW I confirm that node-pg is very stable and can run for months with millions of queries without problem)
 
9:18 AM
@DenysSéguret I'm learning Node by myself, I didn't know it. I will look how wait for the response if it's async, thanks
 
@Aker666 It's really very simple if you just use async await from one end to the other, with db accesses
Like in the doc:
const { Client } = require('pg')
const client = new Client()

await client.connect()

const res = await client.query('SELECT $1::text as message', ['Hello world!'])
console.log(res.rows[0].message) // Hello world!
await client.end()
(it works the same when using a pool)
 
9:34 AM
console.log('Before');
const query = await client.query(new Query('SELECT ST_GeometryType($1) FROM $2.$3 LIMIT 1', [column, schema, tableName]));
console.log('After');

Why only prints before and not after? With await, the script stops until client.query finish, right?
 
Ohhai
 
"const query = await client.query(new Query(" ???
You await the result, not the query. And you don't have to pass this new Query object, just do as in the exemple
Of course you need to try/catch
 
9:53 AM
I'm going to see if my environment has any issue, because it not works.

let client = new Client(connectionString);
await client.connect();
console.log('Before');
let result = await client.query(`SELECT ST_GeometryType(${column}) FROM ${schema}.${tableName} LIMIT 1`);
console.log('After');

Because now, it doesn't print anything.
 
That would seem to indicate that you can't connect to your client
 
Hello, any one there to help in service worker javascript?
 
@raju_eww Welcome to the JavaScript chat! Please review the room rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
10:09 AM
This new machine is spectacular at Windows updates
Sadly, the Microsoft download servers are not
 
send nudes
 
@OliverSalzburg isn't it p2p?
 
10:33 AM
I disabled p2p, but it is LAN only anyway according to a colleague
I just don't get how a cloud company can have such shitty download rates
 
I waiting for the pic :(
btw, what's a "shitty download rate", for you?
in numbers
 
In the last 30 minutes, it went from 41% to 44
 
It downloads from local computers first iirc
Could it be that?
 
@OliverSalzburg ok, and what's the download size
 
I just said I disabled p2p :P
 
10:40 AM
so I can do quick maths
 
p2p usually means over the internet :(
 
And no. Microsoft download servers are always Shit
 
p2p used to mean peer to peer
 
pear to pear is Apple's least favorite file transfer method.
 
it is indeed
they prefer the master-slave method
 
10:42 AM
Colleague was wrong. It's not LAN only
 
I thought there was 2 separate options is what I meant. I seem to remember turning off p2p and local separately
 
I prefer not helping Microsoft with their bandwidth costs though
There was only one option during setup
Oh now I see it
Disabling p2p during setup makes it LAN only
 
There's a whole bunch of setting in here that weren't here before
You can defer updates for a year, pause for a month
might want to check that setting too
 
Yeah. You can only access those after the setup
And during the setup is when it downloads the update
 
10:58 AM
@Cereal it is possible to set it to 120%?
my editor doesn't recognize -ms-transition
 
is there even such a thing?
 
the designer put it there
so I guess
 
11:34 AM
> Guess six numbers and win $50
Bro if I wanted to play the lottery I'm going for more than 50
 
@KendallFrey Nobody said anything about guessing the numbers correctly
That's as good as $50
 
Write a program which loops that shit. I could make a cool million in under a minute
 
Nobody said anything about guessing more than once
 
I knew it was too good to be true
 
11:49 AM
I've got a question up, I need to go some lunch though. Been reading for too long. If anyone wants to take a crack at it. (Won't be here to reply to questions right away.)
0
Q: Removing Duplicates in a Google Sheets Spreadsheet

New_2_CodeI have spreadsheet with some data in it: Staff No. - First Name - Last Name - Age 12345 - John - Doe - 29 12345 - John - Doe - 30 12456 - Jane - Doe - 29 12345 - John - Doe - 29 I have found some code that allows me to remove dupl...

 
@KendallFrey I guess 1 1 1 1 1 1, now pay up
 
@BenjaminGruenbaum Here you go: $50
 
Thanks, this was a pleasant transaction, I will leave a positive 5 star review
 
but one user can only leave 1 star :P
 
than I shall give 0.9 stars
 
11:55 AM
review of one maple leaf
 
12:06 PM
@KendallFrey 13572391345, 238746219531432, 238143135, 83651345145, 587326453454326, 82421354234123
for instance
what's the probability of guessing 6 numbers between 0 and infinite?
 
100, assuming you guessed 6 numbers
 
(1/infinity)^6 ??
 
9c6, that should be the possible combinations of 9 elements into 6 possible combinations
 
even if you guessed incorrectly, you still guessed 6 numbers
 
I thought "guess" included the "correctly" word
but now I feel winning lottery is even easier
 
12:09 PM
grilled bread
 
smoked ham
 
@ndugger this isn't a meme, I cannot verify, gimme a source
please use MLA citation
 
Is column level permission for a SQL User a sane thing to do ? OR should I just write an Rest API in front of it
Use-case here is a job worker, since I'll be executing custom code
I am using AWS Containerization, the container is fired with everything (aka Signed PUT URL, dependency files etc and I further limit what this job can do)
 
@Neoares 1
When asked to guess 6 numbers, the probability is 1
 
thats not very nice
 
12:21 PM
yeah, that was my point
to see if someone got that one :P
the answer is 1
 
Yay
 
:goes to bed:
:cries:
 
Wait, where's my cookie?
 
!!tell Cerbrus giphy cookie
 
12:22 PM
Yay
 
Wow there aren't many archs in this room, hmm.
 
when i return a value from an async function, does it get wrapped in a promise automatically even if the value is a promise itself?
 
@johnmarinelli Welcome to the JavaScript chat! Please review the room rules. Please don't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
 
@ShrekOverflow archs?
 
@GNi33 architects
 
12:29 PM
Hi JS geeks, could someone answer this question please:
https://stackoverflow.com/questions/50133776/mediarecorder-the-pause-and-resume-events-dont-work-in-firefox
 
@ShrekOverflow why do you think so?
 
@KendallFrey lol I was gonna complain about getting pings 6 hours after posting that but this twitter thread is legitimately amazing
 
Not surprising there's not a lot of data architects in a front-end language room
 
i mean, I'm none. I want to, but I'm at the very start of the journey
 
Cerea they could mean software architects
 
12:31 PM
Not surprising there's not a lot of software architects in a javascript room
 
@MikeTheLiar You're missing one half of a pair.
 
@Cerbrus I can improvise.
 
It's also not attached to .upperbody wut
 
@Cerbrus see the parent
 
12:37 PM
The fabled waistboob
 
@CryptoBird No idea, +1 though, good question.
 
This one's got veins included diana-adrianne.com/purecss-zigario
Dammit this is the second day in a row I wandered into 17 and got stuck with you degenerates.
 
fuckin degens from upcountry
 
was that some real Canadian talk?
Yellowknife, a bunch of mongrels
 
what's it to ya?
 
12:42 PM
@KendallFrey what's upcountry
wait, wrong joke
 
> I am a Country member! - Sir Winston Turnbull
> I remember. - Gough Whitlam
 
Currently trying to debug a bug that only happens at one customer site to one person
 
@MadaraUchiha thank you so much .
 
And I can't reproduce it. Iv'e been trying for 3 hours now
 
Those are the best kind
 
12:48 PM
s/ it//
 
On the plus side, I found a bug that was causing error messages to not appear
Not that I can get the error message to appear
 
I once had a bug which occurred on exactly one client after an installation of sql server
 
@Cereal Do you not use any RUM?
 
After work only
 
I use rum on a daily basis, what does this have to do with debugging
 
12:49 PM
I think every developer tried to fix it at a certain point
 
Because lots of them have client error reporting on them
 
We ended up just reinstalling sql server pretending like it never happened
 
No, sorry, what is rum
 
Fixed it right up :)
@Cereal Man you are fun at parties, aren't you?
 
I feel attacked
Someone solve my problems for me
mods
 
12:50 PM
kicks self
 
Violence offends me, stop attacking my beliefs
 
Your belief-attacking belief offends me. Stop attacking my beliefs
 
Stop being so exlusive
 
#include all;
 
Hey
How're the things
 
12:56 PM
@MikeTheLiar This .h file can now do everything. (What I get for working and typing)
 
@hilli_micha god.createWorld()
 
omg we were a computer simulation the whole time.. Elon Musk was right, he is the savior.
 
Oh so real question here for a second
Musk thinks we're in a simulation
He also thinks we need to colonize Mars and move to EV for the good of the Earth/environment
If we're in a simulation does it really matter?
 
I thought he just thought is was possible or an intriguing idea.
 
LOL, overwatch just kicked every single person from the servers
even people playing competitive
 

« first day (2755 days earlier)      last day (2207 days later) »