Skip to content

Commit

Permalink
Merge pull request Chalarangelo#447 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 4c07c3c + da95c27 commit 0fc0017
Show file tree
Hide file tree
Showing 166 changed files with 1,039 additions and 798 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.

25 changes: 7 additions & 18 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 Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[![Logo](/logo.png)](https://30secondsofcode.org/python/p/1)

## 30 seconds of Python
# 30 seconds of code

> Short Python code snippets for all your development needs
* 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 [Python Snippet List](https://30secondsofcode.org/python/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 [Python Snippet collection](https://30secondsofcode.org/python/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-python/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: function_name
tags: utility,intermediate
firstSeen: 2021-06-13T05:00:00-04:00
---

Explain briefly what the snippet does.
Expand Down
2 changes: 2 additions & 0 deletions snippets/add_days.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: add_days
tags: date,intermediate
firstSeen: 2020-10-28T16:19:04+02:00
lastUpdated: 2020-10-28T16:19:04+02:00
---

Calculates the date of `n` days from the given date.
Expand Down
2 changes: 2 additions & 0 deletions snippets/all_equal.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: all_equal
tags: list,beginner
firstSeen: 2019-08-20T11:39:18+03:00
lastUpdated: 2020-10-11T13:40:42+03:00
---

Checks if all elements in a list are equal.
Expand Down
2 changes: 2 additions & 0 deletions snippets/all_unique.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: all_unique
tags: list,beginner
firstSeen: 2018-04-01T11:03:09+03:00
lastUpdated: 2021-01-07T23:30:28+02:00
---

Checks if all the values in a list are unique.
Expand Down
2 changes: 2 additions & 0 deletions snippets/arithmetic_progression.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: arithmetic_progression
tags: math,beginner
firstSeen: 2020-07-28T13:57:33+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Generates a list of numbers in the arithmetic progression starting with the given positive integer and up to the specified limit.
Expand Down
2 changes: 2 additions & 0 deletions snippets/average.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: average
tags: math,list,beginner
firstSeen: 2018-01-27T07:16:41+02:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Calculates the average of two or more numbers.
Expand Down
2 changes: 2 additions & 0 deletions snippets/average_by.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: average_by
tags: math,list,intermediate
firstSeen: 2019-08-20T11:55:10+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Calculates the average of a list, after mapping each element to a value using the provided function.
Expand Down
2 changes: 2 additions & 0 deletions snippets/bifurcate.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: bifurcate
tags: list,intermediate
firstSeen: 2019-08-20T12:37:06+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Splits values into two groups, based on the result of the given `filter` list.
Expand Down
2 changes: 2 additions & 0 deletions snippets/bifurcate_by.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: bifurcate_by
tags: list,intermediate
firstSeen: 2019-08-20T12:41:21+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Splits values into two groups, based on the result of the given filtering function.
Expand Down
2 changes: 2 additions & 0 deletions snippets/binomial_coefficient.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: binomial_coefficient
tags: math,beginner
firstSeen: 2020-10-04T11:56:31+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Calculates the number of ways to choose `k` items from `n` items without repetition and without order.
Expand Down
2 changes: 2 additions & 0 deletions snippets/byte_size.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: byte_size
tags: string,beginner
firstSeen: 2018-02-01T10:19:59+02:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Returns the length of a string in bytes.
Expand Down
2 changes: 2 additions & 0 deletions snippets/camel.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: camel
tags: string,regexp,intermediate
firstSeen: 2019-08-21T08:59:54+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Converts a string to camelcase.
Expand Down
2 changes: 2 additions & 0 deletions snippets/capitalize.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: capitalize
tags: string,intermediate
firstSeen: 2018-02-01T10:19:59+02:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Capitalizes the first letter of a string.
Expand Down
2 changes: 2 additions & 0 deletions snippets/capitalize_every_word.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: capitalize_every_word
tags: string,beginner
firstSeen: 2018-02-01T10:19:59+02:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Capitalizes the first letter of every word in a string.
Expand Down
2 changes: 2 additions & 0 deletions snippets/cast_list.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: cast_list
tags: list,intermediate
firstSeen: 2019-08-20T12:47:43+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Casts the provided value as a list if it's not one.
Expand Down
38 changes: 20 additions & 18 deletions snippets/celsius_to_fahrenheit.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
---
title: celsius_to_fahrenheit
tags: math,beginner
unlisted: true
---

Converts Celsius to Fahrenheit.

- Follow the conversion formula `F = 1.8 * C + 32`.

```py
def celsius_to_fahrenheit(degrees):
return ((degrees * 1.8) + 32)
```

```py
celsius_to_fahrenheit(180) # 356.0
```
---
title: celsius_to_fahrenheit
tags: math,beginner
unlisted: true
firstSeen: 2020-04-05T12:29:03+03:00
lastUpdated: 2021-01-04T12:47:04+02:00
---

Converts Celsius to Fahrenheit.

- Follow the conversion formula `F = 1.8 * C + 32`.

```py
def celsius_to_fahrenheit(degrees):
return ((degrees * 1.8) + 32)
```

```py
celsius_to_fahrenheit(180) # 356.0
```
40 changes: 21 additions & 19 deletions snippets/check_prop.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
---
title: check_prop
tags: function,intermediate
---

Creates a function that will invoke a predicate function for the specified property on a given object.

- Return a `lambda` function that takes an object and applies the predicate function, `fn` to the specified property.

```py
def check_prop(fn, prop):
return lambda obj: fn(obj[prop])
```

```py
check_age = check_prop(lambda x: x >= 18, 'age')
user = {'name': 'Mark', 'age': 18}
check_age(user) # True
```
---
title: check_prop
tags: function,intermediate
firstSeen: 2020-01-02T16:49:25+02:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Creates a function that will invoke a predicate function for the specified property on a given object.

- Return a `lambda` function that takes an object and applies the predicate function, `fn` to the specified property.

```py
def check_prop(fn, prop):
return lambda obj: fn(obj[prop])
```

```py
check_age = check_prop(lambda x: x >= 18, 'age')
user = {'name': 'Mark', 'age': 18}
check_age(user) # True
```
2 changes: 2 additions & 0 deletions snippets/chunk.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: chunk
tags: list,intermediate
firstSeen: 2018-01-09T06:39:42+02:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Chunks a list into smaller lists of a specified size.
Expand Down
2 changes: 2 additions & 0 deletions snippets/chunk_into_n.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: chunk_into_n
tags: list,intermediate
firstSeen: 2020-10-12T22:11:30+03:00
lastUpdated: 2020-10-23T05:35:06+03:00
---

Chunks a list into `n` smaller lists.
Expand Down
2 changes: 2 additions & 0 deletions snippets/clamp_number.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
title: clamp_number
tags: math,beginner
firstSeen: 2019-08-20T12:50:38+03:00
lastUpdated: 2020-11-02T19:27:07+02:00
---

Clamps `num` within the inclusive range specified by the boundary values.
Expand Down
Loading

0 comments on commit 0fc0017

Please sign in to comment.