Skip to content

Commit

Permalink
Merge pull request Chalarangelo#1812 from 30-seconds/redate
Browse files Browse the repository at this point in the history
  • Loading branch information
Chalarangelo authored Jun 17, 2021
2 parents c1cea86 + 9fbb2d0 commit 38a4ede
Show file tree
Hide file tree
Showing 532 changed files with 1,065 additions and 92 deletions.
14 changes: 0 additions & 14 deletions .github/config.yml

This file was deleted.

35 changes: 0 additions & 35 deletions .github/lock.yml

This file was deleted.

18 changes: 0 additions & 18 deletions .github/stale.yml

This file was deleted.

27 changes: 8 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,35 @@

**30 seconds of code** is powered by the community, so feel free to contribute in any way you can to help us!

## Tools

Before you begin contributing, you should install the integration-tools globally on your machine:

```sh
npm install -g @30-seconds/integration-tools
```

This will allow you to use our customized tools for all of our content repositories.

## How you can help

- Submit pull requests with new snippets (see guidelines below) or snippet updates (tags, descriptions, explanations, typos, examples, code improvements).
- Open issues for things you want to see added, modified, discuss ideas or help out with existing issues.
- Open issues for things you want to see added, modified, discuss ideas or help out with existing issues.

## Ground rules

Breaking any of these rules will result in your pull request being closed. Please follow these guidelines above all else:

- **Always be polite and respectful to others** and try to follow the advice of the moderators/collaborators/owners.
- **Only modify snippet files**, never modify the generated files in the `snippet_data` directory.
- **Use the integration tools commands** to generate new snippets, ensuring they have the correct name and are in the correct location.
- **Use the snippet template** to create new snippets, ensure they have the correct name and are in the correct location.
- **Follow snippet format exactly**, otherwise your snippets will not be recognized correctly by the tools responsible for publishing them on the website. This includes such things as spacing and empty lines - if you accidentally make a mistake, consult the repository's [snippet template](snippet-template.md).
- **Snippets should solve real-world problems**, no matter how simple and should be abstract enough to be applied to different scenarios.

## Snippet creation

After installing the integration tools, you can run the following command:

```sh
create-new-snippet <my-snippet-name>
```
In order to create a new snippet, you should follow the steps below:

Replace `<my-snippet-name>` with the name of the snippet you are adding.
- Crate a copy of the [snippet template](snippet-template.md) in the `snippets` directory.
- Change the name of the newly created file to the name of your snippet.
- Edit the file, adding your snippet based on the guidelines.

## Snippet guidelines

- Snippets must have all their frontmatter sections (title, tags etc.) filled.
- Snippet titles must correspond to the filename and follow the language and repository's naming conventions.
- Snippet tags must be comma-separated, contain a primary tag as seen on the website as their first tag and an expertise tag (`beginner`, `intermediate` or `advanced`) as their last tag.
- Snippets must have their `firstSeen` dates formatted using [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601).
- Snippet descriptions must be short and to the point. Explain *what* the snippet does and detail *how* the snippet works and the language features used in it.
- Snippet code and examples must be enclosed in appropriate, language-tagged blocks as shown in the snippet template, be short and use modern techniques and features. Also make sure to test your code before submitting.
- If your snippet contains arguments with default parameters, explain what happens if they are omitted when calling the function and what the default case is. Specify default parameters for arguments only if necessary.
Expand All @@ -54,5 +43,5 @@ Replace `<my-snippet-name>` with the name of the snippet you are adding.
- Always use single quotes for string literals. Use template literals, instead, if necessary.
- Use strict equality checking (`===` and `!==` instead of `==` and `!=`).
- When describing snippets, refer to methods, using their full name. For example, use `Array.prototype.reduce()`, instead of `reduce()`.
- Use variables only when necessary. Prefer `const` when the values are not altered after assignment, otherwise, use `let`. Do not use `var`.
- Use variables only when necessary. Prefer `const` when the values are not altered after assignment, otherwise, use `let`. Do not use `var`.
- Never use `eval()`. Your snippet will be disqualified immediately.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* Visit [our website](https://30secondsofcode.org) to view our snippet collection.
* Use the [Search page](https://30secondsofcode.org/search) to find snippets that suit your needs. You can search by name, tag, language or using a snippet's description. Just start typing a term and see what comes up.
* Browse the [JavaScript Snippet List](https://30secondsofcode.org/js/p/1) to see all the snippets in this project or click individual tags at the top of the same page to narrow down your search to a specific tag.
* Browse the [JavaScript Snippet collection](https://30secondsofcode.org/js/p/1) to see all the snippets in this project or click individual tags at the top of the same page to narrow down your search to a specific tag.
* Click on each snippet card to view the whole snippet, including code, explanation and examples.
* You can use the button on the right side of a snippet card to copy the code to clipboard.
* You can use the button at the bottom of a snippet card to copy the code to clipboard.
* If you like the project, give it a star. It means a lot to the people maintaining it.

## Want to contribute?
Expand All @@ -18,9 +18,9 @@
* If you find a problem with a specific snippet, please [open an issue](https://github.com/30-seconds/30-seconds-of-code/issues/new).
* If you find a problem with the website, please [report it in the web repository](https://github.com/30-seconds/30-seconds-web/issues/new).

## Credits & Sponsors
## Credits

* This repository is maintained by the [30-seconds organization on GitHub](https://github.com/30-seconds).
* This repository is maintained by the [30 seconds of code organization on GitHub](https://github.com/30-seconds).
* All snippets are licensed under the CC0-1.0 License, unless explicitly stated otherwise.
* Logos, names and trademarks are not to be used without the explicit consent of the maintainers or owners of the 30 seconds GitHub organization.
* Our website is powered by [Netlify](https://www.netlify.com/), [Gatsby](https://www.gatsbyjs.org/), [Travis CI](https://travis-ci.com/) & [GitHub](https://github.com/).
* Logos, names and trademarks are not to be used without the explicit consent of the owners of the 30 seconds of code GitHub organization.
* Our website is powered by [Netlify](https://www.netlify.com/), [Next.js](https://nextjs.org/) & [GitHub](https://github.com/).
Binary file modified logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions snippet-template.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: functionName
tags: array,intermediate
firstSeen: 2021-06-13T05:00:00-04:00
---

Explain briefly what the snippet does.
Expand Down
2 changes: 2 additions & 0 deletions snippets/CSVToArray.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: CSVToArray
tags: string,array,intermediate
firstSeen: 2018-06-27T20:57:54+03:00
lastUpdated: 2020-11-03T21:46:13+02:00
---

Converts a comma-separated values (CSV) string to a 2D array.
Expand Down
2 changes: 2 additions & 0 deletions snippets/CSVToJSON.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: CSVToJSON
tags: string,object,advanced
firstSeen: 2018-06-27T21:14:24+03:00
lastUpdated: 2020-11-03T22:11:18+02:00
---

Converts a comma-separated values (CSV) string to a 2D array of objects.
Expand Down
2 changes: 2 additions & 0 deletions snippets/HSBToRGB.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: HSBToRGB
tags: math,intermediate
firstSeen: 2020-09-18T14:25:07+03:00
lastUpdated: 2020-09-18T14:25:07+03:00
---

Converts a HSB color tuple to RGB format.
Expand Down
2 changes: 2 additions & 0 deletions snippets/HSLToRGB.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: HSLToRGB
tags: math,intermediate
firstSeen: 2020-10-01T23:15:49+03:00
lastUpdated: 2020-10-04T11:24:27+03:00
---

Converts a HSL color tuple to RGB format.
Expand Down
2 changes: 2 additions & 0 deletions snippets/JSONToFile.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: JSONToFile
tags: node,intermediate
firstSeen: 2017-12-17T17:55:51+02:00
lastUpdated: 2020-10-20T23:02:01+03:00
---

Writes a JSON object to a file.
Expand Down
2 changes: 2 additions & 0 deletions snippets/JSONtoCSV.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: JSONtoCSV
tags: array,string,object,advanced
firstSeen: 2018-07-06T20:25:46+03:00
lastUpdated: 2020-10-22T20:23:47+03:00
---

Converts an array of objects to a comma-separated values (CSV) string that contains only the `columns` specified.
Expand Down
2 changes: 2 additions & 0 deletions snippets/RGBToHSB.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: RGBToHSB
tags: math,intermediate
firstSeen: 2020-09-18T14:25:07+03:00
lastUpdated: 2020-10-22T20:24:30+03:00
---

Converts a RGB color tuple to HSB format.
Expand Down
2 changes: 2 additions & 0 deletions snippets/RGBToHSL.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: RGBToHSL
tags: math,intermediate
firstSeen: 2020-10-01T23:16:30+03:00
lastUpdated: 2020-10-04T11:25:12+03:00
---

Converts a RGB color tuple to HSL format.
Expand Down
2 changes: 2 additions & 0 deletions snippets/RGBToHex.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: RGBToHex
tags: string,math,intermediate
firstSeen: 2017-12-17T17:55:51+02:00
lastUpdated: 2020-11-03T22:11:18+02:00
---

Converts the values of RGB components to a hexadecimal color code.
Expand Down
2 changes: 2 additions & 0 deletions snippets/URLJoin.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: URLJoin
tags: string,regexp,advanced
firstSeen: 2018-01-16T15:53:03+02:00
lastUpdated: 2020-10-22T20:24:44+03:00
---

Joins all given URL segments together, then normalizes the resulting URL.
Expand Down
2 changes: 2 additions & 0 deletions snippets/UUIDGeneratorBrowser.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: UUIDGeneratorBrowser
tags: browser,random,intermediate
firstSeen: 2017-12-29T09:47:10+02:00
lastUpdated: 2020-10-22T20:24:44+03:00
---

Generates a UUID in a browser.
Expand Down
2 changes: 2 additions & 0 deletions snippets/UUIDGeneratorNode.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: UUIDGeneratorNode
tags: node,random,intermediate
firstSeen: 2017-12-29T09:47:10+02:00
lastUpdated: 2020-10-22T20:24:44+03:00
---

Generates a UUID in Node.JS.
Expand Down
2 changes: 2 additions & 0 deletions snippets/accumulate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: accumulate
tags: math,array,intermediate
firstSeen: 2020-05-04T12:20:46+03:00
lastUpdated: 2020-11-03T21:46:13+02:00
---

Creates an array of partial sums.
Expand Down
2 changes: 2 additions & 0 deletions snippets/addClass.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: addClass
tags: browser,beginner
firstSeen: 2020-12-30T19:21:15+02:00
lastUpdated: 2020-12-30T19:21:15+02:00
---

Adds a class to an HTML element.
Expand Down
2 changes: 2 additions & 0 deletions snippets/addDaysToDate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: addDaysToDate
tags: date,intermediate
firstSeen: 2020-10-12T03:03:18+03:00
lastUpdated: 2020-11-28T19:18:29+02:00
---

Calculates the date of `n` days from the given date, returning its string representation.
Expand Down
2 changes: 2 additions & 0 deletions snippets/addEventListenerAll.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: addEventListenerAll
tags: browser,event,intermediate
firstSeen: 2021-04-22T08:53:29+03:00
lastUpdated: 2021-04-22T08:53:29+03:00
---

Attaches an event listener to all the provided targets.
Expand Down
2 changes: 2 additions & 0 deletions snippets/addMinutesToDate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: addMinutesToDate
tags: date,intermediate
firstSeen: 2020-11-28T19:27:46+02:00
lastUpdated: 2020-11-28T19:27:46+02:00
---

Calculates the date of `n` minutes from the given date, returning its string representation.
Expand Down
2 changes: 2 additions & 0 deletions snippets/addMultipleEvents.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: addMultipleListeners
tags: browser,event,intermediate
firstSeen: 2020-10-08T00:40:30+03:00
lastUpdated: 2020-10-22T20:23:47+03:00
---

Adds multiple event listeners with the same handler to an element.
Expand Down
2 changes: 2 additions & 0 deletions snippets/addStyles.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: addStyles
tags: browser,beginner
firstSeen: 2021-01-07T00:37:43+02:00
lastUpdated: 2021-01-07T00:37:43+02:00
---

Adds the provided styles to the given element.
Expand Down
2 changes: 2 additions & 0 deletions snippets/addWeekDays.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: addWeekDays
tags: date,intermediate
firstSeen: 2020-10-11T16:51:39+03:00
lastUpdated: 2021-01-08T00:23:44+02:00
---

Calculates the date after adding the given number of business days.
Expand Down
2 changes: 2 additions & 0 deletions snippets/all.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: all
tags: array,beginner
firstSeen: 2018-02-14T11:46:15+02:00
lastUpdated: 2020-10-18T20:24:28+03:00
---

Checks if the provided predicate function returns `true` for all elements in a collection.
Expand Down
2 changes: 2 additions & 0 deletions snippets/allEqual.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: allEqual
tags: array,beginner
firstSeen: 2018-08-03T00:03:08+03:00
lastUpdated: 2020-10-18T20:24:28+03:00
---

Checks if all elements in an array are equal.
Expand Down
2 changes: 2 additions & 0 deletions snippets/allEqualBy.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: allEqualBy
tags: array,intermediate
firstSeen: 2020-10-19T22:14:49+03:00
lastUpdated: 2020-10-19T22:14:49+03:00
---

Checks if all elements in an array are equal, based on the provided mapping function.
Expand Down
2 changes: 2 additions & 0 deletions snippets/allUnique.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: allUnique
tags: array,beginner
firstSeen: 2020-10-19T19:47:26+03:00
lastUpdated: 2021-01-08T00:23:44+02:00
---

Checks if all elements in an array are unique.
Expand Down
2 changes: 2 additions & 0 deletions snippets/allUniqueBy.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: allUniqueBy
tags: array,intermediate
firstSeen: 2020-10-19T22:15:05+03:00
lastUpdated: 2021-01-08T00:23:44+02:00
---

Checks if all elements in an array are unique, based on the provided mapping function.
Expand Down
2 changes: 2 additions & 0 deletions snippets/and.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
title: and
tags: math,logic,beginner
unlisted: true
firstSeen: 2020-05-13T11:35:31+03:00
lastUpdated: 2021-01-04T13:04:15+02:00
---

Checks if both arguments are `true`.
Expand Down
Loading

0 comments on commit 38a4ede

Please sign in to comment.