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 / man-pages-pages.csv
Created May 7, 2023 21:59
Man pages sorted by number of pages when converted to PDF (Taken from Arch packages)
We can't make this file beautiful and searchable because it's too large.
Number of pages in manual,Package name,Man page name (and section)
5967,salt,salt.7
751,rclone,rclone.1
684,perl-image-exiftool,Image::ExifTool::TagNames.3pm
645,ffmpeg,ffmpeg-all.1
551,python-pylint,pylint.1
525,ffmpeg,ffprobe-all.1
521,ffmpeg,ffplay-all.1
395,arm-none-eabi-gcc,arm-none-eabi-gcc.1
395,arm-none-eabi-gcc,arm-none-eabi-g++.1