Skip to content

Commit

Permalink
feature | Don't @ me, bruh
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardofabila authored and ricardoBISHOP committed Sep 15, 2022
0 parents commit e4ce44f
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# IntelliJ
.idea/

## mac OS finder garbage
.DS_Store

# VSCode stuff
.vscode/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Ricardo Fabila

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:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

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.
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<h1 align="center">
🎲
<br/>
rand-stand
</h1>

<h4 align="center">
<a href="https://www.youtube.com/watch?v=pjvQFtlNQ-M" target="_blank">
Randomize the order of your team members for your stand ups
</a>
</h4>

<p align="center">
<a href="#about">About</a> •
<a href="#installation">Installation</a> •
<a href="#configuration">Configuration</a> •
<a href="#dependencies">Dependencies</a>
</p>

<p align="center">
<a href="https://github.com/ricardofabila/rand-stand/releases" target="_blank">
<img src="https://img.shields.io/badge/Version-1.0.0-blue" alt="Version 1.0.0">
</a>
<a href="https://www.youtube.com/watch?v=z8RkR4rd7dM" target="_blank">
<img src="https://img.shields.io/badge/Fucks%20given-0-967259" alt="Version 1.0.0">
</a>
</p>

---

# About

### Are your stand ups run 5 minutes longer than they should?

The following is a silly script I wrote in less than 5 minutes to use as an example of how to add a script package to [`🦊 fox`](https://github.com/ricardofabila/fox). But it can actually be useful, as I have been using it for about a year when running stand-ups.

## Installation

Get this script with [`🦊 fox`](https://github.com/ricardofabila/fox)

```shell
fox install rand-stand
```

## Does any of the following applies to you:

- Is there a long akward silence betweeen each member of your team because no one has the currage to go next?
- Are you playing the "the person in turn decides who to go next" game? (Why do people do this? It's beyond stupid 🤦)
- Are you reading this with a commercial voice?

There is a better way! Just install `rand-stand` and get a random list based on your team members. Post it on slack (or whatever you use) before every stand-up. And voila! No more awkward silences. No more unnecessary friction.

## Configuration

Just add your team members to the list in `~/.config/rand-stand/items.json` like so:

```json
{
"first": ["⚡ Zeus"],
"random": [
"🎸 Jimi Hendrix",
"👾 Ricardo",
"🧼 Tyler Durden",
"🦇 Ozzy Osbourne",
"🐢 Mitch McConnell",
"👨‍🍳 Gordon Ramsay"
],
"last": ["🛹 Tony Hawk"]
}
```

This is quite self explanatory, but if you must...

The items in the `first` section are hardcoded to go first (duh!), `random` go at random, and `last` go (you guessed it) at last.

And just run `rand-stand` to get the randomized list output to you terminal.

## Dependencies

This script is written with in JavaScript but uses the `bun` runtime. You can get it at: https://bun.sh
49 changes: 49 additions & 0 deletions rand-stand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bun

import fs from "fs";
import path from "path";

function getUserHome() {
// Return the value using process.env
return process.env[process.platform == "win32" ? "USERPROFILE" : "HOME"];
}

const userHomeDir = getUserHome();

fs.mkdirSync(path.join(userHomeDir, ".config", "rand-stand"), {recursive: true});
const checksumPath = path.join(userHomeDir, ".config", "rand-stand", "check-sum.txt");
const itemsPath = path.join(userHomeDir, ".config", "rand-stand", "items.json");

if (!fs.existsSync(checksumPath)) {
fs.writeFileSync(checksumPath, "", { flag: "w+" });
}

if (!fs.existsSync(itemsPath)) {
fs.writeFileSync(itemsPath, `{"first": [], "random": [], "last": []}`, { flag: "w+" });
}

const checksum = path.resolve(checksumPath);
const itemsFullPath = path.resolve(itemsPath);
const items = JSON.parse(fs.readFileSync(itemsFullPath, "utf8"));

if (Object.values(items).reduce((p, c) => p + c.length, 0) == 0){
console.log("Looks like your `~/.config/rand-stand/items.json` is empty.");
console.log("Go add some members first!");
process.exit(1);
};

function mix({ first = [], random = [], last = [] }) {
return first
.concat(random.sort(() => (Math.random() > 0.5 ? 1 : -1)))
.concat(last);
}

let folks = mix(items);
while (fs.readFileSync(checksum, { flag: "a+" }).toString() == folks.join("")) {
folks = mix(items);
}

console.log(""); // some padding
folks.forEach((dude) => console.log(" ", dude));
console.log("");
fs.writeFileSync(checksum, folks.join(""), { flag: "w+" });

0 comments on commit e4ce44f

Please sign in to comment.