best-practices | Documents best practices for software development

 by   usgs JavaScript Version: Current License: Non-SPDX

kandi X-RAY | best-practices Summary

kandi X-RAY | best-practices Summary

best-practices is a JavaScript library. best-practices has no bugs, it has no vulnerabilities and it has low support. However best-practices has a Non-SPDX License. You can download it from GitHub.

This repository has largely been superseded by the USGS Software Management Website.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              best-practices has a low active ecosystem.
              It has 58 star(s) with 42 fork(s). There are 37 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              There are 19 open issues and 9 have been closed. On average issues are closed in 18 days. There are 2 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of best-practices is current.

            kandi-Quality Quality

              best-practices has 0 bugs and 0 code smells.

            kandi-Security Security

              best-practices has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              best-practices code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              best-practices has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              best-practices releases are not available. You will need to build from source code and install.

            Top functions reviewed by kandi - BETA

            kandi has reviewed best-practices and discovered the below as its top functions. This is intended to give you an instant insight into best-practices implemented functionality, and help decide if they suit your requirements.
            • Parse certificate file .
            Get all kandi verified functions for this library.

            best-practices Key Features

            No Key Features are available at this moment for best-practices.

            best-practices Examples and Code Snippets

            No Code Snippets are available at this moment for best-practices.

            Community Discussions

            QUESTION

            Is it possible to do a semi-automated test on Cypress that involves solving recaptcha manually?
            Asked 2022-Apr-16 at 23:20

            I know that according to Cypress Best Practices it's recommended to not test 3rd party apps which are not under one's control, but as a a future tester, I'm asserting my authority by doing so anyway!

            So I just wanted to test the log in procedure and POST response with status 200 for this particular page, so I wrote the following test case here:

            ...

            ANSWER

            Answered 2022-Apr-16 at 23:20

            Below

            Here comes the human tester that kills the reCaptcha manually IF NEEDED

            insert the following:

            Source https://stackoverflow.com/questions/71897946

            QUESTION

            Why does bidirectional @OneToMany work without second save()
            Asked 2022-Apr-05 at 13:35

            According to this fabulous article by Thorben Janssen a bidirectional association for @OneToMany works like this:

            ...

            ANSWER

            Answered 2022-Apr-05 at 13:35

            To understand what's going on you need to be familiar with Hibernate ORM entity states.

            In your case, both entities are managed and therefore Hibernate ORM knows that it needs to apply the changes. item3 is managed because it has been persisted, order is managed because it's the result of a find.

            The javadoc for session.save starts with:

            Persist the given transient instance ...

            None of the entities are transient in this case.

            Note that you would be able to change the example, depending on how you map the association with different cascade types.

            For example, if the association items is mapped using CascadeType.PERSIST, this would also work:

            Source https://stackoverflow.com/questions/71746609

            QUESTION

            Reusing Stack with Group when nesting Navigation
            Asked 2022-Mar-29 at 09:32

            Using React Navigation 6, in the documentation, they recommend you use Groups to minimize nested navigators.

            However I'm not sure how to do that in this example, using a nested Stack in a Tab Navigator:

            ...

            ANSWER

            Answered 2022-Mar-29 at 09:32

            The problem here is that Group is a component returned by the navigator. If we create a JSX component that returns that group instead, then this is technically not a Group anymore but its own JSX component.

            This is an unsolved problem in react-native-navigation and is discussed in this GitHub issue, but has apparently no satisfying solution other than an ugly hack.

            We can call the functional component inline.

            Source https://stackoverflow.com/questions/71659381

            QUESTION

            How do I present letsencrypt certificates to Kubernetes nginx (GKE)?
            Asked 2022-Feb-23 at 04:12

            I am learning the Google Cloud platform, trying to implement my first project and am getting lost in the tutorials. I am stuck at the trying to implement an nginx ingress. My ingress is stuck in CrashLoopBackoff and the logs show the following error.

            I know how to do this task with DockerCompose, but not here.

            Where do I start?

            ...

            ANSWER

            Answered 2022-Feb-23 at 04:12

            Instead of using that and following setup of GCP CA setup i would suggest using cert-manager with the ingress.

            Cert-manager will get the TLS cert from let's-encrypt CA , cert-manager will create the secret into k8s and store verified certificate into a secret.

            You can attach secret with the ingress, as per host and use it.

            Cert-manager installation

            YAML example :

            Source https://stackoverflow.com/questions/71228403

            QUESTION

            Using Task.Run in ASP.Net Core
            Asked 2022-Feb-03 at 06:55

            I have read these articles:

            ASP.NET Core Performance Best Practices

            When should I use Task.Run in Asp.Net Core?

            Is it allowed to use Task.Run in an ASP.NET Core controller?

            In the first article in docs.microsoft we can see this statement:

            Call data access, I/O, and long-running operations APIs asynchronously if an asynchronous API is available. Do not use Task.Run to make a synchronous API asynchronous.

            I don't understand this statement well. I'm confused about where and when I should use Task.Run and where and when I should (can) write async web API. For example, consider this method:

            ...

            ANSWER

            Answered 2022-Feb-03 at 04:44

            I'm confused about where and when I should use Task.Run

            On ASP.NET, almost never. You can adopt "never" as a general rule.

            and where and when I should (can) write async web API.

            Your controller actions should be asynchronous if and only if they invoke asynchronous code. Generally speaking, you should prefer asynchronous APIs at the lowest level for all code that performs I/O. Then your action methods are asynchronous only if they need to call that asynchronous code.

            I should write a web method synchronously because there is no async version ... but for method 2 I can change it this way

            Yup.

            Is there any way to run the first API async?

            Think of it this way: if there is synchronous (CPU-bound) work to do, then that work needs a thread. It's already running on a thread pool thread (because web requests run on threads from thread pool). Task.Run will move that work to a different thread pool thread, but it will still run on a thread pool thread. So Task.Run doesn't help anything; it just adds overhead and provides no benefit. Hence the general rule of "don't use Task.Run on ASP.NET".

            Source https://stackoverflow.com/questions/70963014

            QUESTION

            What is the difference between "* text=auto" and "* text=auto eol=lf"?
            Asked 2022-Jan-10 at 23:27

            I was reading about the .gitattributes file and the rule to force line endings in some tutorials it's written like * text=auto and in some others, it's like * text=auto eol=lf at the first line of the file.

            Are there any differences? what does the first one exactly do? Does it even force any line endings?

            Also in some repositories it's mentioned that * text=auto preforms LF normalization! I don't know whether it's true or not.

            ...

            ANSWER

            Answered 2022-Jan-10 at 23:27

            There's a difference between these attributes. text asks Git to perform line ending conversion. Any time Git does this, it will store LF endings in the repository, and it will convert them when it checks files out in the working tree. text=auto asks Git to search the beginning of the file for a NUL byte, and if it finds one, then the file is binary and conversions are not performed; otherwise, the file is text, and conversions are performed. This usually works fine in most cases, and is a sensible default.

            By default, Git honors several configuration variables to decide what line ending conversion should be used in the working tree (LF or CRLF), unless the eol attribute is set. If eol is set, then (a) the file is automatically set to be text and (b) that line ending is always used.

            So in the former case, * text=auto says, "Guess whether this is a text file, and if it is, check this file out with the user's preferred line endings." The eol=lf applies only to files that are guessed as text in this case, as of Git 2.10. In general, eol applies if text is set explicitly, text=auto is set and the file is detected as text, or if text is left unspecified; in Git 2.10 and newer, it doesn't affect files explicitly marked -text or detected as binary with text=auto.

            However, if you're using older versions of Git, this can cause some binary files to be mishandled, since it will force them to always be text. If your repository contains only text files, then it will work, but this is better written as * text eol=lf. Otherwise, you can specify different types of files separately:

            Source https://stackoverflow.com/questions/70633469

            QUESTION

            String.Equals on User Input
            Asked 2021-Dec-06 at 21:31

            I've read and re-read https://docs.microsoft.com/en-us/dotnet/csharp/how-to/compare-strings and https://docs.microsoft.com/en-us/dotnet/standard/base-types/best-practices-strings and I am still unclear on one thing: what comparison type should I use for user inputted strings.

            IE, let's say I have the string in a db record that supports unicode, and before running an update query on the database, I want to make sure the string has actually changed so I do if (string.Equals(dbstring, userinput, StringComparison.?)) { // update db. }

            So which one do I use? Reading the guides above, I primarily use StringComparison.CurrentCulture for UI display such as sorting, and I use Ordinal most things under the hood, and I should rarely use InvariantCulture.

            The part that is confusing me is this line (emphasis mine):

            Do not use string operations based on StringComparison.InvariantCulture in most cases. One of the few exceptions is when you are persisting linguistically meaningful but culturally agnostic data.

            What do they mean 'persisting'? Does this apply to the case of storing unicode strings of user input in a database?

            ...

            ANSWER

            Answered 2021-Dec-06 at 21:31

            "Persisting" in most cases means "storing". Just that. Fancy word for simple thing.

            It doesn't really matter if it's database storage, file storage, internet cloud storage, or, yes, even in-memory storage -- even though "in-memory" doesn't usually coincide with thinking about storage, since it tends to evaporate when the power goes out. It's more about how you are going to use this data, rather than where you are going to store it. So even building a in-memory most-recently-used list of terms can be thought as "persisting", if it's kept long enough in a typical non-disastrous case.

            So, yes, storing unicode strings in a database is exactly as good use case for the word "persisting" as it can be.

            --

            However, for your use-case of determining whever the text entered by the user has changed, I'm not sure if you should focus on the 'persisting' aspect. At this point I think you don't really care about storing, you care about "has it been changed", and that should determine the choice of string comparison.

            All StringComparison flags have some effects. Culture vs Invariant, Case-Sensitive or not, how would you like the comparison to behave, so that the result will be clear and understandable to the user?

            If old text was "Mary has a lamb" and new text is "mAry HaS a Lamb", should it be treated as a change?

            If old text was "Maria hat ein weißes Lamm" and new text is "Maria hat ein weisses Lamm", should it be treated as a change?

            and so on. Right now I can't think of better examples, I'm sure you could think of some when focusing on your userbase and on what will be of the most use to them.

            Please note, that they also may not care, and that you may be overthinking it or focusing on too tiny details too soon. Maybe the default comparison would be just fine for first few years until users tell you it could be better here and there? Dunno. YMMV :)

            Source https://stackoverflow.com/questions/70251990

            QUESTION

            Unit test to detect Memory leaks
            Asked 2021-Nov-16 at 07:33

            According 8th step of this post I wrote following simple unit test to sure my Test class doesn't cause memory leak:

            ...

            ANSWER

            Answered 2021-Nov-16 at 06:03

            There are very few possibilities where this test would do something useful. All of them would involve that the constructor of Test does some kind of registration on a global variable (either register itself on a global event or store the this pointer in a static member). Since that is something that's very rarely done, doing the above test for all classes is overshooting. Also, the test does not cover the far more typical cases for a memory leak in C#: Building up a data structure (e.g. a List) and never clean it up.

            This test may fail for a number of reasons: GC.Collect() does not necessarily force all garbage to be cleaned. It should, but there's no guarantee that it will always happen. Also, since testObj is a local variable, it is not yet out of scope when you call GC.Collect(), so depending on how the code is optimized, the variable cannot be considered garbage yet, which makes the test fail.

            Source https://stackoverflow.com/questions/69984341

            QUESTION

            My Android app is not working properly once I set targetSDK as API 30; how do I figure out the reason(s)?
            Asked 2021-Oct-28 at 17:25

            According to Google, all new Google Play apps from August 2021 would need to target API 30, besides being derived as Android App Bundles. Furthermore, from November 2021, even app updates would need to conform.

            So I was updating my app from targeting API 29 to API 30, and some functions broke. How do I figure out the reason(s)? From the list of changes given by Google, it is not obvious, as it is not just a matter of checking whether certain deprecated APIs are being used.

            Ideally, if Android Studio might provide a way to see how features in API 30 affect my app behavior, that would be cool.

            ...

            ANSWER

            Answered 2021-Oct-28 at 17:25

            I discovered a cool feature in Android Developer options, called App Compatibility Changes. Google describes these Compatibility Framework Tools in this way:

            Android 11 introduced new developer tools for testing and debugging your app against the behavior changes in newer versions of the Android platform. These tools are part of a compatibility framework that lets app developers turn breaking changes on and off individually using developer options or ADB. Use this flexibility as you prepare to target the latest stable API version and as you test your app with the preview release of the next Android version.

            Wow, and looking at it on the phone, it appears you can actually toggle each new feature/change on or off individually?

            Well, let's see; first it gives us a list of all the debuggable apps on the device, and if we select one of them, say, targeting API 29, then we can actually toggle on/off each API 30 feature individually, as shown in the example below, with CALLBACK_ON_CLEAR_CHANGE.

            Cool! Just two points to note: this works with debuggable apps only; and if you're wanting to turn on/off features of API 30, build your debuggable app targeting the API level below it, i.e., API 29 in this case, and then turn on/off features and test away! If you've no idea which feature is causing the problem(s), you can speed up the search by selecting, say, half of the 30 or so changes, see if the problem(s) are there or not, and so on, to zoom in to the right toggles.

            Source https://stackoverflow.com/questions/69758511

            QUESTION

            Are there best practices for creating themeable component variants based on CSS custom properties?
            Asked 2021-Oct-20 at 03:32

            I'm currently working with a team developing a bunch of web components, supposed to be the basis for a current and also upcoming web applications developed in the customer's company.

            I want these components to support color themeing; the first use-case for this being supporting a dark mode.

            Current approach
            • I have defined the customer's corporate design colors in a file colorpalette.css (the colors are just an example):

              ...

            ANSWER

            Answered 2021-Oct-20 at 03:32

            In my opinion, the priority requirement of a theme system is easily changing the appearance. So your first solution would be suitable for this case. Let's talk about its cons.

            This approach obviously results in a myriad of variables, as we need to define a separate variable for each place where we need to apply a different color.

            More variables are needed. Cause they serve different purposes. And when you re-design your theme, it will help you quickly change the appearance without traveling into all the components files. And you only need to care about it just in case re-design the theme. So I think it should not be counted as cons.

            If you later want to introduce additional button variations, you'd have to edit both colors.css and button.css.

            Again, I don't consider this is cons because you just need to add some extra code in 2 files. And these codes will not affect anything that exists before.

            But you forgot to mention the biggest con of this approach. It is you need to rewrite the CSS rules. What's happens if we use a gradient background? The code will be something like that:

            Source https://stackoverflow.com/questions/69333251

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install best-practices

            You can download it from GitHub.

            Support

            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/usgs/best-practices.git

          • CLI

            gh repo clone usgs/best-practices

          • sshUrl

            git@github.com:usgs/best-practices.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular JavaScript Libraries

            freeCodeCamp

            by freeCodeCamp

            vue

            by vuejs

            react

            by facebook

            bootstrap

            by twbs

            Try Top Libraries by usgs

            pestpp

            by usgsC++

            shakemap

            by usgsPython

            libcomcat

            by usgsJupyter Notebook

            geomag-algorithms

            by usgsPython

            geobipy

            by usgsPython