|
The job wants to pay me to do Node/Express soooo. They're early enough I could be like, hmm how about Django? Another question - is one way better than the other? I have data like so that I want to put into a redux store: code:
code:
Or option 2: Search through the list of elements each time for id=1.
|
# ? May 30, 2018 23:31 |
|
|
# ? Jun 3, 2024 21:55 |
|
1 isn't valid JSON, so probably 2.
|
# ? May 30, 2018 23:51 |
|
.
|
# ? May 31, 2018 00:34 |
|
huhu posted:The job wants to pay me to do Node/Express soooo. They're early enough I could be like, hmm how about Django? Option 1. Use normalizr to convert to/from nested/arrayed API structures as necessary. Roadie fucked around with this message at 06:06 on May 31, 2018 |
# ? May 31, 2018 06:03 |
|
Roadie posted:Option 1. Use normalizr to convert to/from nested/arrayed API structures as necessary. Ooh I like this thanks! Another question. I stopped working on a React project last night that worked when I went to bed. This morning I'm getting errors from npm. I had to do an rm -rf node_modules and npm i. What could have possibly happened between last night and now for this to happen?
|
# ? May 31, 2018 15:53 |
|
huhu posted:The job wants to pay me to do Node/Express soooo. They're early enough I could be like, hmm how about Django? Option 3: JavaScript code:
|
# ? May 31, 2018 17:02 |
|
huhu posted:Ooh I like this thanks! ghosts or Thermopyle fucked around with this message at 17:25 on May 31, 2018 |
# ? May 31, 2018 17:16 |
|
huhu posted:Ooh I like this thanks! Next time post the errors. But the answer is almost always: npm is trash fire.
|
# ? May 31, 2018 21:06 |
|
Is Javascript able to use binary code, or execute code from other languages in the browser? (Not talking WASM) I'm asking due to recent trouble installing a package (numjs) due to it requiring an old version of Python, or a node version that it has a binary for. (Both of those situations are relevant to my question.) Also unsure how the magic in WebGL (eg accessing GPU hardware from JS) or React is done.
|
# ? Jun 4, 2018 01:22 |
|
Dominoes posted:Is Javascript able to use binary code, or execute code from other languages in the browser? (Not talking WASM) I'm asking due to recent trouble installing a package (numjs) due to it requiring an old version of Python, or a node version that it has a binary for. (Both of those situations are relevant to my question.) Also unsure how the magic in WebGL (eg accessing GPU hardware from JS) or React is done. No, and I'm fairly sure that library is meant to be run in node.js, not in the browser. NPM can be confusing because some portion of the libraries are server-only (node.js only) and authors don't often do a good job at making it clear when that's the case.
|
# ? Jun 4, 2018 02:03 |
|
Dominoes posted:Is Javascript able to use binary code, or execute code from other languages in the browser? (Not talking WASM) Not to be a jerk, but I think you should really brush up on the basics of how Javascript works and on the differences inherent in Node-specific APIs.
|
# ? Jun 4, 2018 04:18 |
|
Chenghiz posted:No, and I'm fairly sure that library is meant to be run in node.js, not in the browser. NPM can be confusing because some portion of the libraries are server-only (node.js only) and authors don't often do a good job at making it clear when that's the case.
|
# ? Jun 4, 2018 04:30 |
|
Yes the bower package (lol) is for the browser, the npm package is for node.
|
# ? Jun 4, 2018 17:27 |
|
Chenghiz posted:No, and I'm fairly sure that library is meant to be run in node.js, not in the browser. NPM can be confusing because some portion of the libraries are server-only (node.js only) and authors don't often do a good job at making it clear when that's the case.
|
# ? Jun 5, 2018 00:41 |
|
Curious if anyone using React has any favorite libraries for it? The biggest ones I currently use are Axios, Styled Components, Redux, Webpack, Material UI, babel and the associated libraries required to connect them to React. I'm starting a new project and thought it would be a good time to see if there's anything out there that would augment this list.
|
# ? Jun 5, 2018 02:26 |
|
I've fallen in love with lodash FP since my last post so I'd add that to the list. Also redux-saga.
|
# ? Jun 5, 2018 03:47 |
|
Dominoes posted:Is Javascript able to use binary code, or execute code from other languages in the browser? (Not talking WASM) I'm asking due to recent trouble installing a package (numjs) due to it requiring an old version of Python, or a node version that it has a binary for. (Both of those situations are relevant to my question.) Also unsure how the magic in WebGL (eg accessing GPU hardware from JS) or React is done. The magic of WebGL is that it's an API implemented by the browser, in C++, which can already access your GPU. React is just an algorithm implemented in JavaScript. All it does is manipulate data objects and doesn't require any external hardware, so it doesn't need any native code.
|
# ? Jun 5, 2018 04:56 |
|
Dominoes posted:Is Javascript able to use binary code, or execute code from other languages in the browser? (Not talking WASM) I'm asking due to recent trouble installing a package (numjs) due to it requiring an old version of Python, or a node version that it has a binary for. (Both of those situations are relevant to my question.) Also unsure how the magic in WebGL (eg accessing GPU hardware from JS) or React is done. There's several blog posts out there that walk through implementing the basics of React on your own in vanilla Javascript. I highly recommend reading those.
|
# ? Jun 5, 2018 06:28 |
|
huhu posted:Curious if anyone using React has any favorite libraries for it? The biggest ones I currently use are Axios, Styled Components, Redux, Webpack, Material UI, babel and the associated libraries required to connect them to React. I'm starting a new project and thought it would be a good time to see if there's anything out there that would augment this list. I mainly just use: redux, redux-thunk, redux-first-router, reselect in my projects. I just use the built-in fetch for network stuff, and I personally find UI component libraries to be more work than helpful (not that they are for you though!) Reselect is a wonderful, wonderful thing. As is redux-first-router. porksmash posted:I've fallen in love with lodash FP since my last post so I'd add that to the list. Also redux-saga. I would love to hear how you are using lodash FP (maybe with some examples??) if you have the time and inclination to do so.
|
# ? Jun 5, 2018 14:42 |
|
Lumpy posted:I would love to hear how you are using lodash FP (maybe with some examples??) if you have the time and inclination to do so. In this current project we pretend it's the standard library and use it everywhere we can, so instead of someArray.map(item => item.id), we prefer _.map(_.get('id'), someArray). For mangling arrays and/or objects in various ways I've found function composition with _.flow to be pretty handy, and we also use currying in some places to prepare functions to pass around as predicates and the like, or to things that expect a function that takes only a callback. I dunno how to sell it or explain it really - if you're used to functional programming you'll probably love it and use it everywhere, and if you don't you'll probably think it's just pointless. One quite practical upside though is that the argument capping/fixed arity stuff does avoid a whole bunch of minor annoyances/potential bugs with passing functions that take optional arguments as iterators to map/filter etc. The classic example of this is of course parseInt, like code:
|
# ? Jun 5, 2018 16:13 |
|
Lumpy posted:I would love to hear how you are using lodash FP (maybe with some examples??) if you have the time and inclination to do so. I'm using it to filter arrays of objects based on redux state. I'm still a javascript noob so I have no idea if I'm doing something neat or creating a horror - but it works! You can specify deeply nested object attributes to filter on. I need to rework it a little bit to handle deeply nested arrays of objects - the entityValue() in filters.js recurses itself and returns an array of all object values in that nested array, but the filter code does not handle it properly. Here's the code that provides the filtering functionality. It's used in my redux selectors here To specify the object path and conditionals I borrowed Django's ORM double snake case syntax for traversing related objects and/or applying conditionals because I love Django. code:
Edit: The second I hit post I realized I could probably refactor the filter into an object and use the object/comparator string as a key and the value as an object like this: code:
porksmash fucked around with this message at 17:43 on Jun 5, 2018 |
# ? Jun 5, 2018 17:41 |
|
JavaScript code:
How would I go about fixing the above? teen phone cutie fucked around with this message at 22:02 on Jun 5, 2018 |
# ? Jun 5, 2018 22:00 |
|
Would love some feedback on this code I wrote for my redux store and to see if there are any pitfalls or ways to improve on it. For each site I make I've always felt like communicating with the API was a bit sloppy so I tried to write a better request function that handles the actions and actions creators and then the rest of the store is only responsible for creating reducers for the requested data. getRequest.js code:
code:
code:
|
# ? Jun 5, 2018 22:18 |
|
In Chrome when you choose "Save As" of type "Webpage (Complete)" what determines which files come along for the ride? Is it only files referenced in the DOM tree or original HTML source or something, but not files referenced by JavaScript? I'm thinking of the JavaScipt Image() objects I construct, then set their src to a relative URL on my server. Do those not count? In the "Network" tab of Chrome devtools I can see those files arranged in their proper assets folders just like I want the user to be able to save, but saving the web page doesn't copy the assets (images / sounds / 3D models) locally like I need. Also is there any way to include more helpful files that I want to provide a user who saves my page for code remixing on their own machine? (Specifically a batch / shell file that lets them easily set up a python local host) If I can figure this out my students can have a really good workflow to remix parts of my tutorial into their homework assignment. They'd use Chrome's local Workspaces feature to type their code edits directly into the Chrome debugger area and save them to their own files. Happy Thread fucked around with this message at 04:22 on Jun 6, 2018 |
# ? Jun 6, 2018 03:04 |
|
Looks like it's smart enough to only include stuff that makes it into the DOM. If you're not going to throw it on Github and tell them to fork it if they feel like it, just include a link to a zip file. Since you mentioned Python, it's pretty easy to make a script that generates one on the fly based on whatever you have deployed, or your students have changed to make it easier on them to share stuff.
|
# ? Jun 6, 2018 14:25 |
|
I want to do something incredibly simple and commonplace, but I can't find an answer for it. I want to animate (fade-in and up) when an element would scroll into view. I can't find a vanilla JS or even jQuery answer for this, but maybe I'm trying to reinvent the wheel here? Is there a script anyone can recommend to do this fancy animate when scroll into view stuff with minimal bloat?
|
# ? Jun 6, 2018 14:26 |
|
LifeLynx posted:I want to do something incredibly simple and commonplace, but I can't find an answer for it. I want to animate (fade-in and up) when an element would scroll into view. I can't find a vanilla JS or even jQuery answer for this, but maybe I'm trying to reinvent the wheel here? Is there a script anyone can recommend to do this fancy animate when scroll into view stuff with minimal bloat? Something like code:
|
# ? Jun 6, 2018 14:58 |
|
LifeLynx posted:I want to do something incredibly simple and commonplace, but I can't find an answer for it. I want to animate (fade-in and up) when an element would scroll into view. I can't find a vanilla JS or even jQuery answer for this, but maybe I'm trying to reinvent the wheel here? Is there a script anyone can recommend to do this fancy animate when scroll into view stuff with minimal bloat? https://www.w3schools.com/css/css3_animations.asp
|
# ? Jun 6, 2018 15:00 |
|
huhu posted:Would love some feedback on this code I wrote for my redux store and to see if there are any pitfalls or ways to improve on it. For each site I make I've always felt like communicating with the API was a bit sloppy so I tried to write a better request function that handles the actions and actions creators and then the rest of the store is only responsible for creating reducers for the requested data. Use redux-pack and redux-actions to replace all that boilerplate. JavaScript code:
JavaScript code:
Roadie fucked around with this message at 05:00 on Jun 7, 2018 |
# ? Jun 7, 2018 04:57 |
|
Is there a WebRTC guide suitable for games somewhere (ie. I don't need to know about streaming video or media bits, I just want peer-to-peer data channels as simply as possible without having to use any particular framework; a small standalone library is fine). I recognize that I have to do something server side, which seems to be just "transmit a single JSON object from the WebRTC host to the WebRTC client" if I understand things correctly(?). And it also seems to be recommended to run a STUN and/or TURN server to avoid an external dependency on those things, maybe? And I recognize that it's going to be horrible, because network communication is always horrible. It's just this initial connection-forming bit that is unfamiliar and all the "simple instructions" I find go immediately to "here's how to stream a video" and then "now you're done, yay!" which is not really very similar to what I want. I'm sure I could figure it out from the API documentation but it seems likely there's something better out there and I'm just missing it in my searches, like I was missing parceljs.
|
# ? Jun 11, 2018 06:36 |
|
So, uh, my JavaScript skills are pretty dusty and I want to update them. What frameworks are "in" these days?
|
# ? Jun 12, 2018 05:39 |
|
Small White Dragon posted:So, uh, my JavaScript skills are pretty dusty and I want to update them. What frameworks are "in" these days? Personally I like "none." I've learned an amazing amount of powerful things es6 language features can do by rolling big complex things from scratch with no libraries and iteratively finding cleaner ways to do the same thing. I've read some articles that this is actually coming back in style among JavaScript coders.
|
# ? Jun 12, 2018 05:43 |
|
ES6 is a very small language, there's no need to eschew libraries to learn it. JS is bad because there's basically no standard library and it's silly to reimplement a bunch of stuff that's been implemented elsewhere. I mean, if you're just having fun or trying to learn how something works, sure. But if the point of your project is to build a thing... As far as what libraries it depends on what you're building.
|
# ? Jun 12, 2018 05:57 |
|
Small White Dragon posted:So, uh, my JavaScript skills are pretty dusty and I want to update them. What frameworks are "in" these days? React, Redux, ApolloJS.
|
# ? Jun 12, 2018 06:00 |
|
Also, use lodash. It’s not as critical anymore with ES6 but there’s still a bunch of common things that still aren’t available natively. Also also, use typescript. At first you might think “ugh, transpiling” but in the end it just makes everything far less painful.
|
# ? Jun 12, 2018 08:28 |
|
I like ramda a lot more than lodash.
|
# ? Jun 12, 2018 21:54 |
|
tekz posted:I like ramda a lot more than lodash. Functional is cool and good and I use lodash-fp myself, but for someone who isn't familiar, going all out from the start might be a bit overwhelming. Took me a while to get used to lodash-fp. Might try ramda next project though. TheFluff fucked around with this message at 22:03 on Jun 12, 2018 |
# ? Jun 12, 2018 22:00 |
|
tekz posted:I like ramda a lot more than lodash. TheFluff posted:Functional is cool and good and I use lodash-fp myself, but for someone who isn't familiar, going all out from the start might be a bit overwhelming. Took me a while to get used to lodash-fp. Might try ramda next project though. Are there any performance concerns with using ramda or lodash-fp?
|
# ? Jun 13, 2018 01:12 |
|
I found this today and had to nudge it a bit because I was compiling to ES2015 and it was breaking. A Promise wrapper that performs retries inside another Promise.JavaScript code:
Use it something like this: JavaScript code:
|
# ? Jun 14, 2018 01:26 |
|
|
# ? Jun 3, 2024 21:55 |
|
Use p-retry instead. It has better coverage for various edge cases including being able to abort the retries from the outside.
|
# ? Jun 14, 2018 04:56 |