Skip to content

Instantly share code, notes, and snippets.

// Module imports
import 'dotenv/config'
import {
Client,
Intents,
} from 'discord.js'
@trezy
trezy / generateGalaxy.js
Created January 19, 2022 19:27
Pseudo code for generating a galaxy based on available mass determined by seed-based Perlin noise
// Local imports
import { STELLAR_CLASSES } from 'helpers/stellarClasses.js'
// The density at a point must be greater than this value for a star to be
// formed.
const DENSITY_THRESHHOLD_FOR_NEW_STAR = 0.2
@trezy
trezy / log.js
Last active December 21, 2021 05:00
let hasShownLoggingDisabledNotification = true
let logging = true
// export functions: a-z
export function getLogging() {
return logging
}
export function log(message, channel, user) {
const logConfig = {
@trezy
trezy / generateHSLCustomProperties.scss
Last active October 18, 2021 15:37
SCSS mixins for generating a set of CSS Custom Properties to use for HSL color calculations.
// Generates a set of flexible CSS Custom Properties
@mixin generateHSLCustomProperties($propertyName, $hue, $saturation, $lightness) {
// $safeName is necessary because $name can be a color literal (like 'red').
// Sass doesn't like that, so we convert it to a string.
$safeName: '' + $propertyName;
--#{$safeName}-hue: calc(#{$hue} + var(--hue-shift));
--#{$safeName}-saturation: #{$saturation};
--#{$safeName}-lightness: #{$lightness};
@trezy
trezy / examples.js
Last active October 13, 2021 21:10
Uses the first character of a string to choose a color within a range. Can take a color pair, otherwise defaults to to full color spectrum.
const strings = [
'Fruit', // #0002ee
'Blorp', // #0000a2
'Fig', // #0002ee
'Bridge', // #0000a2
'Macintosh', // #0006f3
'Apple', // #00000f
'Speakers', // #000a65
'Stream', // #000a65
]
import {
cloneElement,
useCallback,
} from 'react'
function RadioGroup(props) {
const {
children,
onChange,
} = props
// Module imports
import React from 'react'
// Local imports
import ExternalLink from 'components/ExternalLink'
// pages/newsletter.js
function NewsletterPage() {
const [email, setEmail] = useState('')
const [error, setError] = useState(false)
const [isSubmitted, setIsSubmitted] = useState(false)
const [isSubmitting, setIsSubmitting] = useState(false)
const [name, setName] = useState('')
const handleEmailChange = useCallback(({ target }) => {
// Module imports
import {
createContext,
useCallback,
useContext,
useEffect,
useState,
} from 'react'
import PropTypes from 'prop-types'
JavaScript β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘ Pretty Good
HTML β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ Totally Solid
CSS β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ πŸ’―
React.js β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘ Good
Muscle β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘ Meh
Drums β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘ Strong (probs rusty, tho)