|
ufarn posted:Thinking of saying gently caress it and going with Standard (npm install standard). Anyone run into any issues or edge cases that soured them on using it? 2 spaces instead of 4 for indentation is unforgivable.
|
# ? Sep 18, 2016 16:40 |
|
|
# ? Jun 5, 2024 04:52 |
|
Lumpy posted:2 spaces instead of 4 for indentation is unforgivable.
|
# ? Sep 18, 2016 16:42 |
|
Lumpy posted:2 spaces instead of 4 for indentation is unforgivable. Absolutely true. https://www.youtube.com/watch?v=SsoOG6ZeyUI
|
# ? Sep 18, 2016 17:54 |
|
Chenghiz posted:It's good to have a linter setup and enforcing a code style can be useful but I think their stance on semicolons is dumb. As long as you don't mind the rules they set I don't think you'll have any issues though. https://github.com/Flet/semistandard Noam Chomsky posted:Absolutely true. i cant get over how this bit in the show implies that when people use spaces, theyre actually pressing space 4 times. I guess they're all using notepad.exe?
|
# ? Sep 18, 2016 18:51 |
Or eslint + airbnb's styleguide config plugin. Also, javascript without semicolons can gently caress off.
|
|
# ? Sep 18, 2016 19:37 |
|
Yes, I wish everyone would just use airbnb's guide and get on with it.
|
# ? Sep 18, 2016 19:43 |
|
semicolons are useless. single quotes are the best. two spaces is better than four.
|
# ? Sep 18, 2016 19:50 |
|
Strong Sauce posted:semicolons are useless. single quotes are the best. two spaces is better than four. correct except for the semicolon bit. there's no reason whatsoever not to use them and they remove a ton of ambiguity. it's the same with people that try to be clever and don't use braces for single line blocks.
|
# ? Sep 18, 2016 21:48 |
|
Blinkz0rz posted:correct except for the semicolon bit. there's no reason whatsoever not to use them and they remove a ton of ambiguity. it's the same with people that try to be clever and don't use braces for single line blocks. they remove a ton of ambiguity? JS has a spec, there is no ambiguity. you cant start a line with a (. Where is the ambiguity? can yall grandpas with your semicolons and 4 space indent and stuff keep your dumb preferences in the JRE.NET++ 9.3 styleguide or w.e along with the grumpy dude who gets kicked out of conferences for being an rear end in a top hat/wrote the book that encouraged everyone to write terrible JS for 10 years vvvvvv standard js is like the third most popular javascript style guide. the accepted answer on that SO is literally someone saying he prefers semicolons because java and PHP use them bomblol fucked around with this message at 01:24 on Sep 19, 2016 |
# ? Sep 18, 2016 22:50 |
|
Remember when it was a big fad among Javascript 'developers' to not use semicolons because.... well, I guess because they wanted to be unique snowflakes? That dumb movement died out awfully quickly.
|
# ? Sep 19, 2016 00:34 |
|
biznatchio posted:Remember when it was a big fad among Javascript 'developers' to not use semicolons because.... well, I guess because they wanted to be unique snowflakes? nah dude you're just not hip with the latest javascript frameworks. only the uncool people use semicolons now.
|
# ? Sep 19, 2016 02:13 |
|
bomblol posted:they remove a ton of ambiguity? JS has a spec, there is no ambiguity. you cant start a line with a (. Where is the ambiguity? Yes, they do. If you omit you're at the whims of ASI anyway, so why not use them and be explicit and never get bit by that gotcha? But oh, can't be explicit, gotta be clever, gotta go fast.
|
# ? Sep 19, 2016 11:45 |
|
But the gotchas exist regardless of whether you use semicolons or not?
|
# ? Sep 19, 2016 11:47 |
|
Yeah, I should amend my comment to be: "Be verbose, be explicit, be safe. Stop trying to do clever things. Clever things only make you feel smart. Everyone else hates you for them."
|
# ? Sep 19, 2016 11:58 |
|
Cross-posting a question from the Bokeh Google Group. For those that don't know, Bokeh is a Python graphing library that implements its front end with JavaScript. I have a Bokeh Server app that contains both Python server-side callbacks and JavaScript client-side callbacks. Posting here because I suspect the solution is more likely to involve JavaScript trickery than anything else. I'm trying to link the currentTime property of an HTML5 video with the currently selected row of a Bokeh table (SlickGrid). I have video -> table working by using video.ontimeupdate to change the data of a dummy plot object, which then triggers a Python callback where I change the table selection (I need at least part of this loop to be server-side as there is some other data manipulation going on in the Python callback that changes another plot on the page). Going the other way, I have the option of running either a server-side or client-side callback. Ideally, I'd have a client-side callback that changes the video.currentTime property allowing everything else to trigger as normal . What actually happens is the callbacks trigger each other back and forth several times. quote:I have a tricky case of circular callbacks and I'm wondering if anyone has any thoughts.
|
# ? Sep 19, 2016 21:48 |
|
Blinkz0rz posted:Yeah, I should amend my comment to be: A company I worked for fired a couple of CMU JavaScript Bros for not adhering to our style guide. They had other issues too, but we were sick of denying their pull requests and having them break the build because it wouldn't pass JSLint, etc. They had other issues as well, mostly their attitude (and they were certain they were creating the new snapchat), but still it just carried over and dealing with them during code reviews, etc. became a nightmare because of it.
|
# ? Sep 19, 2016 22:49 |
|
The thing is senicolons/not semicolons is not really about explicit/not explicit if you're using a proper linting system already, it is just as much a aesthetic preference as code indenting. In my own small self owned company (2 people) we write semicolon free with ESLint/Typescript. It's not hard, we've never been bitten in the extraordinarily limited number of ASI gotchas because we lint and structure our code properly anyway. When we contract for places with established style guides of course we just follow their convention. People will complain about JavaScript bros, but the sin is non-adherence to a style guide/local convention/linter, not semicolon free or tabs vs spaces or whatever. edit: actually I'll go one more, a file with or without semicolons is functionally identical because that's how it works, replacing 'semicolon-newline' with 'newline' across an entire file will result in the exact same code execution. Inserting semicolons does not turn off ASI. The only place where entering semicolons makes a difference is multiple statements on a single line. Following this logic you can easily make the case that semicolons are useless line noise. I say this not to WIN the argument about which one is right, consistency is the only 'right', just to clear up what semicolon free actually is. Maluco Marinero fucked around with this message at 00:32 on Sep 20, 2016 |
# ? Sep 19, 2016 23:16 |
|
Blinkz0rz posted:Yeah, I should amend my comment to be: Some programmers treat verbosity as a virtue, but I'm going to disagree with "be verbose." That doesn't mean sacrificing clarity in order to be concise, but needless verbosity just decreases the signal-to-noise ratio. You want to put the least burden possible on whoever's reading your code, and that sometimes means less of it, not more. Just try to be as clear as possible and forget about if you're writing too much or too little. That said I prefer to insert semicolons. I don't think they make much difference either way in the verbosity debate, but it's pretty ingrained from other languages, so I pretty much do it out of habit.
|
# ? Sep 20, 2016 01:38 |
|
Need suggestions for front end integration testing. Project will be in react. Considering nightwatchjs.
|
# ? Sep 20, 2016 07:39 |
|
an skeleton posted:Need suggestions for front end integration testing. Project will be in react. Considering nightwatchjs. Does it have to be js? I've never really been happy with anything I've found in js-land. I always use python+selenium+unittest and have been fairly happy. Well at least as happy as you can get when doing the lovely job of writing frontend integration tests.
|
# ? Sep 20, 2016 14:51 |
|
SurgicalOntologist posted:Cross-posting a question from the Bokeh Google Group. Anyone have any ideas here?
|
# ? Sep 22, 2016 18:37 |
|
SurgicalOntologist posted:Anyone have any ideas here? Can you cache responses client side? I mean manually, using (I'm guessing) video's currentTime rounded to some number of seconds as the key. Flag the origin of each event and add logic to not trigger a new request from the client if the origin was the client? You could also have a global 'awaiting response' flag that, say, drops new requests instead of sending them. Just curious, but are you expecting this to work over internet, intranet or localhost latency, because I'm skeptical this can be done reliably over the internet.
|
# ? Sep 22, 2016 18:47 |
|
Oh, nice, a global flag seems pretty straightforward. Don't know why I didn't think of that. There is some lag that causes the updates to lose synchronization with the video when it's not running locally. That should be fixable with an update flag I would imagine--only trigger a new update if the last one has completed. If we're only updating the animation every 10 frames instead of every frame, that's perfectly fine. That said, this is just a proof of concept and does not need to support more than one user at a time. The eventual use case is for internal use so intranet-only supporting a handful of concurrent users is ideal, but if every user needs to run their own local version that's not a big deal either.
|
# ? Sep 22, 2016 19:02 |
|
If you're letting the use jog the video around, caching responses is probably going to be the best UX. I'm not talking about anything complicated, either:JavaScript code:
|
# ? Sep 22, 2016 20:30 |
|
I'm not sure how to fit that into what I'm already doing. I'm not generating responses on my own. Rather, the ontimeupdate callback of the video is triggering a callback in the framework I'm using (Bokeh). Bokeh triggers a server-side Python callback which moves around several elements in the app. My existing method is literally just JavaScript code:
Maybe there's some way to short circuit the Bokeh machinery and cache the JSON payload that it uses to communicate between the client and the Python server, but I don't know how to get a reference to that. I'm adding it to the to-do list though so I will eventually look into it. Thanks for your thoughts, much appreciated. This is my first foray into anything close to webdev and a lot is new to me.
|
# ? Sep 22, 2016 20:44 |
|
Do you write any code for time_glyph to get data or is all that done for you in Bokeh? I did try Bokeh one time but was slightly discouraged because I couldn't figure out how to mess with the front-end code immediately, heh.
|
# ? Sep 22, 2016 21:13 |
|
That is the code for time_glyph to get data. I'm setting its data to the current time, so that the Python server-side code will be able to reference it to get the current time for other operations.
|
# ? Sep 22, 2016 22:31 |
|
So I'm trying to get a better understanding of the this keyword, and i ran into something that confuses me. It's probably because I dont understand JS objects fully, but this code:code:
ddiddles fucked around with this message at 02:43 on Sep 23, 2016 |
# ? Sep 23, 2016 02:39 |
|
ddiddles posted:So I'm trying to get a better understanding of the this keyword, and i ran into something that confuses me. It's probably because I dont understand JS objects fully, but this code: if you call a function as a method on an object, the `this` value is the object it's invoked on. if you call a function as a function (without an object), the `this` value is either the global object (in non-strict mode) or `undefined` (in strict mode). The value of `this` in the objectMethod call does not apply to inner nested functions like objectMethodFunction.
|
# ? Sep 23, 2016 05:24 |
|
In javascript "this" is "the thing left of the dot" If there is nothing "left of the dot", "this" is undefined (in strict mode, which you should always use)
|
# ? Sep 23, 2016 07:51 |
|
Wheany posted:In javascript "this" is "the thing left of the dot" What about in arrow functions....
|
# ? Sep 23, 2016 12:35 |
|
ddiddles posted:So I'm trying to get a better understanding of the this keyword, https://github.com/getify/You-Dont-Know-JS/tree/master/this%20%26%20object%20prototypes
|
# ? Sep 23, 2016 16:07 |
|
SurgicalOntologist posted:That is the code for time_glyph to get data. I'm setting its data to the current time, so that the Python server-side code will be able to reference it to get the current time for other operations. Technically, that's a handler for an event on the video node. I'm asking if data_source.set() is some auto-generated magic or if you wrote it. I'm guessing it's magic, though.
|
# ? Sep 23, 2016 16:20 |
|
Lumpy posted:What about in arrow functions....
|
# ? Sep 23, 2016 16:23 |
|
Wheany posted:In javascript "this" is "the thing left of the dot" This is not always true. This is true when a function on an object when the function is called on that object, but if that function then gets passed to some other callback mechanism (promise, message bus, etc), the meaning of "this" will change.
|
# ? Sep 23, 2016 16:38 |
|
Munkeymon posted:Technically, that's a handler for an event on the video node. I'm asking if data_source.set() is some auto-generated magic or if you wrote it. I'm guessing it's magic, though. Oh, I see what you're asking. Yeah, everything else is Bokeh magic. I think the best chance of being able to cache something is to cache the JSON payload that the Bokeh server sends in response to that event. It should be the same for any given time. Chances are they don't expose this but I'll request it and either get it added to their todo list or get some pointers on how to accomplish it.
|
# ? Sep 23, 2016 16:55 |
|
SurgicalOntologist posted:Oh, I see what you're asking. Yeah, everything else is Bokeh magic. Yes, that's exactly what I was suggesting upthread. However, I just realized that, if your server responds so quickly with data that you just get a little bit of lag doing it this way, that you should be able to compute it all ahead of time by iterating over the gradations in your dataset and squirting that into a script node somewhere so you don't have to make a server round-trip at all. That would eliminate latency at the cost of page load time. Looks like you could make a script node with bokeh.embed and then your video update handler would just grab values out of the global object it leaves laying around. You just have to give the object a predictable name.
|
# ? Sep 23, 2016 18:15 |
|
bomblol posted:How about a too better understanding of this Oh man thats awesome, thanks!
|
# ? Sep 23, 2016 19:53 |
|
I just want to show the current date minus 12 months and 3 months then strip out the time and GMT info - why are the dates wrong? code:
|
# ? Sep 28, 2016 20:58 |
|
|
# ? Jun 5, 2024 04:52 |
|
BobFossil posted:I just want to show the current date minus 12 months and 3 months then strip out the time and GMT info - why are the dates wrong? You want getDate (which returns the day part of the date) not getDay, which returns 1 for Monday, 2 for Tuesday, 3 for Wednesday etc
|
# ? Sep 28, 2016 22:11 |