« first day (2820 days earlier)      last day (2353 days later) » 

00:00
then iterate through the input again, incrementing the slot in the array at index year - min for every birth, and decrementing for a death
O(n)
then do a cumulative sum through the array, recording the index of the max value
O(m)
total: O(n+m)
@William Yeah that's what I did too
I did it that way and did not like that solution. I don't understand why we would need to use the entire interval, why can't we just keep it to births and decrament on the deaths?
How do you mean?
the births are the only thing that matter. since a birth will indicate the year in which most people are alive
but deaths matter too, don't they?
they indicate when a person is no longer alive
if you ignore deaths, the last year in the dataset will be after the most births and therefore have the most people
only in as much as they decrament the living
00:05
the fuck else would they decrement?
I see kendall that makes sense sorry to many windows open
when someone is born is where you will find the peak. it seems like a waste to iterate over the empty spaces between the living and the dead
Oh I get it
if there's a million year gap between anyone living and dying, it's a waste to check all those years
correct
I suspect you'll need more than O(n) in that case
00:08
so what do you do check a million years + 1 and countdown?
O(n log n) should be doable, since I think you can sort it and take it linearly from there.
what if there are multiple years that tie
yeah I wasn't very good at math
that fine if there are muple years that tie that's what a hashtable is for
Before I post my solution
Which year is the correct answer
00:13
I was thinking that maybe we could push the deaths into an array inside of the hash and then splice it in a secondary loop and decrament the counter on each iteration are i reomve the values when the death exceeds the birth
1930 and 1940 right
I think the answer is
[ '1930',
  '1931',
  '1932',
  '1933',
  '1934',
  '1935',
  '1936',
  '1937',
  '1938',
  '1939',
  '1940',
  '1941',
  '1942',
  '1943',
  '1944',
  '1945',
  '1946',
  '1947',
  '1948',
  '1949' ]
am I right?
dude it's just one year where the most people lived
shoot
this is my dataset of yearly changes:
the list is like super small dude it's just a sample you can tell
00:15
{ 1720: 1,
  1730: 1,
  1810: -1,
  1860: -1,
  1920: 3,
  1930: 1,
  1940: 0,
  1950: -1,
  1960: -1,
  1970: 1,
  1980: -1,
  1990: -1,
  2010: -1 }
according to that, it looks like 1931-1949 would be the most?
Should be linear
ok you guys I don't know Javascript so I think I'm probably way off but this looks like linear time to me. But if it's just one year then I'm not even getting the right answers lol. repl.it/@ForrestHopkins/BruisedVoluminousSoftwareagent
@forresthopkinsa linear in the input?
ehh right?
I'm not doing any multidimensional looping at least
whatever I've got to go. I like my solution lol
oh that's still got the loop over the years
00:19
you can tell pretty clearly from it that I'm not a JS dev
so O(n+m)
right but that's still linear
ehhhhh
don't know what m is. Anyway gtg talk to y'all later
35 mins ago, by Kendall Frey
but I bet it can be done in O(m) where m is the difference between the earliest birth and the latest death
oh I made a mistake in the return for testing. fixed
it looks to me like O(n)
ok out
It definitely has that extra term in there
00:21
@KendallFrey That would only apply if you need to generate a range of years I think
Actually explain your point first
I think I'm misinterpreting it
12 mins ago, by Kendall Frey
O(n log n) should be doable, since I think you can sort it and take it linearly from there.
38 mins ago, by Kendall Frey
I doubt it can be done in O(n)
There's no requirement to sort it
That doesn't change anything
00:22
meredith has the correct answer just wish it was not in elixir
It's elixir
you're in luck, it's not in python :P
and don't worry it wouldn't have been readable in js either
I can read unreadable js
by definition you can't
00:23
I needed that robust standard library
are you brute forcing it in elixir ?
i should try it in haskell
No
What I did was create a Map from year to population growth, them summed up the pop growth while keeping the results in a list (this is what scan does), then I find the largest value in the list
ya I am already doing that
Oh I think I realize my mistake
00:26
I just don't know how to decrament on the deaths that's where I am stuck. otherwise I am counting correctly
It happens to be the case that you don't need to sort the map before you scan it
ya sorting may not be nesseary since you are mapping the birth years
The question is if it's reliable
And I think it is
00:40
I think I figured it out
Code coming soon
hopefully not in elixir :)
Unfortunately it has to be in elixir
Because it's a "bug" in how their maps are implemented
It's not a bug, just a neat caveat of the data structure
I am just going to steal your apprach of using two maps
I have another demo
But I don't know how to link a jsbin with a library included
Figured it out
You have to hit save snapshot
01:11
Ok yeah
As far as I can tell, my solution is equivalent to doing a radix sort somewhere along the line
So not linear
ya I notticed the nested loops
but A+ for effort
There's no nested loop
The trick is that inserting into a map is equivalent to inserting into a list and then doing a radix sort, when there are fewer than 32 items
I was in a hurry and didn't really think about it @KendallFrey
you're right, definitely O(m)
Actually it's when the numbers are between 0 and 31
01:17
yeah looks like it lol
still linear though so... that's at least an A-
It's not linear
Cuz there's an implicit sort
there's no sort in mine
I mean unless you count the year-range iterator as a sort
still don't see how that's nonlinear
Let me look over it
01:20
mkay
to be clear, I'm not confident in my code at all; like I said, not a JS dev lol
so you very well may be right
morn
Yeah so you avoid the sort by creating a huge list of years then filtering that?
yeah
that's why I'm down to O(n+m)
not proficient enough to avoid the m I think
It's a huge m though
could be
I mean, if we're talking practically, then I don't expect m would ever be significant
sounds like n is the main concern, and it's linear here
the function doesn't support m > 10001 anyway lol. I mean, it could, but if we're talking practical use...
02:10
import Data.Function (on)
import Data.List (maximumBy)
import Data.Map (alter, assocs, empty, mapAccum, (!))

mapSnd f (a, b) = (a, f b)

input = [(1920, 1950), (1920, 1980), (1940, 1990), (1930, 1940), (1970, 2010), (1920, 1960), (1720, 1860), (1730, 1810)]

result = fst $ maximumBy (compare `on` snd) $ scanl1 (mapSnd . (+) . snd) . assocs $ (flip $ foldr $ alter $ Just . maybe 1 (+1)) (map fst input) $ (flip $ foldr $ alter $ Just . maybe (-1) (`subtract` 1)) (map snd input) $ empty
boom @Rick
one big-ass expression to make you cry
Mission accomplished :,( @KendallFrey should be fun to run it locally good job :)
side note: It's probably O(n log n) or something, since Haskell uses ordered maps
I don't think they are ordered
They are
> The implementation of Map is based on size balanced binary trees
This would be so much easier if haskell wasn't haskell
02:23
lol
Is this just a reimplementation of my algorithm?
I didn't read your algorithm, so idk
Basically, just the one I described except the map is ordered
which lets you skip the step of iterating a sparse array
Where do you see that iterating over a map is ordered?
Oh nvm
Okay, so looking at this

<script>(function(){// stuff here //})();</script>

is it possible to have other scripts add to whatever the stuff inside above does?

Basically i want a base model, that gets extended by other scripts
Yeah you're folding (n) with alter/update (logn) as the reducer
correct
My brain is so fried
I assume you didnt click the links I posted
I did, only skimmed
But maps in elixir/erlang and immutable are both sorted by default
When there are fewer than 32 elements
Which makes sense, since they're HAMTs so you end up with basically a radix sort
Or at least that's what I convinced myself
But in Immutable, if you add a 33rd element, the order becomes 0, 32, 1, 2, 3...
Whereas in elixir, they all just get shuffled around
Immutable makes sense since their hash function for integers less than 2^32 is just
use the integer
And I've been trying to figure out what the fuck's going on in erlang
With no luck
What I did learn is that they're only HAMTs "at large sizes", which I'm guessing is 32
> Erlang 18.0 has the HAMT structure internally and its internal breakoff point for switching to HAMT are currently 32 elements
Well there we go
02:47
Not gonna look too far into the algorithm, but it seems to shuffle things around way more than immutable does
Which is good enough for me
I'm going to bed
03:00
Why use bcryptjs over bcrypt given that it's slower?
is it just to avoid node-pre-gyp?
@JBallin Because slow is good for a cryptographic hash
 
1 hour later…
04:24
1 message moved to Trash can
@Hybridwebdev 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
hey dont delete my message
1 message moved to Trash can
@Hybridwebdev 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
    test = {
      store: {
        actions:{},
        getters: {},
        state: {}
      },
      init: function(){
        console.log(this);
      },
      registerGetter:function(name, object){
        this.store.getters[name] = object;
      },
      registerAction: function(name, object){
        this.store.actions[name] = object;
      }
    }
    test.registerGetter('test', function(){
      console.log(this)
    });
    test.init();

My question is, why is the test function via registerGetter referencing the window object and not the internal object
dude it IS FORMATTED, stop deleting perfectly valid messages
some people just like to abuse the tiniest bit of power, geez
05:12
Good day
how to get the value imageData and supply it to another object?
this.convertURIToImageData(URI).then(function (imageData) {
                    // Here you can use imageData
                    this.myImage = imageData;
                });
my this.myImage is empty outside
05:25
@jsonGPPD arrow or bind
and also promises are asynchronous...
depends on when you mena on the outside
05:54
I understand
I have a new problem now
how to append a base64 string to an input type="file"?
@Hybridwebdev what do you mean? jsfiddle.net/m1fkrde7/8 test.store.actions is the one that gets updated...
06:28
Good morning guys, may the force be with us all
We're beyond may the 4th
06:44
@KarelG Who says Google doesn't have a sense of humor?
user6086034
is this an ok way to save two arrays into one array
user6086034
expArrayToSave = JSON.parse(JSON.stringify($scope.expitems)).concat(JSON.parse(JSON.stringify($sc‌​ope.tmpexpenseitems)));
._. why that parse + stringify ?
user6086034
i thought it creates a deep copy?
@boo thats a workaround.. be careful if you have date objects in there..
user6086034
06:47
hmm, is there a better way to do what im trying to do
@KarelG And what about this place: goo.gl/maps/AB4jTWsst
you got me. But I had a luck that it played an advertisement first
yay
user6086034
@SurajRao thanks
06:57
@boo (Array.from($scope.expitems)).concat(Array.from($sope.tmpexpenseitems));
@towc what about this solution? @kev
3
Q: vuejs history mode with github/gitlab pages

fiskerHas anyone managed to figure out how to make Vue.js work with history mode with GitHub or GitLab Pages? It works with hash mode, but I don't want to use hash mode for SEO related reasons. Reference for router modes: https://router.vuejs.org/en/essentials/history-mode.html

@KevinB ^^
@FlyingGambit does not deep clone...
people forgets that it does a shallow copy
07:15
Hi, can someone tell me, how to write a script to happen when a button is clicked ? not using the Onclick function

I want, after a button with class="cancel" is clicked, <p id="myID"> is .hide().

I can add onclick="$('#MyID').hide()" to button, but if i want it the other way, how should i do it ? like saying anytime a button with class Cancel is clicked, myID get hidden.
@Pedram $('.Cancel').on('click', function() { $('#MyID').hide(); });
be sure to run that after page load or on page load event
otherwise not all buttons will be loaded quite possibly
Ok, Thanks man
07:33
@MadaraUchiha did you have tried to write TS scripts in WSL by combining node + npm and vim editor in the shell?
I am figuring out if it is a good/ok'ish approach
08:33
@Shmiddty I'm pretty sure that you're one too.
And if you think that clever ones use variables like A and B then you're soo wrong, my mate.
08:53
@SuperUberDuper that's pretty much what I came up with
what's wrong with the solution that I gave you, that the question fixes?
other than the internet explorer thing
which I think vue doesn't support either way
09:16
Hi all, How can I use react components with meteor.js instead of default blaze templates ?
I went through the docs of react meteor but could not understand how to pull data and pass it as props inside my react component
Anyone online ? Need some help with reactjs and meteor :)
10:17
I apology for my rudeness yesterday
Apology accepted, I was not there yesterday
@Boypro what have you learnt that you need to improve?
I learnt that I have to research before asking.
great :)
apology accepted
Wait, you were there yesterday?
I don't remember you there.
10:26
ofc
some of us are just lurking around
creepying from the darkness
@Boypro We don't know who @towc is really.. he just keeps showing up here.. the weirdo
10:51
Is it worrysome that I'm stuck in roman numerals converter for 2 days and I still don't know how to exactly start?
You've been stuck for 2 days and haven't started yet?
I don't know how to start.
I have only created 2 arrays. One with decimals and one with numerals.
But I still don't know how I'm supposed to make it work.
40
Q: Convert a number into a Roman Numeral in javaScript

DD77How can I convert integers into roman numerals? function romanNumeralGenerator (int) { } For example, see the following sample inputs and outputs: 1 = "I" 5 = "V" 10 = "X" 20 = "XX" 3999 = "MMMCMXCIX" Caveat: Only support numbers between 1 and 3999

That's kind of cheating.
10:55
are you not that boy that talked about becoming a white hat hacker>
Because I will see the solution.
I'm not saying copy and paste it, walk through the logic in the answers and apply it to your own code.
you have a long path in front of you
No, i'm not the same.
That was my brother.
...
10:55
He was making some jokes from my computer.
> I want to learn but I'm not willing to use any material
i just checked the history
lol fuck off
Yeah I know.
That was my brother.
I am willing to drop it.
stop with trolling
10:56
I left my computer open for 2 hours.
Then BOOM!
You're playing steam?
read it
that's you
Uh no. It's not me.
!!afk lunch
10:57
Okay okay. I was kidding.
That was me.
I thought of some .../s to show that I'm sarcastic but it's ok.
@BenFortune Btw, which game you were playing?
It seems very fun to trade stuff with others.
@BenFortune of course its not you, its your brother!
get out
No u!
USM
USM
11:25
heelo
heerooo
And they say that a hero could save us
I'm not gonna stand here and waaaaaaaaaaaaaaaaaaaaait
I'll hold on to the wings of the eagles
Watch as we all fly awaaaaaaaaaaaaaaaaaaaaaaaaay
@BenFortune an attempt to play rocket league in RL : i.redd.it/lb8t72ttoa811.gif
@KarelG I'm sure that's epi.. oh
@KarelG damn
all of my friday alert flags sprung up as soon as I clicked that. But I was left doubly disappointed
12:04
Hey guys, what framework would you use for developing desktop applications?
@alex55132 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.
@alex55132 using a javascript-based language?
or in any language?
Yeah, js
That wouldn't be my first approach
electron
12:06
electron is an easy one
But i saw electron has security issues :S
That's why im asking, dunno if should use it :S
if it's 100% a desktop application, who cares?
the security aspect is kind of pointless unless it connects to a server of some sort I think
Well indeed it does
It connects to a local nodejs server
Shouldn't be any problem as long is local hosted isn't it?
well I mean, worst case scenario, the user using the program (not necessarily the very same who installed it) gets access to the data you're saving locally
If that's fine, don't sweat it
you can abuse electron apps to steal your data and transmit it :P
12:12
well yeah, if a user gets hold of the data and shouldn't, that user can do whatever he wants with it, including transmitting it
Then how apps like discord handle and secure their data?
seems a little silly unless you're dealing with multilple users
their users data*
they probably use a secure protocol, and don't save anything locally
12:13
all data is held on the server
pure desktop applications are going out of style in any case :P
you sure you wouldn't rather make a website?
I need to make a desktop app :S
But
With security issues i don't mean like handling with user data
More likely to an attacker interfieres with the app flow and make some trouble
man-in-the-middle attacks?
shouldn't be an issue if you use a secure protocol
For example? @Neil
@alex55132 https
12:22
the data is encrypted
Yeah fair enough haha
anyone in the middle can read it, but it won't make sense if it can't be decrypted
If you're giving them the server in the application, it's not hard to MITM it
Hi, I have a question. Suppose you have a "class" (named X) (like Date), and a property. Is it possible for X.property to be undefined, new X().property to be undefined, but X.prototype.property to be defined?
@Neil do not be silly
otherwise there are no needs for certificates during ssh handshakes
12:26
@KarelG at least not without a lot of time on your hands
@KarelG But the server is hosted locally
All they need to do is install the root cert
still using a certificate :P
wait I'm reading this wrong
ssh handshakes should ensure the person on the other end is who they say they are, but there's always the router or gateway or whatever
@GaurangTandon absolutely
function X() {
  this.property = undefined;
}
X.prototype.property = true;
new X().property; // undefined
12:29
@Neil try to mitm on a local starbucks wifi network with a valid self-signed certificate that is accepted by a trusted CA :P
@GaurangTandon You have to do something to explicitly set to undefined, but yeah, it's possible
@KarelG well, never said it would be easy
I do it from time to time when I missed my train
I hope that you would not be surprised that people is e-banking through the starbucks wifi networks
But the way most secure protocols work nowadays, nothing is impossible, but it would just take you a ridiculous amount of time to manage that it isn't really worth your time to try
Hello everyone,
I am having a problem with Websockets. Can anybody help me?
@MohitNegi 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.
12:31
I suppose when we have hypercomputers, we'll have to rethink most security :P
just increase the size
:P
we are already using 256bit keys
overkill i know but sys admin went forth with it
not with hypercomputers
I doubt they're even possible, though some have said that it would take a hypercomputer to simulate a universe, and that one of the limitations of this is that you can't build a hypercomputer within a hypercomputer simulation
anything possible to calculate with enough time can be calculated in constant time using a hypercomputer
Anyone of you have experience with Ionic? I'm running it in the browser but I was wondering if there is a way to use my camera (not some <input type="file" thing>
Okay, so I am having trouble with Websockets.
If I define WebSocket codes within an embedded script tag inside the HTML page, it works. But if I define the code in another file like sockets.js and then reference it inside the HTML page like `<script src="sockets.js></script>`, then WebSockets gets closed unexpectedly.
What to do if I want to define WebSocket code in an external script file.
@Neil do you know the movie interstellar?
12:45
@KarelG Yep, "he was the ghost the whole time"
I got this absurd image of Shaggy and Scooby-doo towards the end of that movie
@MohitNegi your another file is probably not loaded in
@Neil well, the visuals at the other side of the black hole got made with aid of a supercomputer.
a team of physicians were working on it and tried to model it
@KarelG I read about that. The director was worried it wouldn't "make sense" enough for a typical (American) audience, but he liked it and left it
Turns out that movie was quite scientific for a hollywood production
very good movie
that is true but it is not too difficult for me
Though I don't think the ice clouds would ever be possible
maybe because I have a background and interests in physics
12:48
ohh, finally I've got someone I can talk to about such things
are those clouds not present on Mars?
Nobody here at work talks about physics beyond the curvature of the ball in that last score against Russia
Ice clouds? No. :P
At least not the kind you can walk on
there has been physical talks about physics before here
lol that sounds wrong
Talks about physics would be physical I suppose
@KarelG No @KarelG , It's loaded completely, I've checked in browser inspector. Even the WebScokets are opening but suddenly getting closed.
12:50
We need to create that second meaning for that word
@MohitNegi any errors? Do you return false at .onmessage ?

« first day (2820 days earlier)      last day (2353 days later) »