« first day (2052 days earlier)      last day (2888 days later) » 

12:31 AM
That is a disaster ^
 
1:03 AM
I've got a choice between:

data = [ [0, 12, 2, 4.33, 'hello', { foo: 'bar' } ], [1 ... ], [ n ... ] ];

data = [ { index: 2, thing1: 12, thing2: 4.33, thing3: 'hello', thing4: { foo: 'bar' } }, { index: 1 ... }, { index: n ... } ]

where n is some large number
is the second option a big red performance flag? I've got to sort, filter, and search through these data structures according to user input. I plan on actually profiling both in my app, but was wondering if there is any wisdom here that can be applied to the general case
 
Well the second version is easier to maintain. You have to test it, like you say.
 
yeah, definitely maintenance and code clarity are better with the object. data.thing1 is obviously more expressive than data[1] especially if the properties are liable to change
 
1:27 AM
That's the worst thing I've read today
Well, also the first
 
1:49 AM
Anyone know of a chat room where experts about Promises hang out?
 
@BaldEagle yeah
This one
 
fuck javascript questions. morons come along and downvote correct answers
the competence level of the average js question poster is nearly 0 anyway, why bother
and there are an alarming number of outright lies in js questions. they describe things that could not be
 
(You're bluffing! :)) Anyone know why those who spec'd Promises spec'd all, which terminates as soon as any component Promises rejects and runs to completion only if no Promise rejects, but not also a, say, runEm, which completes all component Promises and for each reports either the return value (if resolved) or the error (if rejected)?
OMG, that's only one sentence. So sorry. Clear enough?
 
why would it wait? it is going to reject, why wait around
so promise.all should hang until everything runs to completion eh? that would suck
 
@BaldEagle You mean it would resolve to an array of results?
 
1:59 AM
it doesn't abort anything, the promises have to be started to get into promise.all
 
Let's not get in revolution! Let's leave all alone.
Let's say we want a new function that will complete all the promises passed to it, either to a resolve() or a reject(). And we're interested in the box score.
And the results.
all returns an array of results (the return result of each Promise).
 
@Zirak Hey How are you doing ?
 
Maybe this other one runEm returns a field that says either "resolved" or "rejected", and a field that has the return value for successes and the error for failures.
 
extend Promise, add anything you like
 
Say I'm in a newspaper sports office and for some unknown reason, I use a Promise for each baseball game. Tonight's games won't end all at the same time, so each time I run it, I can get some failures (games not done) and some successes (the final score, for games that ended). When I send that set of Promises, I want whatever news comes back.
That example is a blast from the past. Newspapers? Really? Ever heard of the web?
 
2:05 AM
hmm extend it
 
@BaldEagle you could write a helper function to do that
 
You just want to inspect promises. If you're using bluebird you can use reflect and implement settle all.
 
Agreed. An extension would be needed. I use bluebird, too. I'll look into reflect.
 
you dont need to extend anything
 
The question is interesting. It seems like it would have been a logical thing to have been in the original thinking. Maybe it wouldn't get much use.
 
2:08 AM
that or the fact that you would need a custom result type
 
Thanks for thinking about it for a bit. Helpful.
 
you could use Promise.props then
 
do you want code to come along and poke properties and functions into your code, that you never wrote? me either. if everyone extended everything unnecessarily like that, I wouldn't be here, because js would be totally useless
anyway, sounds like a toy project. fun is more important
 
Maybe that's exactly what a fork is for. If someone else better meets the needs of the masses, it'll show in the numbers. And the two authors either merge happily and work together, or they split the user base and maintain two sets of code.
 
@BaldEagle you need to either reduce an array of promises and chain them with handlers that aggregate resolve/reject values, or you can use primitives to loop over and wrap each await with a try/catch and aggregate resolve/reject values somewhere
 
2:14 AM
Don't get me wrong. I'm not that interested here. I was just wondering if anyone knew why it wasn't already in there.
@FilipDupanović Yup. Sounds reasonable.
 
Something like this maybe.. jsfiddle.net/fcwv0u0w
 
that's a mouthful
 
It is a mouthful. And it's a reasonable outline of a solution. And bluebird Promise.props looks at least close; I'd have to experiment with it a bit. Thanks for both, @cswl!
Actually (blush) I'm really glad you wrote that because I was having trouble understanding the Promise.props writeup. When you put it the way you did ... hmmm ...
 
2:37 AM
Well it was rather a quick stab at it.. didnt think about scalability and concurrency...
 
2:51 AM
sorry, I meant to criticize the result object and the fact that you have to use result.isRejected(), result.reason(), result.value() down the pipeline
 
(I don't mean to be critical!) Why be critical of those functions? If bluebird implemented them, it would seem likely they thought through them and implemented them efficiently. They appear to be a way to do the job I asked about.
 
sigh it's never that simple @BaldEagle; look, it forces you into working with a promise for an array of resolutions from which you have to infer the resolved value or rejection reason
 
Rejection reason? Is that something like a thrown exception?
 
Not simple? Sometimes I think nothing worth doing is simple! But then on my good days, I find a simple way to do something and that gets me motivated again.
Thrown exception? Yeah ... that's a sticky part.
 
Monads are still a better solution than promises
 
3:01 AM
Yeah, promise inspection is kind of synchronous.. which defeats the purpose of promises.. but sometimes thats helpful.. .
 
Or rather, promises are great, but ES5 lacks appropriate monadic syntax over them.
 
ES5 dont have native promises.. you meant ES6?
 
ES6 async syntax is great, but it should have a way to extend over other monads
 
Am I reading about the right stuff?: modernjavascript.blogspot.com/2013/06/…
 
@JanDvorak can you illustrate with an example?
 
3:05 AM
\xs ys -> do {x <- xs; y <- ys; return (x, y)} could be a cartesian product or an async uncurry based on if xs and ys are lists or IO actions
\xs ys -> [(x, y) | x <- xs, y <- ys]` is the same using the comprehension syntax. By default that's only for lists, but you can tell Haskell to generalise the syntax to all monads.
 
that looks pretty
 
Of course there's already a construct in Haskell that does exactly that. LiftM2 (,)
Lists are synchronous multi-element containers. Promises are asynchronous single-element containers. Writer is a container that holds a value and a list of strings. In this monad, the above collects both values and concatenates the lists. The Maybe monad either holds a value or it doesn't, kinda like nullable but better. You can guess what the above does in Maybe.
C# has observables. Kinda like a list of promises or a promise of a list but also neither of them. In Javascript you would either use plain old events and forget any fancy syntax, or you have to use something like type Observable value = Promise (value, Observable value).
 
3:23 AM
well, it seems that if you had array comprehensions in JS, you could write something that could be comparable to your example of a cartesian product in Haskell
 
@JanDvorak Cartesian product? That's really neat.
So, const f = ([x,...xs],ys) => x === undefined ? [] : [...ys.map(y => [x,y]), ...f(xs,ys)]; in ES6? Unless there's a neater way.
@FilipDupanović Well, SpiderMonkey does.
 
[for (const x of xs) for (const y of xy) [await x, await y]]
 
nice
except that can't operate over promises, just lists
and a list of promises isn't quite an observable because the latter can be infinite
 
const f = (xs,ys) => [for(x of xs) for(y of ys) [x,y]]; is legit in SpiderMonkey.
 
For promises, that would be [await xs, await ys]?
 
3:36 AM
Shrug.
 
@JanDvorak mmm, no, from your example, xs and xy are iterables of values that are promises or those which you can wrap with Promise.resolve(v) if they are not
 
Nope, In my example xs and ys are either iterables or promises
 
I think what you can practically achieve are expressions that are similar to those in Python in the way they compare to Haskell
 
xs, ys could also be ListT IO, true, in which case the closest thing in Javascript would be a linked list of promises.
 
it can be a generator, an iterable, a collection, it doesn't really matter
 
3:43 AM
I guess a generator is the closest thing to an observable in Javascript
 
3:54 AM
Actually, the problem with observables as monads is that you can't concatenate them because they're infinite, which means they turn asynchronicity into parallelism.
 
4:05 AM
Not that it makes them not monads, but it would be nice to have an event loop instead of launching many, many threads.
 
those are all issues related to sequencing; there should be enough tools to achieve any sort of sequencing you like in JS; you can charge for coffee even if it's served without cream and sugar
 
I'm talking about Haskell. In Haskell you have to either give a definite order to your IO actions (such as opening a file and binding it to a thunk of a string) or use something for paralelisation (even if it's unsafeEvalIO, used internally for lazy file loading)
 
4:39 AM
Can anyone help me to achieve this? http://pastie.org/10856567
Actually, I do not know where to start? Using functions or some plugin?
 
My first hint is: .addEventListener("input", ...)
Or, if you're a jQuery type of guy, $(...).on("input", ...)
 
@JanDvorak hmm, so need to predefine all the macro styles right?
 
nvm, I get your hint
thanks
 
5:01 AM
@JanDvorak it doesn't matter if you're using Haskell, JavaScript, maths or plain English
you still have to explicitly describe the sequence of events; you'll be doing the same thing, but with what's readily available in JS
 
Wtf just lost 26 rep for no reason
No one deleted any questions and nothing happened to my rep except for it going down
574 to 549 in a few minutes wtf
 
hmm, try looking around on meta.stackexchange.com, maybe there's some explanation why you lost rep, but can't see any changes logged
 
Can I track my rep on mobile? Is there a way to get the desktop graph? I'm outta town and all I have is my phone
Hmm. It might've actually been ~38 rep
 
@AndrewL look around meta, maybe when a question is migrated all the rep changes vanish on your account from the previous site
 
5:16 AM
Can I audit changes on mobile site? I would like the desktop version but I can't seem to find it
 
@AndrewL Rep graph shows no changes
 
5:31 AM
I havent used Q/A feature of SO in a long time :|
 
Really? I had 584
574**
How can I show removed posts on mobile
Also is it possible to lose rep from reviewing posts? Maybe someone didnt find the reviw helpful?
 
5:54 AM
@Radu definately the first, unless you are able to name each and every thing
 
@cswl same
 
6:23 AM
store.steampowered.com/app/434520 open source transportation simulator:D
 
7:15 AM
@littlepootis yeah it is quite a shitstorm
 
@littlepootis How's that any different from OpenTDD?
 
Why don't owners come online in this room ? :/
 
8:27 AM
@TheLittleNaruto I am an owner.
I'm online.
function* Enum (name = 'Unnamed enumeration') {
  while (true) yield Symbol(name)
}

// Usage
const [cat,dog,catdog] = Enum('animal')
const [red,green,blue] = Enum('color')

// Test
console.assert(cat === cat, 'Identity violated')
console.assert(cat !== red, 'Uniqueness violated')
console.assert(cat !== dog, 'Uniqueness violated')
console.assert(cat !== catdog, 'Uniqueness violated')
This is a really nifty trick
 
Hi Owner
Make Caprica talking in room 19132
XD
 
hello guys
 
!!summon 19132
 
Still she doesn't talk :/
She is already there
 
!!live
 
8:29 AM
@MadaraUchiha I'm not dead! Honest!
 
!!unsummon 19132
!!summon 19132
@Zirak @rlemon can you check why Cap's not talking in room 19132? She's there, but won't respond.
 
Thank you :)
 
8:53 AM
I'm wondering, what's faster? Rewriting a CSS sheet with ~40 styles, or updating ~70 style properties from the same data? I plan to do it several times a second.
 
been there, done that. rewriting the sheet is significantly faster in both gecko and blink. But in my case I had 1k styles.
 
I guess I should hit 60 PFS easily even on toasters, then?
Thanks
 
I didn't measure FPS. And infact I don't think it would have helped - all current FPS meters are borked for such extreme cases.
 
There's one within Chrome
 
yeah, it doesn't work that well
Also worth noting that my styles were namespaced to a small part of the dom (with gist.github.com/awalGarg/4596845c178db99a0ff3), so maybe things got optimized out or something.
 
9:00 AM
How about the one in Firefox?
 
same
 
My selectors would be #id .class.number-123456
each child of #id should hit exactly one selector
 
@JanDvorak id being constant for all the rules?
 
Yes.
 
then if things were optimized for my case (that's just my guess though), the same should apply to your case as well
 
9:02 AM
The set of selectors won't change often, but the list can grow every once in a while.
 
@JanDvorak try going through this guy's blog aerotwist.com/blog
 
I don't think I can avoid repaints. I'll be changing the background color.
 
@MadaraUchiha better graphics, steam play
 
Thanks for the link
 
hmm, there are a lot of perf articles he wrote that are linked from the homepage
 
9:15 AM
Looking at the code, I think I have bigger fish to fry. .forEach does reduce performance if you do it 50 times per frame, doesn't it?
 
@JanDvorak JSVM's performance is still million times better than layout though
 
maybe you can squeeze something out with for...of and you can also break and return
 
Early returns are not an option for me. But I'll try changing the loop style if I'm not happy with performance.
!!mdn for of
 
@JanDvorak Something went on fire; status 403
 
covers Caprica with a thick layer of foam
 
9:21 AM
phrasing
 
you can also split work across multiple workers if worst comes to worst
 
How do I convince Atom to either stop touching my whitespace or complete the job and reformat the whole project?
nvm, found it
 
9:48 AM
so, this is the code the person from yesterday was telling me about...
other than the fact that 1) it's windows 2) is that word 0.o 3) it's a photo of a screen
does anyone know what language is that?
 
She sent a friggin photograph of her screen of her code in Word? wtf?
 
visual basic?
 
oh, so that's vb...
it looks horrible
would never want to code in that
 
Hey folks, PyCharm is throwing an error for the following piece of code, function multiBar(stacked,xTicks,xDomain=''){
It says , or ) expected
at xDomain='')
However code does work
 
9:52 AM
PyCharm doesn't understand default params, which landed in ES6, apparently.
 
PyCharm problem or am I doing anything wrong
Ohh okay! Thanks for the clarification
@littlepootis Heavy main ? :P
 
@HackToHell Soldier main :P
 
900 hours and I still can't do them proper rocket jumps
 
@littlepootis Doesn't look any better
And since OTTD is open source, steam play is a disadvantage, not an advantage.
 
@HackToHell 993 and I can't either
 
9:58 AM
I go to them jump maps and come back dizzy. Spy ftw
 
@littlepootis Same.
 
I've only recently started playing spy
 
Also, I suck at soldier generally.
I main Sniper and demoknight
But right now my focus has shifted to Overwatch
 
@MadaraUchiha Nice!
 
@MadaraUchiha How does it compare with Tf2
Tempted to buy
 
10:05 AM
@HackToHell It's amazing.
 
Saw about the AoE spells in overwatch on reddit
 
It's effectively TF3.
 
And someone was like it's tf2 + dota
It's a bit expensive tho
 
@HackToHell Yes, that's also a good description.
 
Hopefully prices come down, in the next few months
@MadaraUchiha awesome
 
10:06 AM
@MadaraUchiha Ah.. Overwatch's nice too. Too bad it isn't available for Linux.
 
@littlepootis Well, at least for me, TF2 isn't really playable on Linux either
 
wot, what distro?
 
I get 3-5 times better frame rate on Windows than I do on Linux, on the same machine.
Ubuntu
 
Same here, some issue with my laptop and nvidia driver
 
^
nvidia + linux = nope.
 
10:08 AM
@MadaraUchiha I get comparatively better frame rate on Linux. I don't know why.
@MadaraUchiha DE?
 
Unity
 
Desktop Environment. Unity?
 
It's OK, I don't mind
I have a windows machine I use exclusively for games
And I use Ubuntu for pretty much everything else.
 
@littlepootis These weren't funny when they weren't jokes
They aren't funny as jokes either.
 
11:04 AM
@littlepootis Some of them ... could be useful.
 
Hello everybody
short question
usually when people embed an image in a webpage they use something like <img src="xxx"... so you can easily obtain the source link but what about this video: vier.be/theskyisthelimit/videos/aflevering-van-12-april/1840782 it looks there is no link for the entire video. By going trough the network console I found they use links to small parts of the video in order to buffer it. I fyou click on that link it downloads like 10sec of the video.
BTW: this is a belgian website, so some things might be blocked for you due to geolocation
 
11:34 AM
@trilolil That's DASH
Dynamic Adaptive Streaming over HTTP (DASH), also known as MPEG-DASH, is an adaptive bitrate streaming technique that enables high quality streaming of media content over the Internet delivered from conventional HTTP web servers. Similar to Apple's HTTP Live Streaming (HLS) solution, MPEG-DASH works by breaking the content into a sequence of small HTTP-based file segments, each segment containing a short interval of playback time of content that is potentially many hours in duration, such as a movie or the live broadcast of a sports event. The content is made available at a variety of different...
 
11:48 AM
@HackToHell I now have the m3u8 link
but just don t know how to concatenate everything to one file
 
There should be start and stop time params in the URL
iirc
Check for DASH downloaders
 
any recommendations for a good one?
because all the tools I used so far don t even detect the video on the webpage...
 
I have only run into DASH on youtube and I use youtube-dl
Check their source code to see how they do it ?
 
how they do what?
 
How they download DASH videos
 
11:51 AM
that will take soo much time...
hoping I find open source tools...
 
Hey people :) I need a bit of help optimizing my code, if anyone can to look at problem statement and the code i've written to see if it can be optimized ,thanks in advance ... here is pastebin pastebin.com/UXh7Zt1y
 
@MarkoMackic 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.
 
Already read them :)
 
12:32 PM
@towc 0) multicolumn layout for a single file of code...
 
@AwalGarg yeah, that's crazily weird...
 
user image
6
 
@CapricaSix how does you !!learn command work? Just with simple command mappings or do you provide a way to actually add (limited) logic to new commands?
cc @rlemon ^ becauce cap ignores me :P
 
@PeeHaa Zirak knows
 
12:47 PM
Is he still alive? I don't get an autocomplete from it
 
is there a shorthand for accessing last array element?
 
!!help learn
 
@towc learn: Teaches me a command. /learn cmdName outputPattern [inputRegex [description]]
 
I mean, without using .lenght or .pop()
what I really want is:
let foo = array.last;
 
I see. Thanks @towc
 
12:49 PM
let foo = array.slice[-1][0]
 
or maybe, let foo = array.tail(1);
 
the one I showed above works
 
@towc that looks worse then using lenght
 
@towc .slice[-1] ??
 
You can use slice... ^^^
 
12:50 PM
pls
 
with a negative index
 
!!> var arr = [ 1, 2, 3, 4, 5, 6 ]; console.log( arr.slice(-1)[0] )
 
@towc "TypeError: arr.slice['-1'] is undefined"
 
@towc u wot m8
 
slice is a function noob
 
12:50 PM
nvm......
 
:P
 
@towc "undefined" Logged: 6
 
me n00b
anyway, there
 
@PeeHaa simple command mapping mostly, with a printf like support for some special words in the output
 
@towc as I said, it looks like ass
 
12:51 PM
@tereško so does most of javascript :)
 
@AwalGarg Guessed so. tnx
 
well .. not mine, really
 
you can't say I don't have a point
 
@PeeHaa Please don't imitate it for jeeves. cap's learn is terrible
 
I suggest going with the semantically correct way, the length one
or if you're only needing the last and not the first, just reverse the order in which you add things to the array
 
12:52 PM
@AwalGarg Yeah. Going to think about a better way when I have some spare time
 
!!> [1,2,3,4,5].reduceRight(p => p)
 
@rlemon 5
 
:D
 
!!> [1,2,3,4,5].reverse()[0]
 
@littlepootis 5
 
12:54 PM
@PeeHaa Take this as an excuse to implement a shell like interpreted language with pipes and stuff :P
 
:D
 
@littlepootis that also permanently changes the beginning array
!!> var a = [1,2,3,4,5]; console.log( a.reverse()[0], a )
 
@towc "undefined" Logged: 5,[5,4,3,2,1]
 
.pop() does that too
 
did I ever suggest pop :P
 
12:57 PM
@towc so reverse it again, noob
 
then it's longer than .length :P
 
reduceRight ftw!
:D
 
Doesn't matter. Code should be cryptic.
Readable code results in oracle vs google fight
 
elmao
 
!!urban elmao
 
12:58 PM
@AwalGarg No definition found for elmao
 
Almost thought that's a real thing
 

« first day (2052 days earlier)      last day (2888 days later) »