|
If all you want is "come back after other tasks are done" then just dump whatever you were working on to the bottom of the stack. Node will do everything else and come back around to it. This is not an ideal solution for your case since you are describing intense processing, which should definitely be offloaded out of your main thread. But in any case, methods for doing so include: `setTimeout(() => { // your code }, 0);`
|
# ¿ Jan 13, 2017 01:29 |
|
|
# ¿ Apr 29, 2024 17:15 |
|
fankey posted:Pretty simple - every time a new web socket comes in ( via require('ws').Server ) I create a TCP socket and set up handlers on both the socket and ws to shovel data between them. If an error occurs on either one I close down the other side. It all pretty much works but I'm not clear what I need to do with regards to clearing stuff out so the gc can delete the objects. Everyone's first production Node project leaks memory like a sieve. JavaScript wasn't designed with long running processes in mind. It was supposed to run on a webpage that gets cleared out as soon as you click on anything. JavaScript doesn't gc oftentimes seemingly regardless of whether the object can logically be ever used. It therefore requires a great deal of care to write for Node. In depth closures understanding will be necessary and at some point you'll have to begin explicitly setting variables to `undefined`. Nolgthorn fucked around with this message at 02:46 on Jan 29, 2017 |
# ¿ Jan 29, 2017 02:44 |
|
kiwid posted:I'm looking for a library/package that allows a user to upload an image from their computer in the original huge as 12 megapixel size, auto-resize the short side of the image with proportions locked and then allow the user to crop the remaining with a locked size so in the end I get a 300px by 300px profile picture. Any suggestions? Something like this? https://foliotek.github.io/Croppie/ If you have a bit of JS expertise you might be best off allowing the user to crop their photo before uploading a huge file. This can be done using canvas, loading the image into it, allowing them to move it around. The image can then be extracted from the canvas and sent with a post request to the server. You'll have to do some reading on canvas to make that happen.
|
# ¿ Jun 15, 2017 19:33 |
|
I wanted to say I've had the pleasure of using `js-joda` for dates stuff in a recent project and it's so nice. Terrible name but so nice.
|
# ¿ Jun 24, 2017 15:31 |
|
I've had a great experience with TypeScript, but I haven't had any trouble figuring it out from the documentation provided on the official website. Since it's a superset of ES2015+, the massive bulk of TypeScript is just existing valid JavaScript code. It adds a few features but mostly not. In fact it replaces some things you used to need like Babel.
|
# ¿ Jul 6, 2017 06:12 |
|
IAmKale posted:So here's my question: How can I break up and organize my code into multiple files, but get tsc to output a single JavaScript file in basic ES5? This has become a more complicated question after TypeScript developers found out that people were using TypeScript wrong, so they fixed it and you can't really do this with TypeScript alone anymore. They would say that concatenating the files is wrong too. The simplest and best solution: Emit "es2015" targeted at "es5" compatibility. This will give you a folder full of your ts files, as es5 files, with es2015 import statements. Then use Rollup because Webpack is the worst thing to have ever happened. Rollup is really small, it will watch, and it will properly output a single file for you.
|
# ¿ Jul 10, 2017 21:01 |
|
When using state, you want to set an initial state in your constructor.code:
|
# ¿ Jul 16, 2017 14:27 |
|
Knifegrab posted:gently caress yes thank you for recommending postgres I am so sick of people bending over backwards for mongo in situations where it gains them literally no benefit. Postgres is also really really good in so many ways. I've rediscovered my love for document storage after learning to use views incredibly liberally. It just returns whatever crazy object I want spread out all over my database. But for replication and less of a need for replication reasons, a SQL database is often a better option. Wish there was a super simple basic SQL database without all the frills of MySQL and Postgres. Like sqlite but not sqlite. Also I would like something better than using blob for file attachments. Nolgthorn fucked around with this message at 19:31 on Sep 8, 2017 |
# ¿ Sep 8, 2017 19:29 |
|
I've been hearing rumblings that REST is dead. That the concept in practice doesn't work very well, that no consistency exists between APIs and that it's basically a crap shoot where the only value derived from it are descriptive urls. But those urls could be replaced easily by descriptive names, in fact names could be those urls or something even more suitable. Also a point of aggression against REST is that no protocol supports it at all except HTTP and then even methods DELETE and so on are inconsistently implemented. If you have a REST api and want a Websockets version it is flat out impossible. People are saying a single API endpoint which accepts json GET or POST is the future.
|
# ¿ Sep 10, 2017 16:30 |
|
But I get it. These transmission frameworks are too complicated, in a perfect world I'd be able to simply run a function on a different server. The closest we can come to something so simple is a single parameter in the shape of an object. Or, even, an array of parameters. A single endpoint where I can just send something like code:
code:
|
# ¿ Sep 10, 2017 16:48 |
|
Thinking more in the realm of new apis not in upgrading old ones. Error codes too, it seems like they aren't implemented in any kind of uniform or expected way. You can try and GET a resource that's behind authentication and if you're not authenticated you can expect any of a huge number of possible error codes. I understand there is some agreement about what you should receive but I think it'd be a lot simpler if we all admitted that it is on a per API basis, realistically. Some will return 404 some will return something else. I'd prefer something like. code:
I've been building APIs for a while. I know they're not changing soon. But I also am getting disillusioned.
|
# ¿ Sep 10, 2017 22:49 |
|
ROFLburger posted:That's more an implementation issue and not necessarily a shortcoming of REST though, right? I mean there's definitely a standard for what should be returned in that scenario It seems to depend who you ask. https://docs.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes https://developer.springcm.com/guides/rest-api-response-and-error-codes https://www.fusioo.com/guide/api-status-error-codes https://actionstep.atlassian.net/wiki/spaces/API/pages/13140251/Error+Codes Best resource I found looked like a flow chart. I think only communication errors should return a error code, if the software is communicating correctly then just let me communicate with the software and leave the code book out of it.
|
# ¿ Sep 10, 2017 23:49 |
|
I stopped making web apps long ago, I just set up a user facing phpmyadmin and it's practically the same thing.
|
# ¿ Sep 14, 2017 18:15 |
|
I think Typescript is the best thing to happen to Javascript since ES2015 but lately they've been letting me down with the part of it that really mattered to me which was client side compilation. It can compile to ES5 but it cannot compile to a single file. It used to be able to. That functionality has languished and now you need a second compilation step in order to get the code where it needs to be. I was using Rollup to do that which was annoying but still manageable. Now that I see support for Vue, or just about anything which isn't Angular falling by the wayside I've had to stop using Typescript. Which is such a shame because it was one of my favourite tools for a long time.
|
# ¿ Sep 16, 2017 14:56 |
|
Still no ES6 alternative for `pick`... ? code:
|
# ¿ Sep 16, 2017 15:04 |
|
Skandranon posted:How is client side compilation a deal breaker? There are a ton of industry standard tools for bundling files, TypeScript shouldn't be trying to do their own. Because Typescript is a compiler. You only need another compiler if you wanna do client side compilation, something it used to do and used to do a lot better than Browserify or Webpack. "Industry standard" doesn't generally describe technologies that are only a couple of years old, as well.
|
# ¿ Sep 17, 2017 20:58 |
|
gmq posted:Apparently CoffeeScript refused to die honorably. Does this work as an alternative to `decaffeinate`, so that I can get rid of all this coffeescript?
|
# ¿ Sep 23, 2017 18:07 |
|
That worked thanks.
|
# ¿ Sep 24, 2017 09:22 |
|
How is { [key: string]: any } different from { [giraffe: string]: any }?
|
# ¿ Sep 26, 2017 00:42 |
|
Anecdotally, yarn didn't work and I had to force install all of my packages more often than it worked at my last job.
|
# ¿ Sep 28, 2017 18:32 |
|
What are the best places to host your basic Nodejs app these days? I have been using Bluemix which is great but I'm starting to get a small stack of apps running there and it's becoming no longer cheap, they seem to have disabled "auto sleep" for my less important apps so I'm always racking up gigabyte hours too.
|
# ¿ Sep 30, 2017 16:14 |
|
Yes I need to use my own custom domains, I need SSL, I also have a project coming up that needs to host a (incoming) mail server. I don't know much about the details of receiving mail at a domain if there are special requirements for that. Are there smaller players than Microsoft, Heroku, and Google?
|
# ¿ Sep 30, 2017 16:54 |
|
Cool I'll try it out! I don't need my own mail server per say I just need to to be able to receive and read emails, no sending emails, no storing emails, nothing like that. Basically this. https://github.com/Flolagale/mailin Nolgthorn fucked around with this message at 17:23 on Sep 30, 2017 |
# ¿ Sep 30, 2017 17:21 |
|
Now looks frighteningly competent. All I need is a regular package.json and it'll deploy my app... I can add domains and it automatically gets decorated with ssl and whoisguard for free. I can generate as many deployments as I want. It's too bad that the free tier open sources your code. That means I can't really try them without using a test app, instead of my actual app. Something is fishy about the competency. What if I manage my own domains ssl certs and whoisguard elsewhere because I'm a tinfoil hatter and want to spend more.
|
# ¿ Oct 1, 2017 16:20 |
|
Running a bunch of nodes is pretty common. It's supposed to be, you can have one for each api concern. Docker is big because of the demand for microservices, something that lets me run a bunch of small stuff would make me feel more future proof.
|
# ¿ Oct 1, 2017 19:34 |
|
code:
|
# ¿ Oct 8, 2017 00:29 |
|
Man these classes using old javascript make me feel like Javascript is the new PHP. With all of these alternate old ways of doing things, that are still supported, that you're not supposed to use, that are taught in classes. I can see learning programming in school to start, but if I had taken a class for everything I wanted to know I'd have never made it anywhere.
|
# ¿ Oct 8, 2017 01:13 |
|
code:
code:
Nolgthorn fucked around with this message at 17:48 on Oct 8, 2017 |
# ¿ Oct 8, 2017 17:41 |
|
Dude not even God himself understands bitwise operations.
|
# ¿ Oct 8, 2017 23:03 |
|
The Unity3D game engine used to be a modified version of javascript. But, you can use it for all kinds of cool stuff due to the callstack and singlethreadedness.
|
# ¿ Oct 9, 2017 18:11 |
|
Once you get it working move the `throw 'buttes'` into the catch block since you know it'll never get thrown again anyway.
|
# ¿ Oct 9, 2017 21:02 |
|
Mobile safari is very unpredictable. You are defining the city variable twice, you only need to define it the first time.code:
|
# ¿ Oct 12, 2017 21:01 |
|
https://www.htmlgoodies.com/beyond/webmaster/toolbox/article.php/3889011/Using-Safari-for-iPhone-iPad-and-iPod-Touch-Website-Testing.htm Ooh. Safari -> Preferences -> Advanced -> Show developer menu -> Right click -> User Agent -> Select any safari you want.
|
# ¿ Oct 13, 2017 02:30 |
|
Knifegrab posted:I quite think the solution is elegant, and flexible and half my coworkers agree but the other half are screeching. It is elegant now. But it's also incredibly annoying that any time you want new behaviour from a form field, or a new type of form field, you have to go in and hack someone's API. For example what if you wanted a specific form field that had a specialised popover that's only relevant to one page of the application? Hopefully that is happening fairly often. With your solution that is a big pain, because you have re-written HTML.
|
# ¿ Dec 14, 2017 17:15 |
|
In my experience in general it's a good idea to leverage existing tools, especially at the lowest levels such as HTML CSS and JavaScript. I see way too often these days new solutions which completely replace those base toolsets. It forces developers then to have to choose between the in house version or another custom thing. Or combine them. My solution would be more along the lines of something that eliminates duplicated code, but not a replacement for basic tooling. For example, a function that takes a reference to a form and a set of validation criteria. Or a function that takes a reference to a form and returns the data from that form as you like it. Doesn't your answer to my question place that new field outside the `form` element?
|
# ¿ Dec 14, 2017 17:58 |
|
huhu posted:What am I missing here? In react I have an image with two events... I remember solving a similar problem by instantiating the events. code:
e- something like... code:
Nolgthorn fucked around with this message at 20:34 on Dec 22, 2017 |
# ¿ Dec 22, 2017 20:24 |
|
Shrimpy posted:That's my intention, though part of this will require DOM manipulation and checking browser compatibility, so I'm kind of stuck using a browser or something browser-like at some point in the process. Testing in multiple browsers is typically slow and also difficult. How many legacy browsers are you supporting? I'd suggest having them run on Jenkins. But, blah. Really I'd rather figure out what parts of the code are browser-sensitive and fix them.
|
# ¿ Dec 23, 2017 05:30 |
|
It's better to bind a function than it is to create a new function on every execution. Especially in React especially on event declarations. React has a couple of failings in this way, Vue you don't have to do bindings like that.
|
# ¿ Dec 25, 2017 21:16 |
|
I'm interested in capturing and parsing incoming email. For the time being I'm using a 3rd party service but it would be really nice if I could just very simply receive and parse email myself. With a DNS MX record set up, how difficult is it in a node app to capture an email? Once I have captured the email, is it difficult to take it apart? I found this module, which may do what I want however it doesn't talk about how to get the email to begin with. https://github.com/nodemailer/mailparser
|
# ¿ Jan 2, 2018 14:26 |
|
|
# ¿ Apr 29, 2024 17:15 |
|
The same authors offer a SMTP server implementation. oops https://nodemailer.com/extras/smtp-server/
|
# ¿ Jan 2, 2018 14:47 |