« first day (2070 days earlier)      last day (2876 days later) » 

8:00 PM
oh, jsperf is down again
but promising to be back up so it's good
 
@SterlingArcher exactly the right farness
 
some of those things should not be -1
the bitwise operators fail on numbers above the 3^32 - 1 boundary
they're a cheap hack that has a) no value and b) can actually break things
a fantastic example of why being clever for clever's sake just makes you an asshole
 
@ssube oh, never noticed that
@ssube I'm being clever for laziness sake, it's different :P
 
it's not
 
@towc probably a crappy perf test, but shows
const source = Array(100).fill(null).map( _ => Math.random() + 0.5 );
const a = source.slice();
const b = source.slice();
console.time('a');
const c = a.map(i => Math.floor(i));
console.timeEnd('a');
console.time('b');
const d = b.map(i => b|0);
console.timeEnd('b');

VM43542:7 a: 0.112ms
VM43542:10 b: 1.388ms
consistently slower
err, fuck.
 
8:05 PM
so much cons
 
dammit. mixed results once I fixed the b test
 
increase your iterations
 
but I swear Math.floor is/was faster than |0 or ~~ a while ago
 
floor won't change underlying types, so it should be a little faster
 
@rlemon oh wow
 
8:06 PM
@ssube not in my chrome version
gonna check FF and node
 
and still is
 
:/
@towc no that test had a bug
b|0 should be i|0
 
oh right XD
still a bit slower
oh nvm
fluctuating
 
a million iterations, floor finished in 500ms and |0 hasn't finished yet (30s)
 
8:08 PM
var source2 = Array(1000000).fill(null).map( _ => Math.random() + 0.5 );
var a2 = source2.slice();
var b2 = source2.slice();
console.time('b');
var d2 = b2.map(i => i|0);
console.timeEnd('b');
console.time('a');
var c2 = a2.map(i => Math.floor(i));
console.timeEnd('a');
VM9972:6 b: 897.494ms
VM9972:9 a: 915.596ms
 
> That deep ass-clenching bass for a good clean.
 
you have a problem babes :P @ssube
 
Would it be okay to ask a tiny node.js question here? Mostly about JS in general though.
 
hey since when does imgur have a meme generator
 
@Codingale node is js
 
8:09 PM
I wish I had known this
 
$ node floor-test.js
a: 133.706ms
b: 168.453ms
 
Oh that reminds me. I was in the bathroom today, and a guy went to the urinal, mid way through, farted, said, "Oh dear." And walked right into a stall.
 
with 1 million items
 
@rlemon not ES6 I guess?
 
I was dying trying not to laugh
 
8:09 PM
@towc yes es6
 
@towc es6 doesn't have anything to do with this
 
and @rlemon, the previous code I sent has 1M too, but |0 was sitll faster by a bit
 
Ye, but I'm having a strange issue with node.js... in a function I have a return, but it doesn't actually cause execution to stop.
 
HAMMERTIME!
 
node 6.1.0
 
8:10 PM
@ssube Math. optimizations
 
@towc that's not how the language spec works
 
@towc ofc this was all just curiosity, you should be using Math.floor unless codegolfing
 
@SterlingArcher lmfaoh dear
 
this is part floating math and part how v8 handles bailing to/from float
 
@rlemon if my company's styleguide says I should use Math.floor then I'll use it, but meh :/
I should do a talk on lazy JS XD
 
8:11 PM
Like, you shit yourself, or damn near, and all you can say calmly is "Oh dear"
I couldn't even
 
For example if I have if (err) { console.log(error); return;} it keeps going regardless and causes a few issues further down in the code.
 
@towc or you could write code that actually works correctly
it's like a thing people do
 
@towc sure, but that is what the immature developer says. it takes no time at all (with proper tooling) to not introduce little hacks because it saves you a few keystrokes
 
@ssube yeah, I really didn't know about the problem with big numbers, I'll look out for that
 
neo
http://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_modal2
can anyone explain why <div id="myModal" class="modal"> has ID as well as class and only when ID is called the modal visibilty goes none if clicked ?
 
8:12 PM
@SterlingArcher Life tip: If you shit yourself, don't make it obvious. Walking will cause less problems than running anyway.
 
you don't have to look out for it if you don't use stupid hacks in the first place
 
@VeronicaDeane speaking from experience?
 
!!afk oh dear
 
And think of future readability (and by other devs)
 
@neo don't use w3schools
 
8:13 PM
@towc certainly
 
While w3schools is terrible, w3fools is a shitty resource these days
 
@NathanJones w3fools starts the page saying they're out of date
and, if you actually visited, you might notice they have no other content
 
@neo whereas I agree with do not use that resource, the common practise is to use ID's for grabbing elements in JS, and classes for styling them and grabbing collections of elements.
so <div id="foo" class="foo"> isn't going to be such an uncommon thing to see
 
8:17 PM
No one have any suggestions about my issue?
 
or maybe I'm not reading correctly again. sorry I block w3schools so I don't see anything you have in those links
 
@Codingale can you post some code?
 
neo
why is w3schools a bad practice ?
 
@neo most of their examples have mistakes or use very old, potentially problematic patterns
some of them don't even work, copy-and-paste
 
8:19 PM
@neo for starters, the code you're learning from (in that fiddle) has a bunch of bad practises
w3schools is closed. MDN and other public wiki's are more maintained
 
onclick="buttonclick();" is bad practice and simply doesn't work in larger applications
 
@neo second, I already explained document.getElementsByClassName("modal").style.display = "block"; is wrong.
 
.style.display = "none"; instead of adding and removing classes is poor practice
 
so even if you did get the function to execute, it wouldn't work.
 
neo
@rlemon sorry didnt i changed that ? wait
 
8:21 PM
onclick="buttonclick(); = This is how ng-click="functionname()" works right?
 
Somehow if (err) return; doesn't stop it but it does trigger console.log("");
 
@Codingale that code doesn't look obviously wrong...
 
@neo ditch w3schools. this is a slightly cleaner way to do it fiddle.jshell.net/h2mcf44h/3
 
@GandalftheWhite a) no and b) ng-click is pretty poor practice and one of the more commonly-cited reasons not to use angular
:31193124 no I think that's it
 
neo
@rlemon but why not get closed when clicked anywhere ?
 
8:23 PM
line 4 will never run?
 
if (truthy && false) will short circuit and bail
 
@neo because you only register a close on the click of the x button
there is no code to do the other thing
 
But it does run
 
Life is tough. When I started using Angular people encouraged me to use it citing reasons like it is new and good etc. and recently I have been told that it isn't good enough. @ssube
React is cool right?
 
@GandalftheWhite you probably should have made an educated decision
 
neo
8:24 PM
@rlemon but in w3schools it will allow to close anywhere
 
I talked to a few people
 
instead of wading into writing a finance app with a random mish-mash of popular technology
 
@neo then they had additional code
 
neo
i am not again saying w3schools is great
 
It's been weird. It runs sometimes if I change the URL.
 
8:25 PM
@ssube Well you haven't actually forgotten a bit, have you?!
 
neo
yeah thats why i was enquring this at first
 
react is cool, and you will be too, if you use it.
 
Although I like React a lot more than Angular, I don't like either.
 
to close when you click outside of the modal you must Add an Event Listener to the document body
and when it is clicked check to see if the event target is the modal
if it isn't you call spanclick()
 
The current URL breaks and it keeps going regardless
 
8:25 PM
I've dropped hints
 
@GandalftheWhite the headdesk hurt enough that I probably won't
 
I asked a few people who were working in firms. We Indians are kinda' slow in adapting to new technologies. They gave rave reviews on Angular and google search result was full of wanking for MEAN stack - what was I supposed to do. @ssube
 
@neo actually with that HTML it is even easier. just add an event listener to the modal itself and check if it is the modal-content and return early if it is, otherwise call the close
 
I'm wondering why err can exist in both states though, it's not Schrodinger's cat
 
@Codingale short circuiting
if the first part of an AND fails, the whole thing is skipped
 
8:27 PM
@ndugger What do you prefer? If not either of Angular or React.
 
neo
@rlemon yeah thats right
 
@GandalftheWhite The DOM apis are all very simple. You don't need a framework.
 
with if (err.finished && err.finished == false), if err.finished is false, javascript will read it as if(false && true) .. and it'll never run
 
@ssube What about line 2 though? if err
 
@ndugger lol
 
neo
8:28 PM
and thanks for w3schools info
 
You laugh because the DOM is too hard for you
 
It is for me for sure
I use a layer above that
xD
 
If you just take a minute to actually learn the shit, you won't be running after a new shiny library that sucks ass
 
if you want performant DOM handling, you do need a library
 
neo
i learned the beginning from there.I think its the best for begineers
 
8:29 PM
@ssube to be fair they are simple, just oddly named and clunky in places
 
@neo but your code didn't work
 
It is like writing whole css on your own without using any CSS engine
 
@rlemon the API structure is kinda bad but could be used, the problem is what happens when you call the method willy nilly
 
@ssube a magical library that is written over top of... the DOM api? ;) if you want performant DOM handling without thinking about it, you need a library
 
But no abstraction removes the need to understand the real DOM, for better or worse.
 
8:30 PM
It takes a lot of time but you need to remember a lot of things, which makes it even more tough.
 
react's fake DOM and caching makes the actual update a lot smaller
 
@rlemon a library can optimize out some DOM manipulation, like react.
 
which you can write yourself, but is pretty big
there's a lot of state to hang onto
 
@Luggage yea, and you can always do it on your own. I don't like the argument "you need a framework/library" to pull off a task
sure, might make it easier out of the box. but I dont' need it
 
What the library does it let you simply describe the DOM instead of having to optimize each interaction by hand.
 
8:31 PM
I know that console.log("Info: "+file); shouldn't run if (err) which is in it's own if block, inside that is the if (true && false) thing.
 
@rlemon no, strictly speaking
but I'm not willing to spend the time writing something like that
 
neo
@ssube yeah thats true
 
You can learn a lot about what causes repaints, reflows, etc, and you can learn how to avoid causing them in your code. You can get more performance out of the default apis than I'm sure you're used to
 
@Codingale just do if(typeof err !== "undefined") if you want a better check
 
You just have to be smart
 
8:31 PM
@ndugger yeah, this ^^
is it still true that you increase performance if you keep the repaint calls together?
 
Of course
 
solution: never change the DOM
 
@bitten batching
 
solution: never write code
 
@rlemon :O crazy
 
8:32 PM
it's good everywhere
 
solution: never be born
 
@ndugger that's called Haskell
 
htm is basic for java
 
:/ Wait What?
 
he no get, now I fell sad
 
8:33 PM
if u don't know java then it's not my fault
 
@bitten Edit: Nope it won't I need a null check.
 
@ndugger google that phrase
the first page of results are us
 
I know Java. Not an expert but I know it.
 
@ssube hahaha
@Codingale i don't know.. maybe?
 
8:36 PM
This honestly makes no sense why it runs the stuff inside the if block then just ignores the return.
 
@Codingale ssube and i explained it, no?
 
@GandalftheWhite ^
 
@ndugger who has the retina screen.. my god
it feels like 2.5x
 
I do
 
@ndugger there are more comments than that
 
8:37 PM
does it have a 3dpr?
 
@ssube I took this screeny early on, and I can't see it now that it's deleted
 
@bitten we're not accepting 3d pull requests
@ndugger do you have a link to the Q?
 
Nope
 
IT is kinda funny that his 12 Parents dives with 2 divs LMAO
 
@ssube >.>
lol
 
8:38 PM
12 parent dives, that's the gem, tbh
 
Reference : ndugger's image.
 
user image
4
 
The best line of that image is at the very bottom
 
full image , expanded comments
 
8:39 PM
@bitten They had thought that I had issues with the second if not the first.
For example this is the ouput if I clean the code more pastebin.com/dquYRhad
 
@Luggage thank you
 
<- knows how to use about:history
 
hah, OP had other questions, all negative
 
@Luggage always fav them
easy to get back to
 
That guys is probably trolling or something
No answers I feel sad - he wrote this.
 
8:42 PM
fell*
 
@GandalftheWhite no, that's average for non-technical developers
 
What is he? A toddler?
Fell sad - well that makes it worse
 
some regions just have boatloads of bad questions
 
No Comments.
 
No one has suggestions? pastebin.com/dquYRhad is my currnet code and it still executes the console.log("Info: "+filename); part for some reason >.<
 
8:47 PM
{ finished: false }
null
What is {finished : false} - Codingale
 
@GandalftheWhite probably line 3
 
wat
 
So it isn't that null thingy exactly codingale therefore it us bound to execute I guess?
 
@Codingale i can't recreate your problem, that shouldn't be possible.
 
@ssube i didn't link that as an alternative resource, per se. more of an explanation on why w3schools isn't a great resource, and should certainly not be the only resource (like the page says)
 
8:50 PM
I honestly have no idea what is going on... I could give the whole script but that's kinda all terriable code.
 
@NathanJones they took all the info out of that page, though
 
@KevinB @Codingale @anyone else -- my guess is that the file errors the first time and goes into an auto retry? how is the download getting called?
 
it used to have specifics and go into detail, but now it's just the header
 
maybe what you are seeing is the output from two consecutive download calls
 
-28
Q: Content vs style in answers and how to handle duplicates vs edits?

Evan CarrollWe have two revisions on this answer and the problem boils down to one of style vs content. I'd like to see this clarified, and my edited reverted. This is the original code snippet: for (var key in p) { if (p.hasOwnProperty(key)) { alert(key + " -> " + p[key]); } } This is my modified...

lol
 
8:52 PM
ah, i didn't read into what the code was actually doing, that's likely what's happening.
 
@ssube oh, i don't think i saw that version. my bad
 
note, folks: taking a good answer and making it es6 just for fun is not ok
 
prove it
 
!!> "making it es6 just for fun" === "ok"
 
@rlemon false
 
8:54 PM
proven
 
@rlemon You might be right I think I missed a return in the download function so the call back is being called twice.
 
@Codingale it really does look like the only way that is possible.
 
@rlemon God, 1 day of me trying it myself and about an hour of asking here... all because I forgot a return in the wrong place.. I are genius.
I've had two off days clearly and can't think it seems.
 
@Codingale sometimes all it needs is a few more pair of eyes
!!afk Sherlock Holmtime
 
9:00 PM
I swear this is the 20th time he's helped me >.<
 
!!afk PT time... probably upper/push today
 
Back to coding. Thanks.
 
is it really a cardinal sin to continue in a loop?
 
i just learned that i have tomorrow off. woo, unexpected day off
 
9:16 PM
@VeronicaDeane youtube.com/watch?v=ctX3juq9Okw Do this instead, and then use some monofilament fishing wire with a simple spring loaded striker.
 
@NathanJones no?
it's common
 
the post that the meta post @ssube posted has an answer that suggested it as personal preference, which seems hyperbolic to describe breaking a preference a cardinal sin.
 
I have 3 pages in a web app that uses html and javascript. The pages are part of a transaction flow. Enter merchant> Enter amount > Choose payment mode. I need to combine these pages into one so that i could eliminate the load times.. What is the best way to do it without using any frameworks
 
@VivekMaskara 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.
 
@VivekMaskara just cache hard, cache real good
 
9:31 PM
caching is good for subsequent transactions.. i want the first transaction to be fast enough too
 
gzip?
 
ask anyone. I have the best caches.
 
basically whats the best way to make a single page application without any framework
 
@VivekMaskara html
or using the history api, localStorage, and ajax
look at pushState on the history api, you'd use that when you're going from one transaction to the next
 
Yes i am using localStorage for a few things. How can i use ajax to decide which page to load
 
9:38 PM
you don't.
you decide what page to load based on the page state, for example, initially you're on Enter Merchant, presumably that's domain.com/enter-merchant
then, when you change state to enter-amount, you load the enter amount page
etc
 
right. will it be a good idea to put all the html and javascript of the 3 pages to a single page and use conditional statements to decide what to show
 
depends on the size. You said you're doing this to improve the page load times right?
If you're loading everything up front, and then adding a good bit of javascript to handle what would have otherwise been done by your server, that's going to impact your initial load times.
may still be better though, all depends on how much logic you need to control the application.
 
all the 3 pages are simple enough as far as the html is concerned and i dont have issues with the initial load times as that too wont be too significant.
yes theres a decent amount of javascript used
 
!!afk Food time.
 
front-loading all the html and just show/hiding would likely be fine for just 3 states
 
9:47 PM
given the scenario whats the best practice to combine the pages
so simple javascript functions to show hide divs would be fine? or should something better should be improvised
 
@VivekMaskara the way I always look at is this: do you expect all of the pages to be viewed in a single session ? load them all.
if you know users are actually using only 1, the others very seldom.. maybe lazy load them or load them when you need them
 
nice point. for every successful transaction the user would be using all the pages..
i have one more related query. i have a few functions that are supposed to be triggered on only one of these pages. for eg i want to listen to the keyup and keydown events only on the payment page.. what can be a good way to do it
i dont feel comfortable using if(currentPage==="payment"){ \\ do something}
 
well... events are attached directly to elements, so that shouldn't be a problem unless you're delegating events from the body..
or sharing event handlers
 
yes theres a scenario of shared event handlers
how shoudl i handle it
 
either don't share them when not needed, or you'll have the check what page is open.
 
9:57 PM
just bind and unbind event handlers when each page changes
 
or have said elements within the page, so that they're only available on said page
so you can share the event handler between pages 1 and 2, but give 3 its own.
 
if you have events that you only want triggered if currentPage is payment, then bind them only when you've switched to that page?
 
these suggestions clear up lot of my doubts.
is there some resource that could help me understand how to bind and unbind events
 
@VivekMaskara addEventListener and removeEventListener
if jQuery is available, use .on / .off
or .bind and .unbind
 
okay. thanks for all the help
 
10:04 PM
@VivekMaskara api.jquery.com/off have a look at the demo
the code formatting is not very great
 
anyone familiar with readme.io? if so are they using form.io for their documentation drag and drop creation?
 
but the idea is there ^^
 
@GNi33 God damn, that's incredible!
Even better that I didn't even know those books existed!
 
10:50 PM
!!> String.fromCharCode(-1) === String.fromCharCode( 65535 )
 
@towc true
 
!!> String.fromCharCode(-1)
 
@towc "￿"
 
fun
!!> ￿
 
@towc "SyntaxError: illegal character"
 
10:50 PM
!!> var ￿ = 2
 
@towc "SyntaxError: illegal character"
 
11:04 PM
hey guys question
 
hey guy answer
 
lol
how is everything ?
how yall coding day going ?
 
shit's going down
other than rlemon
we're sending him to mars
and arguably that may be up
 
i see
 
ndugger is high as always
yah know, trekking on mountains as he loves doing
cap may be the most human person I've seen in here
you?
 
11:07 PM
i am alright thanks for asking
 
need anything?
 
in node js how can we use URL has a data type
because i try to create a model scheme for my database
 
not sure what do you mean, using the URL as a datatype or seeing the URL's datatype or smth?
 
ok just like you see var somename:String
can i actually do var somename:URL
 
the usual thing that happens is using URL parameters: www.fake.com/page?name=stuff&amount=things
@Lamar I think it's the wrong language buddy :P You may be talking about typescript
or not JS at all
and URLs are strings anyway, treat them as such
 
11:11 PM
ok thanks
 
@VeronicaDeane wow
 

« first day (2070 days earlier)      last day (2876 days later) »