https://github.com/yamadapc/rl
Rate-limit output from an UNIX pipe
https://github.com/yamadapc/rl
Last synced: 8 months ago
JSON representation
Rate-limit output from an UNIX pipe
- Host: GitHub
- URL: https://github.com/yamadapc/rl
- Owner: yamadapc
- License: mit
- Created: 2015-10-25T16:44:15.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-10-25T16:50:19.000Z (about 10 years ago)
- Last Synced: 2025-03-30T16:45:01.997Z (9 months ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rl
Rate-limit output from an UNIX pipe. This is useful if you're writting scripts
to query an API for example which has a rate limit.
So let's say I want to run something against the GitHub API, but I only want to
do one request every second. I can do it with:
```bash
cat list-of-inputs |
rl "1/1s" |
xargs -I % -L 1 -P32 curl -X GET -v https://api.github.com/some-github-url/% -u token:$GITHUB_API_TOKEN
```
## Installation
```bash
git clone git@github.com:yamadapc/rl
npm i -g rl
rm -rf rl
```
## Usage
To output a random number very 1 second:
```bash
for i in {1..5}; do echo $RANDOM; done | rl "1/1s"
```
To output a random number very 1 minute:
```bash
for i in {1..5}; do echo $RANDOM; done | rl "1/1minute"
```
To output 20 random numbers every hour:
```bash
for i in {1..5}; do echo $RANDOM; done | rl "20/hour"
```
## License
This code is licensed under the MIT license. For more information please refer
to the [LICENSE](/LICENSE) file.