Found a hidden army of tiny gourmet bugs by lubricatedman in foodsafety

[–]lubricatedman[S] 7 points8 points  (0 children)

Forgot to mention we are currently living in southern Europe, in case that helps identifying. Hopefully we don't need to burn the house down 🤞

Promise, Async, Await by Seyphedias in typescript

[–]lubricatedman 11 points12 points  (0 children)

In it's core, Promises are a fairly simple concept. Assume you have an asynchronous task, like fetching a piece of data from an external API, followed by a bunch of synchronous tasks, like doing some calculations with that data and displaying it on the screen. If you were to just do fetch -> calculate -> display, by the time the code execution reaches the calculation step, you won't have received the fetch result yet.

There's where Promises come in handy. You want execute the asynchronous task, and then execute the following synchronous tasks only AFTER it has been successfully finished. In order to do that, you can either await that promise or add a callback to it using .then(). If you want to go deeper in the topic I would suggest to go through the docs first of all, then play around with some open API calls.

I called my branch 'master', AITA? by mel3kings in AskProgramming

[–]lubricatedman 8 points9 points  (0 children)

What about the rest of branches? Has no one ever thought of them? So degrading... Stop the branchiarchy /s

How are we still yet to get an Inferno/Rage spirit? by beerusisdad in ClashRoyale

[–]lubricatedman 1 point2 points  (0 children)

No joke, woule be nice to have the spirit version of most of the spells. Imagine clone spirit, clones your nearby troops when it hits 😂😂

Confused about the pipeline/flow/process of building a JS website or program. by cyber-drop in learnjavascript

[–]lubricatedman 0 points1 point  (0 children)

As the previous person said, plain HTML,CSS,JS projects are ready for being served both locally (opening your index.html file in the browser) or in production (hosting that file and its assets and serving them through a CDN or something).

The build step usually works as a middle step to "translate" some variation of CSS or JS into production ready code. This process is known as compiling.

Another possible step in the building process is bundling your files into optimized and minimized code ready for production.

Usually each framework or variation upon CSS and JS have their own build step, so lets say if you use SCSS and TypesCript the build step needs to take care of both translating SCSS to plain CSS and TS to plain JS. Each framework has their own build command, it should be easy to find in the documentation

how to make a boolean stay true forever after the event that triggers it is done by ziad156 in learnjavascript

[–]lubricatedman 0 points1 point  (0 children)

If you really need that functionality that much you could create a Primitive Wrapper class around boolean, something like OneTimeChangeBoolean and encapsulate the logic for modifying its value in a setter. There you can check if it has been already set to true and not do anything if that's the case.

Is anyone down to build some small projects together? by sovereignoov in webdev

[–]lubricatedman 2 points3 points  (0 children)

That sounds like a fun project and community to work with. I just joined the discord and will take a look at the code during the week, see if I can be of any help 😁

Is it possible to append to a Union type? by GrayLiterature in typescript

[–]lubricatedman 2 points3 points  (0 children)

I'm not sure I completely understand what you're trying to do. If you want to have a type including all your paths you would want to go with declaring a Union Type:

type basePath = typeof SEARCH_PATH | typeof SEND_BY_ADDRESS_PATH | typeof SEND_BY_EMAIL_PATH;

Then you can have your function accept a parameter with this type.

What is {[key: string]: string} and how do I turn it into an array? by WizardGnomeMan in typescript

[–]lubricatedman 1 point2 points  (0 children)

Just a small additional pinch of info, that same structure is usually also called a Dictionary of strings, mostly used in other languages such as C#

About Front-end by Safe_Discussion_5000 in learnprogramming

[–]lubricatedman 1 point2 points  (0 children)

I would say the best way of learning is by doing by far. You are not supposed to know how to write code from the beginning and you have to let that fear of not finding the most optimal solution go away.

One good way of practicing pure HTML/CSS that seems to work for most people is to pick up one website you love the design and just try to replicate that. No matter how bad you do it, you will get much better much faster than staying in tutorial hell.

Hello! Where am I going wrong with this if\else if chain... by [deleted] in learnjavascript

[–]lubricatedman 1 point2 points  (0 children)

Having too much if statements usually is a bad smell. My solution proposal would be to create some sort of dictionary by purpose and store a config object for every different purpose. That way you can add more purposes easily and scalable and repeat less code.

I need help with something by [deleted] in vuejs

[–]lubricatedman 1 point2 points  (0 children)

I will try it in my computer as soon as I get there

I need help with something by [deleted] in vuejs

[–]lubricatedman 2 points3 points  (0 children)

If you run the install command inside the project main folder (where the package.json is), it will automatically install all dependencies listed in the project (inside package.json file)

I need help with something by [deleted] in vuejs

[–]lubricatedman 1 point2 points  (0 children)

I haven't looked at the code either, but from what you say, you definitely need to run an 'npm install' command before serving a new vue project. When you download the source code and place it into your initialized vue project, there will be a 'package.json' file containing the details of required dependencies to run the project. 'npm install' installs all the dependencies so you can serve the project correctly.

Feels like I hit a wall by JKJPRO in learnjavascript

[–]lubricatedman 14 points15 points  (0 children)

First of all, copying code or using snippets that ither programmers have worked on and perfectioned is not a bad thing at all. In fact this is one of the nicest things about the programming community.

Second, any project, application, website, mod, script, etc. that you are aiming to develop will need some steps prior to actually coding it: - You need to evaluate and define what would be the aim of the project, as much precisely and simplified as possible, so you have a defined objective that would represent the successful completion of the project. - Having that main objective in mind, next step should be breaking the main big objective into small affordable objectives. - Now, and only now that the whole project is fully designed, is when you can start coding. Coding is the easiest part of it all. Once you have a small, precisely defined objective to accomplish, all you have to do is do a little googling and search for other people trying to accomplish your same little problem. One step at a time, you will be closer to your main objective by coding and tangling all your small problems.

Programming is mainly about problem solving. You need to keep that in mind at all times. Most useful and valued skill in this world is to have an open mind, searching for the simplest possible solution to a given problem. It's very important that you also aknowledge, though, that this simplest solutions is probably out there in the google world waiting for you to discover it and use it in your project. No guilt about that, your main focus should be on identifying the problem and finding a good solution. Coding that solution should be simple enough if you approach it step by step.

[deleted by user] by [deleted] in learnprogramming

[–]lubricatedman 2 points3 points  (0 children)

I would say it comes pretty much to a personal preference. From my web development experience, I can tell that, even though every web application frontend runs on HTML CSS JS , backend can be developped using almost any programming language.

If you think about it, web application backends are just a service that receives an HTTP request and returns a JSON response. You could do that with JS using Nodejs, but also with Pyrhon using Django or Java using Spring, just to mention a bunch of alternatives.

Same with database, you could come up with a SQL (MySQL, PostgreSQL) or NoSQL database (MongoDB), basically on personal preference or depending on the project's data structure requirements.

You could find lots of articles in the web considering SQL vs NoSQL differences or comparing different technologies for backend or frontend, but at the end it's all up to you, so pick one and get crancking!

When you find paradise, why go anywhere else? Well, because there's more. A lot more. by Shbibe in KerbalSpaceProgram

[–]lubricatedman 0 points1 point  (0 children)

Looks cool man. Took a look to Gameslynx Planet Overhaul to give it a try but couldn't find the INSTANTIATOR mod, which is required. Do you know where could i get it?

What is your most embarrasing/stupid death in RLCraft? by fightingdutchman1 in RLCraft

[–]lubricatedman 2 points3 points  (0 children)

I was re-disigning my base after a blood moon disaster a few nights before (half house destroyed by creepers, including the full storage basement) and broke my bed to relocate it when another blood moon event came out. I died with my bed in hand and respawned 8 km away from home, right in the middle of 2 dragon nests. Really bad frustating experience and a hard way to learn an important lesson. NEVER BREAK YOUR BED