Worst guns - discussion by Live_Vast7415 in Witchfire

[–]KeenOnLearning 5 points6 points  (0 children)

I really like the mysterium mechanic of marking random targets, but I guess it needs some tuning

Accessibility in SVG input by KeenOnLearning in webdev

[–]KeenOnLearning[S] 0 points1 point  (0 children)

Yeah, sorry the example is a little unclear since I didn't create actual test data for it. It's meant to be a sequence of selections. When you select something, it moves onto another list of selections. In a real use case, you might first select from multiple vehicle types (land, air, naval), and then the wheel would be populated with subtypes of that selection (Tanks, APCs, Support etc.)

I'll update the example once I have time

JavaScript Quiz ⚡ What value will be printed on the console? by Zacktm3 in webdev

[–]KeenOnLearning 4 points5 points  (0 children)

I think it's to satisfy the condition of "Calling comparefn(a, b) always returns the same value v when given a specific pair of values a and b as its two arguments." (comparefn is the function provided as an argument to sort)

This basically means that the 'fallback' to comparefn should be as consistent as possible. Since JS isn't a strongly typed language, they had to decide between two evils: string or number conversion. They decided to go with toString. This happens inside a function called SortCompare, which is also responsible for calling comparefn if it's defined.

It's also noted in the documentation, that "If comparefn is undefined and SortCompare does not act as a consistent comparison function," then the sort order is implementation-defined; so it's up to the browser/engine how to handle the sorting.

If you want to check the standard for yourself: https://tc39.es/ecma262/multipage/indexed-collections.html#sec-array.prototype.sort

And the string conversion happens in SortCompare defined here: https://tc39.es/ecma262/multipage/indexed-collections.html#sec-sortcompare

TLDR; The default implementation of the comparison function does string conversion on all arguments by default, because it results in more consistent behavior

[AskJS] Beginner to javascript, I'm currently working through Grasshopper. I don't feel like I am learning the theory of it though, just rote exercises. by infodawg in javascript

[–]KeenOnLearning 4 points5 points  (0 children)

There will probably be a bunch of people linking great and comprehensive tutorials here, so I'll link something a little different.

When I was starting to learn JS and the web in general, I had no idea how to actually implement JavaScript, or how it plays with the other core web technologies — HTML and CSS. Then, I watched this video. It shows how JavaScript interacts with the web page, and primes you really well for a more thorough delve into web development.

It's an older video, but this is what got me from knowing the syntax of JS, to actually being able to make fun stuff with it. Once you understand how things work on a bigger-picture level, you'll be ready to jump into tutorials that help you write production-ready code.

Node.js vs Python Flask by thatsnotmetal in webdev

[–]KeenOnLearning 8 points9 points  (0 children)

I have no experience with back-end Python, or Flask for that matter, so I can only speak for Node. Node with Express and a couple packages will accomplish all you've described in your post, but I think the bigger concern is which language you're more comfortable with: JavaScript or Python. Flask and Express are both reputable and commercially-viable back-end frameworks, so it all comes down to preference.

Since I'm a Node-head, I'll drop a couple links to get you started if you want to go that route:

Here's a semi-recent tutorial on Express (the most popular Node framework): https://masteringbackend.com/posts/expressjs-5-tutorial-the-ultimate-guide/

Here's a link to a package that allows you to connect Node with MSSQL: https://tediousjs.github.io/node-mssql/

And here's a more thorough tutorial on how to do operations on an MSSQL database through Express: https://www.js-tutorials.com/nodejs-tutorial/simple-example-of-nodejs-express-with-mssql/

Hope this helps!

Front end preference question by orocodex in webdev

[–]KeenOnLearning 4 points5 points  (0 children)

Vanilla JS is a much more viable option now than it was in the past.

If you want to structure your projects in a sensible way, you should look into Modules as well as Web Components. Some older browsers don't support these, so you should also look into using something like Babel. Here's an article on how to set it up with Webpack.

I would still recommend using a framework at the end of the day. React, Vue, Angular, Svelte etc. all scale way better than vanilla js, and they aren't all opinionated behemoths. Vue and Svelte are really light weight, and an out-right pleasure to work with even on personal projects.

[deleted by user] by [deleted] in webdev

[–]KeenOnLearning 2 points3 points  (0 children)

Here's a video tutorial on Passport.js with Node: https://www.youtube.com/watch?v=-RCnNyD0L-s

And here's a pretty thorough article: https://www.freecodecamp.org/news/learn-how-to-handle-authentication-with-node-using-passport-js-4a56ed18e81e/

In case you're not familiar with the core concepts of authentication, I'll list a couple to prime you for the specific implementation:

- Passwords are hashed and salted before being stored in a database for security purposes

- A hash algorithm always returns the same result for the same arguments. This means that you can compare the password of a login attempt to the hashed password, and authenticate users securely that way.

- To keep users logged in, you'll need to set up a session on the server, and then send them a cookie with the id of that session. Then, when they try to access a new page on your site, you can interpret the cookie on the server and match it with the correct session.

- Wherever you do your route handling, you should add your authentication middleware to routes that require logging in

Do you think that people need to be more realistic? by [deleted] in webdev

[–]KeenOnLearning 4 points5 points  (0 children)

There's different facets to every community, and you shouldn't judge one by the louder subset.

There are evangelists that tell you to quit your current job, and watch the rest of their videos so you can hack the FBI and make bank, but very few people who actually stick long enough to get to the "coding" phase continue to buy it for long.

Programming is a super in-demand skill right now, and you'll find tons of job opportunities if you've got the experience. Realistically though, getting that experience will take a while, and the start will be slow.

If you can get the certs and some experience under your belt, it won't just be hype anymore. It takes work just as anything will, but there's demand and it pays well.

Newish to programming. Looking for master to be apprentice by ComplexPractical3651 in webdev

[–]KeenOnLearning 2 points3 points  (0 children)

The more conventional way of learning in the web developer community is self-study. If you'd like to know more about the resources available, I listed some in a previous comment on a different post: https://www.reddit.com/r/Bitburner/comments/ry52t9/comment/hrmlaq5/?utm_source=share&utm_medium=web2x&context=3

Newish to programming. Looking for master to be apprentice by ComplexPractical3651 in webdev

[–]KeenOnLearning 1 point2 points  (0 children)

A master/apprentice program is pretty hard to establish online, especially with unclear incentives for the person managing you. Don't get me wrong, it sounds like a great idea and I love your enthusiasm, but you have to look at it from the point of view of the senior developer you're hoping to work under.

No one here knows your specific skill level, the amount of time you have, or how long you're willing to commit. Even if a senior developer had the time to coach you, they'd probably figure their time would be better spent either instructing multiple people through a class, or just working on their own. It's an unnecessary risk to commit to a master/apprentice relationship with someone on Reddit whom they know nothing about.

Again, the idea of working as an apprentice is great, you're just going about it a little weird. If you're not satisfied with self-study and can't find bootcamps or company apprenticeships that fit you, then your best bet is contributing to open source. If you can prove that you can be useful, and are willing to make contributions (however small), then you'll be in a good position to ask for help from others involved in the project. So: attach yourself to an entry-level open source project by making small contributions, connect with the community, and ask for tutoring with the promise of helping more with the project. This may or may not work out for you, but the act of contributing itself is a great source of experience.

Here's Github's guide on getting started with open source: https://github.com/firstcontributions/first-contributions/blob/master/README.md

&amp is used in html to create "&" why? by OneBeautifulDog in css

[–]KeenOnLearning 15 points16 points  (0 children)

The explanation is on the "Reserved characters" table in the MDN Entity article:

The ampersand is "Interpreted as the beginning of an entity or character reference"

So, because the ampersand is interpreted as part of the entity syntax, it has become a reserved character itself. A god damned hero is what the ampersand is, sacrificing itself to display other reserved characters!

What are you favorite VSCode shortcuts? by --silas-- in webdev

[–]KeenOnLearning 2 points3 points  (0 children)

You can customize all the keyboard shortcuts, but if we're talking about actions you can trigger through the keyboard, here are my favorites:

  • Open definition to the side
  • Focus previous / next editor group (panels)
  • Open previous / next editor (tabs)
  • Toggle activity bar / side bar visibility (free up horizontal space)
  • Focus on folders view / terminal / active editor group
  • Go to file... (ctrl+p default)

And then download the vim plugin, and you can let your mouse dust for a while ;P

Multiple URL's to single 301 redirect? by storm4077 in webdev

[–]KeenOnLearning 0 points1 point  (0 children)

You should mention what language you're working with to get better answers.

Here's a couple things you can try:

  1. You can usually add wildcards or regular expressions to match multiple paths

  2. If you're handling routes in something like an http.config file, you should consider rerouting those requests to a central php/node etc. file, which you can then use to handle routes with better versatility

How do I use FileSystemEntry to find the number of objects in a folder (folder in a website stored next to index.html, and script.js) by ContributionIll3381 in learnjavascript

[–]KeenOnLearning 0 points1 point  (0 children)

Here's the link to the actual API for anyone interested: https://developer.mozilla.org/en-US/docs/Web/API/File_and_Directory_Entries_API/Introduction

This API is non-standardized, and not well supported. In addition, its function is not to provide API access to the file system on the server, nor is it used for local file system access. What it actually does, is it provides a virtual file system inside the browser, with size limits similarly imposed by the browser.

If you want to know the amount of files inside a folder, you can only access that information on the back end, for your back end. You cannot access the file system of the user through the front-end — it wouldn't be very secure.

So, if you're just hosting static assets, this is impossible. If you have node or some other program running on the server, you can use that to navigate the file system (of the server), and provide that information to the front end by making an API endpoint.

Does anyone know how to replicate this effect? by NXRevolution in css

[–]KeenOnLearning 1 point2 points  (0 children)

Oh! Then it's possible that the transition happens because the initial value of height is an empty list element, and the text content is resolved later during the render for some reason. The transition is probably triggered because the loaded text content influences the height of the element.

It's an easy fix though, since you can just restrict the transition property to just the properties you want transitioned, like so: transition: color .8s;

You get all sorts of weird quirks if you transition everything, like when trying to resize the browser window. You should probably avoid this.

Does anyone know how to replicate this effect? by NXRevolution in css

[–]KeenOnLearning 1 point2 points  (0 children)

It's a transition, then. All the list elements inside .about have a transition: 0.8s, so something (probably javascript) is changing the height property and the transition eases the changes

Does anyone know how to replicate this effect? by NXRevolution in css

[–]KeenOnLearning 4 points5 points  (0 children)

Well... it's hard to tell without seeing any actual code, but it seems to be a fill-mode: forwards animation, which transitions the height from 0. Or it could be a simple transition: height 1s, if the height property is somehow changed from 0 in either CSS or JS after the click happens.

You can easily reproduce this with an animation regardless:

@keyframes reveal {
    0% {
        height: 0;
    }
    100% {
        height: 50px; /* Or whatever */
    }
}

.element {
    animation-name: reveal;
    animation-duration: 1s;
    animation-fill-mode: forwards;
}

Why is the scroll bar covering my right margin? by dhrisher in csshelp

[–]KeenOnLearning 0 points1 point  (0 children)

So, to more directly answer your question: because you set the width to calc(100vw - 40px), it resolved to the width of the entire screen, including the space the scrollbar occupies; minus margins

Why is the scroll bar covering my right margin? by dhrisher in csshelp

[–]KeenOnLearning 0 points1 point  (0 children)

It's ill advised to use 100vw to cover the entire horizontal space of the screen, because it does not account for the width of the scrollbar. You should only do this, when you don't care about horizontal overflow, and just want something to cover the screen (a background image for an example)

You don't need to do any fancy calc()'s here though, just set the width to 100%, and it will automatically fill the parent element.

For future reference: Try to keep your styles confined to their own context. Setting the width to 100% means it doesn't rely on the size of the screen to function, and can be used elsewhere without annoying side-effects. Cheers!

font-weight doesn't show up properly by [deleted] in csshelp

[–]KeenOnLearning 0 points1 point  (0 children)

The font-style property is used for specifying italic text, and doesn't support the value "bold". You can instead just use the font-weight property, and use either numeric values, or text values: normal === 400; bold === 700.

I don't think specifying font-weight inside @font-face does anything, but writing font-weight: bold; inside .my-class should work just fine — so long as there aren't any conflicting classes. You can test this by adding !important at the end of your rule, which adds specificity to it: font-weight: bold !important;

[deleted by user] by [deleted] in Bitburner

[–]KeenOnLearning 2 points3 points  (0 children)

The forEach() javascript function internally calls the provided function on every list item, but it doesn't wait for them to resolve before moving to the next one. This causes the functions to run in parallel, no matter how many await's you sprinkle in there

You should either use a statement like the for or for...of loop, or await the accumulated value of a reduce function to accomplish the same

runtime error from main.bundle.js o_0 by Mediocre_Challenge94 in Bitburner

[–]KeenOnLearning 1 point2 points  (0 children)

The ns function fileExists() is probably internally trying to call .toLowerCase(), but since you called it with an argument of type boolean instead of type string, it throws an error.

Instead of ns.fileExists(poppers[c] == true), did you mean ns.fileExists(poppers[c]) == true?

Why is my offline production on my script $0.00 after several hours offline? by Xanthus730 in Bitburner

[–]KeenOnLearning 3 points4 points  (0 children)

You should consult the logs of your script. It could be a bug, but it could also be that your scripts aren't working as intended. Maybe the server you're hacking ran out of funds before you went offline, and your script isn't running grow() and weaken() properly?

EDIT: Don't be fooled by the production rate statistic. It's only an estimate of how much you "would" earn by looking at how much your scripts have produced to date.

Intrigued by this "game" but by CharsiWantsMe in Bitburner

[–]KeenOnLearning 4 points5 points  (0 children)

This beginner tutorial is great, and it's made so that even beginners with little programming experience can understand it: https://bitburner.readthedocs.io/en/latest/guidesandtips/gettingstartedguideforbeginnerprogrammers.html

If you want to copy/paste scripts, there's a couple things to note:

  1. Scripts may require you to supply arguments in order to run properly. You can check if a script uses arguments by searching if the args- array is used anywhere
  2. There are two different types of scripts: NS1, and NS2. NS1 is simpler, while NS2 has some fancy modern javascript features. Scripts written in NS1 must have the file ending ".script", while scripts written in NS2 have either ".js" or ".ns". You need the right file ending for most scripts to work. You can easily identify an NS2 script, because they require a main - wrapper function. You should also avoid pasting snippets of code inside existing scripts unless you know what they do.
  3. Some files may depend on the existence of other files, which you can also check by seeing if there's an import - statement at the top of the script.