Skip to content

Instantly share code, notes, and snippets.

@sebastiancarlos
sebastiancarlos / kanyeBleach.js
Last active August 1, 2021 17:28
Kanye and the ontology of bleached T-shirts. A JavaScript implementation.
// Let's start by defining the ontology of our universe.
const BLEACH_TRANSFERENCE_RATIO = 0.5
class TShirt {
constructor() {
// By default, a T-shirt is clean.
this.stains = []
}
import { useEffect, useRef } from "react";
// Render an SVG Circle Progress set to the provided progress percentage.
export const CircleProgress = ({ progress = 0 }) => {
const pieElement = useRef(null);
// Update SVG every time the progress prop changes.
useEffect(() => {
pieElement.current.style.setProperty("--progress", progress);
}, [progress]);
:root {
--PI: 3.14159265358979;
}
.pie {
--progress: 0;
--radius: 25;
--circumference: calc(2 * var(--radius) * var(--PI));
fill: transparent;
stroke: #ced4da;
import { useControls, button } from "leva";
import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import "./styles.css";
import { CircleProgress } from "./CircleProgress";
import { useEffect } from "react";
export default function App() {
const [{ readTime, progress }, set] = useControls(() => ({
readTime: { value: 10 * 1000, label: "Read Time (ms)" }, // Default to 10 seconds
@sebastiancarlos
sebastiancarlos / TechStackGenerator.js
Created October 3, 2021 19:52
Tech Stack Generator
import "./styles.css";
import { useState } from "react";
import Link from "@mui/material/Link";
import { Input } from "./Input";
import { InteractiveStackName } from "./InteractiveStackName";
import { Description } from "./Description";
import {
getRandomStackName,
sanitizeInputValue,
isStackNameValid,
@sebastiancarlos
sebastiancarlos / supermarket.js
Created December 2, 2021 15:07
Interface to buy food from the supermarket.
// interface for food
interface Food {
name: string;
calories: number;
}
// interface for refrigerator
interface Refrigerator {
food: Food[];
addFood(food: Food): void;
@sebastiancarlos
sebastiancarlos / gammaScript.js
Last active February 1, 2022 19:51
GammaScript
export default function (babel) {
return {
visitor: {
BooleanLiteral(path) {
// this code prevents stack overflow
// TODO: fix before IPO
if (path.parent.type === "ArrayExpression") {
return;
}
@sebastiancarlos
sebastiancarlos / popular-npm-create-packages-2022-08.csv
Last active August 26, 2022 17:14
CSV of npm packages using the "create-" naming convention, and number of weekly downloads. Sorted by most downloads. Limited to packages with more than 150 weekly downloads.
@sebastiancarlos
sebastiancarlos / manimal.sh
Created April 12, 2023 13:57
Manimal - The Minimal POSIX-Compliant Man Pager
#!/usr/bin/env bash
# Manimal - The Minimal POSIX-Compliant Man Pager
# Manimal usage
manimal_usage() {
echo "Usage: manimal [-k] name"
echo
echo "Options:"
echo " -k Search for name in the utilities summary database"
@sebastiancarlos
sebastiancarlos / manpdf.sh
Last active April 15, 2023 13:38
manpdf - Turn your man pages into PDF - No one man should have all that power™️ 🔥💪🍆👀
#!/usr/bin/env bash
# Created by argbash-init v2.10.0
# ARG_OPTIONAL_SINGLE([output],[o],[The output file])
# ARG_OPTIONAL_BOOLEAN([open-pdf],[],[Open the PDF file after creating it],[on])
# ARG_POSITIONAL_SINGLE([name-or-file])
# ARG_POSITIONAL_SINGLE([section],[],[""])
# ARG_DEFAULTS_POS([])
# ARG_HELP([<Open a man page as a PDF file>])
# ARG_VERSION([echo $(basename $0) 420.69])