Merge branch 'main' into main

This commit is contained in:
Fechin authored and GitHub committed 2024-05-22 08:50:18 +08:00
commit a40fda64d1
17 files changed
+5899 -61

No files matched your search

+670 -17
View File
@@ -1,21 +1,674 @@
MIT License
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (c) 2021 @Fechin
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Preamble
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+11 -11
View File
@@ -35,8 +35,8 @@ Reference provides cheat sheets for the following:
- [LaTeX](https://cheatsheets.zip/latex.html): This cheat sheet summarizes a reference list of [LaTeX](https://www.latex-project.org/) commonly used display math notation and some application examples of [KaTeX](https://katex.org/).
- [Rust](https://cheatsheets.zip/rust.html): The Rust quick reference cheat sheet that aims at providing help on writing basic syntax and methods.
- [C#](https://cheatsheets.zip/cs.html): C# quick reference cheat sheet that provides basic syntax and methods.
- [Laravel](https://cheatsheets.zip/laravel.html): [Laravel](https://laravel.com/docs/8.x/) is an expressive and progressive web application framework for PHP.
This cheat sheet provides a reference for common commands and features for Laravel 8.
- [Laravel](https://cheatsheets.zip/laravel.html): [Laravel](https://laravel.com/docs/8.x/) is an expressive and progressive web application framework for PHP.
This cheat sheet provides a reference for common commands and features for Laravel 8.
- [Dart](https://cheatsheets.zip/dart.html): A Dart cheat sheet with the most important concepts, functions, methods, and more. A complete quick reference for beginners.
- [JSON](https://cheatsheets.zip/json.html): This is a quick reference cheat sheet for understanding and writing JSON format configuration files.
- [Hook](https://cheatsheets.zip/hook.html): The [Hook](https://github.com/hook-lang/hook/) cheat sheet is a one-page reference sheet for the Hook programming language.
@@ -55,7 +55,7 @@ This cheat sheet provides a reference for common commands and features for Larav
- [Sass](https://cheatsheets.zip/sass.html): This is a quick reference cheat sheet that lists the most useful features of [SASS](https://sass-lang.com).
- [Go](https://cheatsheets.zip/go.html): This cheat sheet provided basic syntax and methods to help you using [Go](https://go.dev/).
- [Markdown](https://cheatsheets.zip/markdown.html): This is a quick reference cheat sheet to the Markdown syntax.
- [Bash](https://cheatsheets.zip/bash.html): This is a quick reference cheat sheet to getting started with linux bash shell scripting.
- [Bash](https://cheatsheets.zip/bash.html): This is a quick reference cheat sheet to getting started with Linux bash shell scripting.
</details>
@@ -64,10 +64,10 @@ This cheat sheet provides a reference for common commands and features for Larav
- [ChatGPT](https://cheatsheets.zip/chatgpt.html): This cheat sheet lists out prompts and tips from all over the world on how to use ChatGPT effectively
- [VSCode](https://cheatsheets.zip/vscode.html): This VSCode (Visual Studio Code) quick reference cheat sheet shows its keyboard shortcuts and commands.
- [Mitmproxy](https://cheatsheets.zip/mitmproxy.html): [mitmproxy](https://mitmproxy.org/) is a free and open source interactive HTTPS proxy. This is a quick reference cheat sheet to the mitmproxy.
- [Mitmproxy](https://cheatsheets.zip/mitmproxy.html): [Mitmproxy](https://mitmproxy.org/) is a free and open source interactive HTTPS proxy. This is a quick reference cheat sheet to the Mitmproxy.
- [XPath](https://cheatsheets.zip/xpath.html): This is an [XPath](https://en.wikipedia.org/wiki/XPath) selectors cheat sheet, which lists commonly used XPath positioning methods and CSS selectors
- [Emacs](https://cheatsheets.zip/emacs.html): [Emacs](https://www.gnu.org/software/emacs) is the extensible, customizable, self-documenting real time display text editor.
This reference was made for Emacs 27.
This reference was made for Emacs 27.
- [Emmet](https://cheatsheets.zip/emmet.html): [Emmet](https://emmet.io/) is a web-developer’s toolkit for boosting HTML & CSS code writing, which allows you to write large HTML code blocks at speed of light using well-known CSS selectors.
- [RegEX](https://cheatsheets.zip/regex.html): A quick reference for regular expressions (regex), including symbols, ranges, grouping, assertions and some sample patterns to get you started.
- [Vim](https://cheatsheets.zip/vim.html): A useful collection of [Vim](http://www.vim.org/) 8.2 quick reference cheat sheets to help you learn vim editor faster.
@@ -86,19 +86,19 @@ This reference was made for Emacs 27.
- [Netstat](https://cheatsheets.zip/netstat.html): This quick reference cheat sheet provides various for using netstat command.
- [Screen](https://cheatsheets.zip/screen.html): This is a quick reference guide cheat sheet for the screen command.
- [Awk](https://cheatsheets.zip/awk.html): This is a one page quick reference cheat sheet to the [GNU awk](https://www.gnu.org/software/gawk/manual/gawk.html), which covers commonly used awk expressions and commands.
- [Find](https://cheatsheets.zip/find.html): This is a quick reference list of cheat sheet for linux find command, contains common options and examples.
- [Find](https://cheatsheets.zip/find.html): This is a quick reference list of cheat sheet for Linux find command, contains common options and examples.
- [Sed](https://cheatsheets.zip/sed.html): [Sed](https://www.gnu.org/software/sed/manual/sed.html) is a stream editor, this sed cheat sheet contains sed commands and some common sed tricks.
- [Cron](https://cheatsheets.zip/cron.html): [Cron](https://en.wikipedia.org/wiki/Cron) is most suitable for scheduling repetitive tasks. Scheduling one-time tasks can be accomplished using the associated at utility.
- [Git](https://cheatsheets.zip/git.html): This cheat sheet summarizes commonly used Git command line instructions for quick reference.
- [Grep](https://cheatsheets.zip/grep.html): This cheat sheet is intended to be a quick reminder for the main concepts involved in using the command line program grep and assumes you already understand its usage.
- [Netcat](https://cheatsheets.zip/nc.html): This cheat sheet provides various for using Netcat on both Linux and Unix.
- [Netcat](https://cheatsheets.zip/nc.html): This cheat sheet provides various for using netcat on both Linux and Unix.
- [Taskset](https://cheatsheets.zip/taskset): This quick reference cheat sheet for tasket command.
</details>
<details>
<summary>Python</summary>
- [Numpy](https://cheatsheets.zip/numpy.html): [NumPy](https://numpy.org/) is the fundamental package for scientific computing with Python. This cheat sheet is a quick reference for NumPy beginners.
- [NumPy](https://cheatsheets.zip/numpy.html): [NumPy](https://numpy.org/) is the fundamental package for scientific computing with Python. This cheat sheet is a quick reference for NumPy beginners.
</details>
@@ -107,7 +107,7 @@ This reference was made for Emacs 27.
- [Neo4j](https://cheatsheets.zip/neo4j.html): A Neo4j cheat sheet with getting started resources and information on how to query the database with Cypher.
- [PostgreSQL](https://cheatsheets.zip/postgres.html): The [PostgreSQL](https://www.postgresql.org/docs/current/) cheat sheet provides you with the common PostgreSQL commands and statements.
- [Redis](https://cheatsheets.zip/redis.html): This is a [redis](https://redis.io/) quick reference cheat sheet that lists examples of redis commands
- [Redis](https://cheatsheets.zip/redis.html): This is a [Redis](https://redis.io/) quick reference cheat sheet that lists examples of redis commands
- [MySQL](https://cheatsheets.zip/mysql.html): The SQL cheat sheet provides you with the most commonly used SQL statements for your reference.
</details>
@@ -127,7 +127,7 @@ This reference was made for Emacs 27.
- [Slack](https://cheatsheets.zip/slack.html): A visual cheat-sheet for the 62 keyboard shortcuts found in Slack
- [SoundCloud](https://cheatsheets.zip/soundcloud.html): A visual cheat-sheet for the 22 keyboard shortcuts found on SoundCloud
- [Twitter](https://cheatsheets.zip/twitter.html): A visual cheat-sheet for the 26 keyboard shortcuts found on Twitter
- [Android Studio](https://cheatsheets.zip/android-studio.html): A visual cheat-sheet for the 130 keyboard shortcuts found in the Andriod Studio software
- [Android Studio](https://cheatsheets.zip/android-studio.html): A visual cheat-sheet for the 130 keyboard shortcuts found in the Android Studio software
- [Github](https://cheatsheets.zip/github.html): A visual cheat-sheet for the 80 keyboard shortcuts found on Github.com
- [Shopify](https://cheatsheets.zip/shopify.html): A visual cheat-sheet for the 50 keyboard shortcuts found on the Shopify website
- [Zoom](https://cheatsheets.zip/zoom.html): A visual cheat-sheet for the 32 keyboard shortcuts found in Zoom. These shortcuts are for MacOS, for Windows visit /zoom-windows.
@@ -203,7 +203,7 @@ This reference was made for Emacs 27.
- [HTML Characters Entities](https://cheatsheets.zip/html-char.html): This cheat sheet is a complete list of HTML entities with their numbers and names. Also included is a full list of ASCII characters that can be represented in HTML.
- [ISO 639-1 Language Code](https://cheatsheets.zip/iso-639-1.html): This is a list of the ISO language codes that conform to the ISO 639-1 standard, it provide reference for multi-language website.
- [Resolutions](https://cheatsheets.zip/resolutions.html): This cheat sheet lists screen sizes, viewport size and CSS media queries for popular Phones, Tablets, Laptops and Watches
- [HTTP Status Code](https://cheatsheets.zip/http-status-code.html): The http status codes cheat sheet. a quick reference to every HTTP status code.
- [HTTP Status Code](https://cheatsheets.zip/http-status-code.html): The http status codes cheat sheet. A quick reference to every HTTP status code.
- [Emoji](https://cheatsheets.zip/emoji.html): Some of the emoji codes are not super easy to remember, so here is a little cheat sheet.
- [CheatSheets](https://cheatsheets.zip/quickref.html): This is the magic syntax variant manual that you can use on CheatSheets.zip, It's a good practice for contributors.
- [MIME types](https://cheatsheets.zip/mime.html): This cheat sheet lists some common MIME types for the Web. You can look in the [IANA/MIME Media Types registry](http://www.iana.org/assignments/media-types/index.html) which contains all registered MIME types.
File diff suppressed because it is too large. Load diff
+58
View File
@@ -1006,8 +1006,64 @@ func main() {
var r Shape = Rectangle{Length: 3, Width: 4}
fmt.Printf("Type of r: %T, Area: %v, Perimeter: %v.", r, r.Area(), r.Perimeter())
}
```
Go generics {.cols-2}
-------------
### example 1
```go
// comparable represents types that can be compared.
type comparable interface {
int | float64 | string
}
// Max returns the maximum of two comparable values.
func Max[T comparable](a, b T) T {
if a > b {
return a
}
return b
}
func main() {
// Find the maximum of two integers.
maxInt := Max(10, 20)
fmt.Println("Max integer:", maxInt)
// Find the maximum of two floats.
maxFloat := Max(3.14, 2.71)
fmt.Println("Max float:", maxFloat)
// Find the maximum of two strings.
maxString := Max("apple", "banana")
fmt.Println("Max string:", maxString)
}
```
### example 2
```go
// Pair[T, U] represents a generic pair of values.
type Pair[T, U any] struct {
First T
Second U
}
func main() {
pair := Pair[int, string]{First: 42, Second: "hello"}
fmt.Println("First:", pair.First)
fmt.Println("Second:", pair.Second)
// Print the types of the values in the pair.
fmt.Println("Type of First:", reflect.TypeOf(pair.First))
fmt.Println("Type of Second:", reflect.TypeOf(pair.Second))
}
```
Miscellaneous
-------------
@@ -1037,6 +1093,8 @@ Miscellaneous
- import
- return
- var
- iota
{.cols-3 .marker-none}
### Operators and punctuation
+31 -26
View File
@@ -3,21 +3,21 @@ title: HTTP Status Code
background: bg-[#3b7dc0]
date: 2020-12-26 16:09:09
tags:
- response
- server
- response
- server
categories:
- Other
- Other
intro: |
The http status codes cheat sheet. a quick reference to every HTTP status code.
The HTTP status codes cheat sheet. A quick reference to every HTTP status code.
plugins:
- tooltip
- tooltip
---
HTTP Status code
-----------
### Means
### Means
- [1xx: Informational](#1xx-information){data-tooltip="It means the request has been received and the process is continuing."}
- [2xx: Success](#2xx-successful){data-tooltip="It means the action was successfully received, understood, and accepted."}
@@ -26,20 +26,20 @@ HTTP Status code
- [5xx: Server Error](#5xx-server-error){data-tooltip="It means the server failed to fulfill an apparently valid request."}
### 2xx. Successful {.row-span-2}
* [200: OK](https://tools.ietf.org/html/rfc7231#section-6.3.1){data-tooltip="The request is OK."}
* [201: Created](https://tools.ietf.org/html/rfc7231#section-6.3.2){data-tooltip="The request is complete, and a new resource is created ."}
* [201: Created](https://tools.ietf.org/html/rfc7231#section-6.3.2){data-tooltip="The request is complete, and a new resource is created."}
* [202: Accepted](https://tools.ietf.org/html/rfc7231#section-6.3.3){data-tooltip="The request is accepted for processing, but the processing is not complete."}
* [203: Non-Authoritative Information](https://tools.ietf.org/html/rfc7231#section-6.3.4){data-tooltip="The information in the entity header is from a local or third-party copy, not from the original server."}
* [204: No Content](https://tools.ietf.org/html/rfc7231#section-6.3.5){data-tooltip="A status code and a header are given in the response, but there is no entity-body in the reply."}
* [205: Reset Content](https://tools.ietf.org/html/rfc7231#section-6.3.6){data-tooltip="The browser should clear the form used for this transaction for additional input."}
* [206: Partial Content](https://tools.ietf.org/html/rfc7233#section-4.1){data-tooltip="The server is returning partial data of the size requested. Used in response to a request specifying a Range header. The server must specify the range included in the response with the Content-Range header."}
* [207: Multi-Status](https://tools.ietf.org/html/rfc4918#section-11.1){data-tooltip="Provides status for multiple independent operations."}
* [208: Already Reported](https://tools.ietf.org/html/rfc5842#section-7.1){data-tooltip="Used inside a DAV: propstat response element to avoid enumerating the internal members of multiple bindings to the same collection repeatedly."}
* [226: IM Used](https://tools.ietf.org/html/rfc3229#section-10.4.1){data-tooltip="The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance."}
### 4xx. Client Error {.row-span-3}
### 4xx. Client Error {.row-span-3}
* [400: Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1){data-tooltip="The server did not understand the request."}
* [401: Unauthorized](https://tools.ietf.org/html/rfc7235#section-3.1){data-tooltip="The requested page needs a username and a password."}
* [402: Payment Required](https://tools.ietf.org/html/rfc7231#section-6.5.2){data-tooltip="You can not use this code yet."}
@@ -50,38 +50,39 @@ HTTP Status code
* [407: Proxy Authentication Required](https://tools.ietf.org/html/rfc7235#section-3.2){data-tooltip="You must authenticate with a proxy server before this request can be served."}
* [408: Request Timeout](https://tools.ietf.org/html/rfc7231#section-6.5.7){data-tooltip="The request took longer than the server was prepared to wait."}
* [409: Conflict](https://tools.ietf.org/html/rfc7231#section-6.5.8){data-tooltip="The request could not be completed because of a conflict."}
* [410: Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9){data-tooltip="The requested page is no longer available ."}
* [411: Length Required](https://tools.ietf.org/html/rfc7231#section-6.5.10){data-tooltip="The "Content-Length" is not defined. The server will not accept the request without it ."}
* [410: Gone](https://tools.ietf.org/html/rfc7231#section-6.5.9){data-tooltip="The requested page is no longer available."}
* [411: Length Required](https://tools.ietf.org/html/rfc7231#section-6.5.10){data-tooltip="The "Content-Length" is not defined. The server will not accept the request without it."}
* [412: Precondition Failed](https://tools.ietf.org/html/rfc7232#section-4.2){data-tooltip="The pre condition given in the request evaluated to false by the server."}
* [413: Payload Too Large](https://tools.ietf.org/html/rfc7231#section-6.5.11){data-tooltip="The server will not accept the request, because the request entity is too large."}
* [414: URI Too Long](https://tools.ietf.org/html/rfc7231#section-6.5.12){data-tooltip="The server will not accept the request, because the url is too long. Occurs when you convert a "post" request to a "get" request with a long query information ."}
* [415: Unsupported Media Type](https://tools.ietf.org/html/rfc7231#section-6.5.13){data-tooltip="The server will not accept the request, because the mediatype is not supported ."}
* [414: URI Too Long](https://tools.ietf.org/html/rfc7231#section-6.5.12){data-tooltip="The server will not accept the request, because the URL is too long. Occurs when you convert a "post" request to a "get" request with a long query information."}
* [415: Unsupported Media Type](https://tools.ietf.org/html/rfc7231#section-6.5.13){data-tooltip="The server will not accept the request, because the media type is not supported."}
* [416: Range Not Satisfiable](https://tools.ietf.org/html/rfc7233#section-4.4){data-tooltip="The requested byte range is not available and is out of bounds."}
* [417: Expectation Failed](https://tools.ietf.org/html/rfc7231#section-6.5.14){data-tooltip="The expectation given in an Expect request-header field could not be met by this server."}
* [421: Misdirected Request](https://tools.ietf.org/html/rfc7540#section-9.1.2){data-tooltip="The request was directed at a server that is not able to produce a response."}
* [426: Upgrade Required](https://tools.ietf.org/html/rfc7231#section-6.5.15){data-tooltip="The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol."}
* [428: Precondition Required](https://tools.ietf.org/html/rfc6585#section-3){data-tooltip="The origin server requires the request to be conditional."}
* [429: Too Many Requests](https://tools.ietf.org/html/rfc6585#section-4){data-tooltip="The user has sent too many requests in a given amount of time."}
* [431: Request Header Fields Too Large](https://tools.ietf.org/html/rfc6585#section-5){data-tooltip="The server is unwilling to process the request because its header fields are too large."}
* [451: Unavailable For Legal Reasons](https://datatracker.ietf.org/doc/html/rfc7725#section-3){data-tooltip="This status code indicates that the server is denying access to the resource as a consequence of a legal demand."}
### 1xx. Information
* [100: Continue](https://tools.ietf.org/html/rfc7231#section-6.2.1){data-tooltip="Only a part of the request has been received by the server, but as long as it has not been rejected, the client should continue with the request."}
* [101: Switching Protocols](https://tools.ietf.org/html/rfc7231#section-6.2.2){data-tooltip="The server switches protocol."}
* [102: Processing](https://tools.ietf.org/html/rfc2518#section-10.1){data-tooltip="An interim response used to inform the client that the server has accepted the complete request, but has not yet completed it."}
* [103: Early Hints](https://tools.ietf.org/html/rfc8297){data-tooltip="Indicates to the client that the server is likely to send a final response with the header fields included in the informational response."}
### 3xx. Redirection
* [300: Multiple Choices](https://tools.ietf.org/html/rfc7231#section-6.4.1){data-tooltip="A link list. The user can select a link and go to that location. Maximum five addresses  ."}
* [301: Moved Permanently](https://tools.ietf.org/html/rfc7231#section-6.4.2){data-tooltip="The requested page has moved to a new url ."}
* [302: Found](https://tools.ietf.org/html/rfc7231#section-6.4.3){data-tooltip="The requested page has moved temporarily to a new url ."}
* [303: See Other](https://tools.ietf.org/html/rfc7231#section-6.4.4){data-tooltip="The requested page can be found under a different url ."}
* [300: Multiple Choices](https://tools.ietf.org/html/rfc7231#section-6.4.1){data-tooltip="A link list. The user can select a link and go to that location. Maximum five addresses."}
* [301: Moved Permanently](https://tools.ietf.org/html/rfc7231#section-6.4.2){data-tooltip="The requested page has moved to a new URL."}
* [302: Found](https://tools.ietf.org/html/rfc7231#section-6.4.3){data-tooltip="The requested page has moved temporarily to a new URL."}
* [303: See Other](https://tools.ietf.org/html/rfc7231#section-6.4.4){data-tooltip="The requested page can be found under a different URL."}
* [304: Not Modified](https://tools.ietf.org/html/rfc7232#section-4.1){data-tooltip="This is the response code to an If-Modified-Since or If-None-Match header, where the URL has not been modified since the specified date."}
* [305: Use Proxy](https://tools.ietf.org/html/rfc7231#section-6.4.5){data-tooltip="The requested URL must be accessed through the proxy mentioned in the Location header."}
* [306: Unused](https://tools.ietf.org/html/rfc7231#section-6.4.6){data-tooltip="This code was used in a previous version. It is no longer used, but the code is reserved."}
* [307: Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7){data-tooltip="The requested page has moved temporarily to a new url."}
* [307: Temporary Redirect](https://tools.ietf.org/html/rfc7231#section-6.4.7){data-tooltip="The requested page has moved temporarily to a new URL."}
* [308: Permanent Redirect](https://tools.ietf.org/html/rfc7538#section-3){data-tooltip="The request and all future requests should be repeated using another URI."}
### 5xx. Server Error
@@ -91,4 +92,8 @@ HTTP Status code
* [503: Service Unavailable](https://tools.ietf.org/html/rfc7231#section-6.6.4){data-tooltip="The request was not completed. The server is temporarily overloading or down."}
* [504: Gateway Timeout](https://tools.ietf.org/html/rfc7231#section-6.6.5){data-tooltip="The gateway has timed out."}
* [505: HTTP Version Not Supported](https://tools.ietf.org/html/rfc7231#section-6.6.6){data-tooltip="The server does not support the "http protocol" version."}
* [506: Variant Also Negotiates](https://tools.ietf.org/html/rfc2295#section-8.1){data-tooltip="Transparent content negotiation for the request results in a circular reference."}
* [507: Insufficient Storage](https://tools.ietf.org/html/rfc4918#section-11.5){data-tooltip="The server is unable to store the representation needed to complete the request."}
* [508: Loop Detected](https://tools.ietf.org/html/rfc5842#section-7.2){data-tooltip="The server detected an infinite loop while processing the request."}
* [510: Not Extended](https://tools.ietf.org/html/rfc2774#section-7){data-tooltip="Further extensions to the request are required for the server to fulfill it."}
* [511: Network Authentication Required](https://tools.ietf.org/html/rfc6585#section-6){data-tooltip="The client needs to authenticate to gain network access."}
+1 -1
View File
@@ -378,7 +378,7 @@ then, true || evaluates to false and eventually returns true
```kotlin
var studied = true
var well Rested = true
var wellRested = true
if (wellRested) {
println("Good luck today!")
+1 -1
View File
@@ -248,7 +248,7 @@ preview | method | preview | method | preview | method | preview | method
:- | :- | :- | :-
:- | :- | :- | :-
| Correct: | <pur>`\tan(at-n\pi)`</pur> | `KaTeX:\rightarrow` | `KaTeX:\tan(at-n\pi)`|
| Incorrect: | <pur>`tan(at-n\pi)`</pur> | `katex:\rightarrow` | `KaTeX:tan(at-n\pi)` | {.left-align}
| Incorrect: | <pur>`tan(at-n\pi)`</pur> | `KaTeX:\rightarrow` | `KaTeX:tan(at-n\pi)` | {.left-align}
### Logic and Set Theory{.col-span-3}
+1 -1
View File
@@ -558,7 +558,7 @@ ON t(c3,c4)
Drop an index
```sql
DROP INDEX idx_name;
DROP INDEX idx_name ON t;
```
+328
View File
@@ -0,0 +1,328 @@
---
title: OpenSSL
date: 2020-11-25 18:28:43
icon: icon-style
background: bg-emerald-600
tags:
categories:
- Linux Command
intro: |
This is a reference of commands to use to interact with electronic certificates
plugins:
- copyCode
---
## Private Key {.cols-2}
### Print out the private key details
```bash
openssl rsa -check -text -in privateKey.key
```
### Print out the hashes of the private key
```bash
openssl rsa -noout -modulus -in privateKey.key | openssl md5
openssl rsa -noout -modulus -in privateKey.key | openssl sha1
openssl rsa -noout -modulus -in privateKey.key | openssl sha256
openssl rsa -noout -modulus -in privateKey.key | openssl sha512
```
### Change password
```bash
openssl rsa -aes256 -in privateKey.key -out newPrivateKey.key
```
### List available elliptic curves
```bash
openssl ecparam -list_curves
```
### Create elliptic curve private key with a specific curve
```bash
openssl ecparam -name secp521r1 -genkey -noout -out privateKey.key
```
## Certificate {.cols-2}
### Print out the hashes of the certificate
```bash
openssl x509 -noout -modulus -in certificate.crt | openssl md5
openssl x509 -noout -modulus -in certificate.crt | openssl sha1
openssl x509 -noout -modulus -in certificate.crt | openssl sha256
openssl x509 -noout -modulus -in certificate.crt | openssl sha512
```
Or, alternatively:
```bash
openssl x509 -noout -fingerprint -in certificate.crt
openssl x509 -noout -fingerprint -sha256 -in certificate.crt
```
### Print out the content of the certificates
```bash
openssl x509 -in certificate.crt -noout -text|more
```
### Print out specific fields of the certificates
```bash
openssl x509 -noout -subject certificate.crt
openssl x509 -noout -issuer certificate.crt
openssl x509 -noout -dates certificate.crt
```
### Inspect server certificates
```bash
echo | openssl s_client -servername www.openssl.org -connect \
www.openssl.org:443 2>/dev/null | openssl x509 -noout -text|more
echo | openssl s_client -servername imap.arcor.de -connect \
imap.arcor.de:993 2>/dev/null | openssl x509 -noout -text|more
```
### Verify certificates
**OK**
```bash
openssl verify -verbose -x509_strict -CAfile \
issuer.crt Test\ Haeschen\ 1.crt
```
Result:
```bash
Test Haeschen 1.crt: OK
```
**Corrupted** ([for example](https://security.stackexchange.com/questions/60804/creating-an-x-509-certificate-with-an-invalid-signature))
```bash
openssl verify -verbose -x509_strict -CAfile \
issuer.crt Test\ Haeschen\ 1_corrupted.crt
```
Result:
```bash
C = DE, ST = Thueringen, L = Rudolstadt, O = Damaschkestr. 11, OU = Arbeitszimmer, CN = Test Haeschen 1
error 7 at 0 depth lookup: certificate signature failure
error Test Haeschen 1_corrupted.crt: verification failed
40270500477F0000:error:0200008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding:../crypto/rsa/rsa_pk1.c:75:
40270500477F0000:error:02000072:rsa routines:rsa_ossl_public_decrypt:padding check failed:../crypto/rsa/rsa_ossl.c:598:
40270500477F0000:error:1C880004:Provider routines:rsa_verify:RSA lib:../providers/implementations/signature/rsa_sig.c:774:
40270500477F0000:error:06880006:asn1 encoding routines:ASN1_item_verify_ctx:EVP lib:../crypto/asn1/a_verify.c:217:
```
## S/Mime {.cols-2}
### create signature
```bash
openssl smime -sign -in msg.txt -text -out msg.p7s \
-signer certificate.crt -inkey privateKey.key
```
### Verify signature
```bash
openssl smime -verify -in msg.p7s -CAfile chain.pem
```
## CRL {.cols-2}
### Print out the contents of the CRL
```bash
openssl crl -inform DER -noout -text -in crl/cacrl.der
openssl crl -inform PEM -noout -text -in crl/cacrl.pem
```
## PKCS#12 {.cols-2}
### Display contents
```bash
openssl pkcs12 -info -in digitalIdentity.p12
```
### Create from certificate and private key
```bash
openssl pkcs12 -export -in certificate.cert \
-inkey privateKey.key -out digitalIdentity.p12
```
### Extract private key
```bash
openssl pkcs12 -in digitalIdentity.p12 -out privateKey.key
```
### Convert to PEM
```bash
openssl pkcs12 -in digitalIdentity.p12 -out digitalIdentity.pem
```
## TSA {.cols-2}
### Display query
```bash
openssl ts -query -in query.tsq -text
```
### Display reply
```bash
openssl ts -reply -in reply.tsr -text
```
### Verify reply
```bash
openssl ts -verify -in reply.tsr -data data.dat -CAfile chain.pem
```
### Extract token from reply
```bash
openssl ts -reply -in reply.tsr -token_out -out token.tk
```
### Extract certificates from token
```bash
openssl pkcs7 -inform DER -in token.tk -print_certs -noout -text
```
## CSR {.cols-2}
### Create from existing key
```bash
openssl req -new -key privateKey.key -out my.csr
```
This can of course be a RSA key or one based on an elliptic curve. Available curves can be listed using
```bash
openssl ecparam -list_curves
```
Afterwards you chose one of the curves and create a private key like so:
```bash
openssl ecparam -name secp521r1 -genkey -noout \
-out privateKey.key
```
### Display
```bash
openssl req -in my.csr -noout -text
```
## HTTPS {.cols-2}
### Dump Certificates PEM encoded
```bash
openssl s_client -showcerts -connect www.example.com:443
```
## STARTTLS {.cols-2}
### Dump Certificates PEM encoded
```bash
openssl s_client -showcerts -starttls imap \
-connect mail.domain.com:139
```
## S/MIME verification {.cols-2}
### Possible outcomes
Message was tampered with (return code 4):
```bash
Verification failure
140485684135232:error:2E09A09E:CMS routines:CMS_SignerInfo_verify_content:verification failure:../crypto/cms/cms_sd.c:847:
140485684135232:error:2E09D06D:CMS routines:CMS_verify:content verify error:../crypto/cms/cms_smime.c:393:
```
Message signature not trusted (return code 4):
```bash
Verification failure
140146111432000:error:2E099064:CMS routines:cms_signerinfo_verify_cert:certificate verify error:../crypto/cms/cms_smime.c:252:Verify error:unable to get local issuer certificate
```
Message not signed (return code 2):
```bash
Error reading S/MIME message
140701208487232:error:0D0D40CD:asn1 encoding routines:SMIME_read_ASN1:invalid mime type:../crypto/asn1/asn_mime.c:469:type: multipart/alternative
```
Validation successful (return code 0):
```bash
Verification successful
```
### Verify the validity of an email message
```bash
openssl cms -verify -in some_email_message.eml
```
### Verify the validity of an email message explicitly specifying trust
```bash
openssl cms -verify -in some_email_message \
-CAfile trust_anchor-crt
```
### Signed and encrypted messages need to be decrypted first:
Note: the P12 file holding the digital identity must be pem-encoded! (see above)
```bash
openssl cms -decrypt -out decrypted_email_message \
-inkey p12.pem -in some_encrypted_email_message
```
## Raw {.cols-2}
### See the raw structure of an ASN.1 file (only for DER encoded files)
```bash
openssl asn1parse -in mysterious_file.pem
```
### With a bit more detail
```bash
openssl asn1parse -dump -strictpem -in mysterious_file.pem
```
## Some resources with useful OpenSSL commands
* [OpenSSL command cheatsheet](https://www.freecodecamp.org/news/openssl-command-cheatsheet-b441be1e8c4a/)
* [21 OpenSSL Examples to Help You in Real-World](https://geekflare.com/openssl-commands-certificates/)
* [The Most Common OpenSSL Commands](https://www.sslshopper.com/article-most-common-openssl-commands.html)
* [OpenSSL Quick Reference Guide](https://www.digicert.com/ssl-support/openssl-quick-reference-guide.htm)
* [openssl_commands.md](https://gist.github.com/webtobesocial/5313b0d7abc25e06c2d78f8b767d4bc3)
* [OpenSSL Essentials: Working with SSL Certificates, Private Keys and CSRs](https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrs)
* [OpenSSL tips and tricks](https://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art030)
* [Checking A Remote Certificate Chain With OpenSSL ](https://langui.sh/2009/03/14/checking-a-remote-certificate-chain-with-openssl/)
* [OpenSSL: how to extract certificates and token status from RFC3161 timestamping reply?](https://stackoverflow.com/questions/66044640/openssl-how-to-extract-certificates-and-token-status-from-rfc3161-timestamping)
* [Steps to generate CSR for SAN certificate with openssl](https://www.golinuxcloud.com/openssl-subject-alternative-name/)
* [Howto add a Subject Alternative Name extension into a Certificate Signing Request](https://support.microfocus.com/kb/doc.php?id=3522065)
+186 -1
View File
@@ -382,4 +382,189 @@ export default function Weather(props) {
}
}
```
Note: Make sure to import Axios first to your project.
Note: Make sure to import Axios first to your project.
HOOKS
------------
### useState Hook
```javascript
import React, { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increment</button>
</div>
);
}
export default Counter;
```
Note: The useState Hook is a built-in React Hook that allows functional components to manage local state. It provides a way to declare state variables and update them within a functional component.
Example code illustrating how to use it
### Multiple State Variable Declaration
```javascript
import React, { useState } from "react";
function Counter() {
const [count, setCount] = useState(0);
const [name, setName] = useState("");
const [isCompleted, setIsCompleted] = useState(false);
const handleIncrement = () => {
setCount(count + 1);
};
const handleNameChange = (event) => {
setName(event.target.value);
};
const toggleCompletion = () => {
setIsCompleted(!isCompleted);
};
return (
<div>
<p>Count: {count}</p>
<button onClick={handleIncrement}>Increment</button>
<input type="text" value={name} onChange={handleNameChange} placeholder="Enter your name" />
<label>
<input type="checkbox" checked={isCompleted} onChange={toggleCompletion} />
Completed
</label>
</div>
);
}
export default Counter;
```
Note: You can declare multiple state variables using the useState Hook by calling it multiple times in a functional component. Each call to useState manages a separate piece of state.
### Input State Management
```javascript
import { useState } from "react";
function FormExample() {
const [formData, setFormData] = useState({name: "",email: "",message: ""});
const handleChange = (event) => {
const { name, value } = event.target;
setFormData((prevFormData) => ({ ...prevFormData, [name]: value }));
};
const handleSubmit = (event) => {
event.preventDefault();
alert(`Name: ${formData.name}, Email: ${formData.email}, Message: ${formData.message}`
);
};
return (
<form onSubmit={handleSubmit}>
<label htmlFor="name">Name:</label>
<input type="text" id="name" name="name" value={formData.name} onChange={handleChange}/>
<label htmlFor="email">Email:</label>
<input type="email" id="email" name="email" value={formData.email} onChange={handleChange}/>
<label htmlFor="message">Message:</label>
<textarea id="message" name="message" value={formData.message} onChange={handleChange}/>
<button type="submit">Submit</button>
</form>
);
}
export default FormExample;
```
### useEffect Hook
```javascript
import React, { useState, useEffect } from "react";
function Timer() {
const [seconds, setSeconds] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setSeconds((prevSeconds) => prevSeconds + 1);
}, 1000);
return () => clearInterval(interval);
}, []);
return <div>Seconds: {seconds}</div>;
}
export default Timer;
```
Note: The useEffect Hook in React is used for performing side effects in functional components. It allows you to execute code based on component lifecycle events like mounting, updating, and unmounting.
### Fetch API using useEffect
```javascript
import React, { useState, useEffect } from "react";
import axios from "axios";
function UserList() {
const [users, setUsers] = useState([]);
useEffect(() => {
axios.get("https://jsonplaceholder.typicode.com/users")
.then(response => {
setUsers(response.data);
})
.catch(error => {
console.error("Error fetching users:", error);
});
}, []);
return (
<div>
<h2>User List</h2>
<ul>
{users.map(user => (
<li key={user.id}>{user.name}</li>
))}
</ul>
</div>
);
}
export default UserList;
```
Note: Make sure to import Axios first to your project.
### Custom Hook creation useLocalStorage
```javascript
import { useState, useEffect } from "react";
function useLocalStorage(key, initialValue) {
const [value, setValue] = useState(() => {
const storedValue = localStorage.getItem(key);
return storedValue !== null ? JSON.parse(storedValue) : initialValue;
});
useEffect(() => {
localStorage.setItem(key, JSON.stringify(value));
}, [key, value]);
return [value, setValue];
}
export default useLocalStorage;
```
Note: Custom Hooks are reusable functions in React that contain logic shared across multiple components. They allow you to extract stateful logic from components into standalone functions.
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -277,7 +277,7 @@ println!("Share {cs} for developers");
```rust
// Creating an empty string object
let my_string = String::new;
let my_string = String::new();
// Converting to a string object
let S_string = a_string.to_string()
+156
View File
@@ -0,0 +1,156 @@
---
title: Selenium
date: 2024-05-04 19:50:01
background: bg-[#d33731]
tags:
- automation
- testing
categories:
- Programming
intro: |
This cheat sheet is a crash course for Selenium beginners and help to get the idea about the basic concepts of Selenium.
---
## Getting Started
### Initialize Browser Drivers {.row-span-2}
| Browser | Syntax |
| --------- | --------------------------------------- |
| `Chrome` | WebDriver driver = new ChromeDriver(); |
| `Edge` | WebDriver driver = new EdgeDriver(); |
| `Firefox` | WebDriver driver = new FirefoxDriver(); |
| `Safari` | WebDriver driver = new SafariDriver(); |
{.show-header .left-text}
### Selenium Locators {.col-span-2}
| Locator | Syntax |
| ----------------- | --------------------------------------------- |
| `className` | driver.findElement(By.className (“key”)) |
| `cssSelector` | driver.findElement(By.cssSelector(key")) |
| `id ` | driver.findElement(By.id(key")) |
| `linkText` | driver.findElement(By.linkText(key")) |
| `name` | driver.findElement(By.name(“key")) |
| `partialLinkText` | driver.findElement(By.partialLinkText(“key")) |
| `tagName ` | driver.findElement(By.tagName (“key”)) |
| `xpath` | driver.findElement(By.xpath(“key")) |
{.show-header .left-text}
### Navigate to URL
```shell script
driver.get("https://www.example.com");
```
### Close all browser windows
```shell script
driver.quit();
```
### Close the current browser window
```shell script
driver.close();
```
### Navigation {.col-span-2}
| Description | Syntax |
| ------------------------------- | ------------------------------------------------ |
| `Navigate to a new URL` | driver.navigate().to("https://www.newsite.com"); |
| `Go forward to the next page` | driver.navigate().forward(); |
| `Go back to the previous page ` | driver.navigate().back(); |
| `Refresh the current page` | driver.navigate().refresh(); |
{.show-header .left-text}
### Frame Handling {.col-span-2}
| Description | Syntax |
| --------------------------------- | ----------------------------------- |
| `Switch to a frame` | driver.switchTo().frame("frameId"); |
| `Switch back to the main content` | driver.switchTo().defaultContent(); |
{.show-header .left-text}
### Alerts/Pop-Ups
```shell script
Alert alert = driver.switchTo().alert();
// Used to click on the ‘OK’ button of the alert.
alert.accept();
// Used when the ‘Cancel’ button is clicked in the alert box.
alert.dismiss();
// Used to send text to an alert
alert.sendKeys("text");
// Used to capture the alert message.
alert().getText();
```
### Mouse and Keyboard Actions {.col-span-2}
```shell script
Actions actions = new Actions(driver);
// Shifts the mouse pointer to the center of the element and click on it
actions.moveToElement(element).click().build().perform();
// Performs double click on the element
actions.doubleClick(element).perform();
// Drags the element from one point and drops to another
actions.dragAndDrop(source, target).perform();
// Sends a series of keys to the element
actions.sendKeys(element, "text").perform();
```
### Page Information {.col-span-1}
```shell script
// Get the page title
driver.getTitle();
// Get the current page URL
driver.getCurrentUrl();
// Get the entire page source code
driver.getPageSource();
```
### Waits {.col-span-3}
```shell script
// Explicit Wait :- These are conditional waits can be applied to satisfy a particular condition
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.elementToBeClickable(element));
```
```shell script
// Implicit Wait :- Once the command is run, Implicit Wait remains for the entire duration for which the browser is open.
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
```
```shell script
// Fluent Wait :- Fluent Wait in Selenium marks the maximum amount of time for Selenium WebDriver to wait for a certain condition (web element) becomes visible. It also defines how frequently WebDriver will check if the condition appears before throwing the “ElementNotVisibleException”.
FluentWait wait = new FluentWait(driver);
//Specify the timeout of the wait
wait.withTimeout(5000, TimeUnit.MILLISECONDS);
//Specify polling time
wait.pollingEvery(250, TimeUnit.MILLISECONDS);
//Specify what exceptions to ignore
wait.ignoring(NoSuchElementException.class)
//This is how we specify the condition to wait on.
wait.until(ExpectedConditions.alertIsPresent());
```
+434
View File
@@ -0,0 +1,434 @@
---
title: Terraform
date: 2024-4-18
background: bg-[#7f48be]
tags:
- container
- virtual
categories:
- Programming
intro: |
This is a quick reference cheat sheet for [Terraform](https://docs.docker.com/get-started/).
plugins:
- copyCode
---
## HCL Syntax:
```
(Block Name) (Resource Type) (Resource Name)
| | |
▽ ▽ ▽
resource "aws_instance" "my_aws_server" {
--
ami = "ami-1251351351513" |<--(Arguments)
instance_type = "t2.micro" |
--
}
```
### Variable Types
1. Simple types: number, string, bool, null.
2. Complex types:
Collection types: list, map, set
Structural types: `object({<KEY> = <TYPE>, ...})`, `tuple([<TYPE>, ...])`
Order of Precedence:
defaults < env vars < terraform.tfvars file < terraform.tfvars.json file < .auto.tfvars < command line (-var & -var-file)
```
variable "<VAR NAME>" {
description = "<DESCRIPTION OF THE VAR>"
type = <VAR TYPE>
default = <DEFAULT VALUE>
}
# type string
variable "aws_region" {
description = "AWS Region"
type = string
default = "us-east-1"
}
# type list(string)
variable "azs" {
description = "AZs in the Region"
type = list(string)
default = [ "us-east-1a", "us-east-1b", "us-east-1c"]
}
# type map
variable "amis" {
type = map(string)
default = {
"eu-west-1" = "ami-0fdke15151513145",
"us-east-1" = "ami-0d17359173587519"
}
}
# type object
variable "egress_dsg" {
type = object({
from_port = number
to_port = number
protocol = string
cidr_blocks = list(string)
})
default = {
from_port = 0,
to_port = 65365,
protocol = "tcp",
cidr_blocks = ["100.0.0.0/16", "200.0.0.0/16", "0.0.0.0/0"]
}
}
```
## Meta-Arguments
### Loops
count, for_each, [for( o in var.list: o.id])
```
# creating multiple EC2 instances using count
resource "aws_instance" "server" {
ami = "ami-06ec8443c2a35b0ba"
instance_type = "t2.micro"
count = 3 # creating 3 resources
}
# declaring a variable
variable "users" {
type = list(string)
default = ["demo-user", "admin1", "john"]
}
# creating IAM users using for_each
resource "aws_iam_user" "test" {
for_each = toset(var.users) # converts a list to a set
name = each.key
}
# A for expression creates a complex type value by transforming another complex type value.
variable "names" {
type = list
default = ["som", "john", "mary"]
}
output "show_names" {
# similar to Python's list comprehension
value = [for n in var.names : upper(n)]
}
output "short_upper_names" {
# filter the resulting list by specifying a condition:
value = [for name in var.names : upper(name) if length(name) > 7]
}
```
### Splat
`Splat(var.list[*].id)`
```
# Launch an EC2 instance
resource "aws_instance" "server" {
ami = "ami-05cafdf7c9f772ad2"
instance_type = "t2.micro"
count = 3
}
output "private_addresses"{
value = aws_instance.server[*].private_ip # splat expression
}
```
### depends_on
if two resources depends on each other, depends_on specifies that dependency to enforce ordering
```
resource "aws_iam_role_policy" "example" {
name = "example"
role = "s3 access"
policy = jsonencode({
"Statement" = [{
"Action" = "s3:*",
"Effect" = "Allow",
}],
})
}
resource "aws_instance" "my_server" {
ami = "ami-a255235"
instance_type = "t2.micro"
iam_instance_profile = aws_iam_instance_profile.my_server
depends_on = [
aws_iam_role_policy.example,
]
```
### lifecycle
A set of meta arguments to control behavior specific resources
```
resources "aws_instance" "server" {
ami = "ami-a1b3414"
instance_type = "t2.micro"
lifecycle {
create_before_destroy = true
ignore_changes = [
# Some resources have metadata
# modified automatically outside of TF
tags
]
}
}
```
### Conditionals
`condition ? true_val : false_val`
### Built-In functions
| Function | Result |
| ------------------------------------------------|-------------------------|
| `max(5, 10, 9)` | 12 |
| `min(5, 10, 9)` | 5 |
| `format("There are %d servers", 4)` | There are 4 lights |
| `join("," ["foo", "bar", "baz"])` | foo,bar,baz |
| `split(",", "foo,bar,baz")` | `["foo", "bar", "baz"]` |
| `replace("hi world", "/w.*d/", "mom"` | hi mom |
| `substr("hello world", 1, 4)` | ello |
| `lookup({a="lol", b="sad"}, "a", "what?")` | lol |
| `lookup({a="lol", b="sad"}, "c", "what?")` | what? |
| `slice(["a", "b", "c", "d"], 1, 3)` | `["b", "c"]` |
| `timestamp()` | "2022-04-02T05:52:48Z" |
| `cidr("10.1.2.240/28", 1)` | 10.1.2.241 |
| `cidr("10.1.2.240/28", 14)` | 10.1.2.254 |
### Provider block
Details of the provider(s) being used. Includes information like access mechanisms, regional options, profile touse etc.
```
provider "aws" {
region = "us-east-1"
}
# Additional provider config reference as `aws.west`.
provider "aws" {
alias = "west"
region = "us-west-2"
}
```
### Requiring Providers
```
terraform {
# required_providers block specifies source and version
required_providers {
aws = {
source = "hashicorp/aws" # where to find the provider
version = "5.8.0" # which version of the provider is needed for this config
}
}
}
```
### Locals block
A local value assigns a name to an expression, so you can use the name multiple times within a module instead of repeating the expression
```
locals {
service_name = "forum"
owner = "Community Team"
}
# once local declared you can reference it
locals {
common_tags = {
Service = local.service_name
Owner = local.owner
```
### Output block
```
output "api_base_url" {
value = "https://${aws_instance.example.private_dns}:8433/"
# The EC2 instance must have an encrypted root volume.
precondition {
condition = data.aws_ebs_volume.example.encrypted
error_message = "The server's root volume is not encrypted."
}
# output can be marked as containing sensitive
sensitive = true # output can be marked as containing sensitive
}
```
### Data block
Data sources that can be queried (cloud provider, local list, etc.)
```
data "aws_ami" "example" {
most_recent = true
owners = ["self"]
tags = {
Name = "app-server"
Tested = "true"
}
}
```
### Modules
```
module "myec2" {
source = "../modules/ec2"
# module inputs
ami_id = var.ami_id
instance_type = var.instance_type
servers = var.servers
}
```
### Backends
A backend defines where Terraform stores its state data files.
Available backends: local(default), remote, azurerm, consul, cos, gcs, http, Kubernetes, oss, pg, s3
```
terraform {
backend "remote" {
organization = "example_corp"
workspaces {
name = "my-app-prod"
}
}
}
```
### Resource Addressing
| Example | Description |
| ------------------------------------------------- | ----------------------- |
| `[module path][resource info` | Resource path syntax |
| `module.<MODULE_PATH>[optional] module index` | Module path syntax |
| `resource_type.user_defined_name[optional index]` | Resource spec syntax |
| `<RESOURCE_TYPE>.<NAME>` | List all images |
| `var.<NAME>` | Input Variable |
| `local.<NAME>` | Locals |
| `module.<MODULE_NAME>` | Child module outputs |
| `data.<DATA TYPE>.<NAME>` | Data blocks |
| `path.module` | Location of expresssion |
| `path.root` | Root Module location |
| `terraform.workspace` | Current workspace |
---
## Terraform CLI
Create/Edit TF config file -> init -> plan -> validate -> apply -> destroy
### Initialization
```sh
terraform init [options]
-upgrade # Install latest module & provider versions
-reconfigure # reconfigure backend, ignoring any saved config
-backend=false # Disable backend & use previous Initialization
-migrate-state # reconfigure backend & attempt to migrate any existing state
```
### Planning
Generates & review an execution plan
```sh
terraform plan [options]
-var 'user=john' # set value for input vars in the root module of config
-var-file=filename # load var values from the given file
-input=true # ask for input for vars if not directly set
-out=path # write a plan file to given path. can be used as input for "apply"
-refresh-only # verifies remote object consistency without proposing actions to undo changes done outside TF
-destroy # create plan to destroy all objects currenly managed
-target=resource # target planning to given resouce & its dependencies only.
terraform plan -refresh-only # updates state to match changes made outside of TF. Good for drift detection
```
### Validation
```sh
terraform validate # Validates the config files for errors
```
### Apply
Executes changes to infra
```sh
terraform apply [options]
-auto-approve # skip interactive approval of plan before applying
-replace # force replacement of a particular resource instance
-var 'foo=bar' # set a value for input vars in the root module of config
-var-file=filename # load var values from the given file
-parallelism=n # limit the no of concurrent operations. Default=10
terraform apply -auto-approve var-file=web-dev.tfvars
terraform apply -replace="aws_instance.server"
terraform plan -refresh-only # Updates statefile to accept changes made manually.
```
### Destroy
Destroy (deletes) Terraform managed infra. Same as `terraform apply -destroy `
```sh
terraform destroy [options]
-auto-approve # skip interactive approval before destroying
-target # limits destroy to only given resource & its dependencies
terraform destroy -target aws_vpc.my_vpc -auto-approve
```
# Miscellaneous
```sh
terraform state show aws_instance.my_vm
terraform state pull > my_terraform.tfstate
terraform state mv aws_iam_role.my_ssm_role
terraform state list
terraform state rm aws_instance.my_server
terraform import aws_instance.new_server i-243abc
sudo apt install graphviz
terraform graph | dot -Tpng > graph.png
```
# Logging
log levels = TRACE > DEBUG > INFO > WARN > ERROR
```sh
export TF_LOG_CORE=TRACE # enable core logging
export TF_LOG_PROVIDER=TRACE # enable provider logging
export TF_LOG_PATH=logs.txt # to persist logs
```
# Also See
- [Docs](https://developer.hashicorp.com/terraform/language)
- [Good FCC Article](https://www.freecodecamp.org/news/terraform-certified-associate-003-study-notes/)
+4 -2
View File
@@ -1,2 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg fill="#000000" width="1rem" height="1rem" viewBox="0 0 24 24" role="img" xmlns="http://www.w3.org/2000/svg"><title>Nim icon</title><path d="M12.095 2.9s-.92.778-1.857 1.55c-.964-.032-2.856.199-3.88.598C5.412 4.408 4.582 3.7 4.582 3.7s-.709 1.305-1.154 2.07c-.662.377-1.325.8-1.917 1.36C.824 6.84.026 6.482 0 6.471c.911 1.966 1.524 3.935 3.19 5.119 2.654-4.483 14.983-4.07 17.691-.025 1.75-.977 2.43-3.078 3.119-5.018-.075.026-1.012.362-1.619.61-.363-.423-1.217-1.072-1.702-1.385a96.008 96.008 0 00-1.131-2.122s-.794.632-1.715 1.322c-1.243-.246-2.747-.544-4.012-.47A52.988 52.988 0 0112.095 2.9z M.942 10.65l2.189 5.671c3.801 5.366 13.508 5.739 17.74.104 1.001-2.415 2.352-5.808 2.352-5.808-1.086 1.721-2.852 2.909-3.94 3.549-.774.453-2.558.727-2.558.727l-4.684-2.597-4.71 2.545s-1.761-.303-2.558-.701c-1.608-.919-2.69-2.004-3.83-3.49z"/></svg>
<?xml version="1.0" encoding="utf-8"?>
<svg fill="currentColor" width="1em" height="1em" viewBox="0 0 24 24" role="img" xmlns="http://www.w3.org/2000/svg">
<path d="M12.095 2.9s-.92.778-1.857 1.55c-.964-.032-2.856.199-3.88.598C5.412 4.408 4.582 3.7 4.582 3.7s-.709 1.305-1.154 2.07c-.662.377-1.325.8-1.917 1.36C.824 6.84.026 6.482 0 6.471c.911 1.966 1.524 3.935 3.19 5.119 2.654-4.483 14.983-4.07 17.691-.025 1.75-.977 2.43-3.078 3.119-5.018-.075.026-1.012.362-1.619.61-.363-.423-1.217-1.072-1.702-1.385a96.008 96.008 0 00-1.131-2.122s-.794.632-1.715 1.322c-1.243-.246-2.747-.544-4.012-.47A52.988 52.988 0 0112.095 2.9z M.942 10.65l2.189 5.671c3.801 5.366 13.508 5.739 17.74.104 1.001-2.415 2.352-5.808 2.352-5.808-1.086 1.721-2.852 2.909-3.94 3.549-.774.453-2.558.727-2.558.727l-4.684-2.597-4.71 2.545s-1.761-.303-2.558-.701c-1.608-.919-2.69-2.004-3.83-3.49z"/>
</svg>

Before

Width:  |  Height:  |  Size: 968 B

After

Width:  |  Height:  |  Size: 878 B

+3
View File
@@ -0,0 +1,3 @@
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" fill="currentColor" height="1em" width="1em">
<path d="M26.875.109c4.043.703 5.193 3.464 5.104 6.36L32 6.426l-1.817 23.855-23.641 1.62c-1.963-.084-6.344-.261-6.541-6.38l2.193-4 3.76 8.781.672 1.561 3.739-12.192-.041.011.021-.043 12.339 3.944-1.86-7.245-1.317-5.199 11.755-.76-.817-.677-8.443-6.885 4.88-2.719zM0 25.453v.031-.036zM6.839 6.765c4.749-4.713 10.875-7.495 13.229-5.12 2.348 2.371-.141 8.141-4.896 12.844-4.751 4.713-10.803 7.647-13.151 5.276-2.355-2.364.057-8.287 4.817-13z"></path>
</svg>

After

Width:  |  Height:  |  Size: 562 B

+22
View File
@@ -28,6 +28,28 @@ html.scrollbar {
scroll-padding-top: 20px;
}
/***Scrollbars***/
:root.dark {
color-scheme: dark;
}
/* Restrict changes to mouse users */
@media (pointer: fine) {
::-webkit-scrollbar {
@apply bg-slate-200 w-2 h-2 rounded-lg
}
::-webkit-scrollbar-thumb {
@apply bg-slate-300 rounded-lg
}
:root.dark ::-webkit-scrollbar {
@apply bg-slate-700
}
:root.dark ::-webkit-scrollbar-thumb {
@apply bg-slate-500
}
}
.max-container {
max-width: 1320px;
@apply mx-auto p-3;