Skip to content

Instantly share code, notes, and snippets.

@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
]
@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 / 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 / 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
// Module imports
import 'dotenv/config'
import {
Client,
Intents,
} from 'discord.js'
// Module imports
import { SlashCommandBuilder } from '@discordjs/builders'
export class Command {
/****************************************************************************\
* Instance properties
// Local imports
import { Command } from '../structures/Command.js'
export default new Command({
// Meta
name: 'ping',
// Local imports
import { capitalise } from '../helpers/capitalise.js'
export class Command {
/****************************************************************************\
* Public methods
// Local imports
import { Command } from '../structures/Command.js'
export default new Command({
// Meta
name: '8ball',
// Module imports
import { MessageEmbed } from 'discord.js'
// Local imports
import { Command } from '../structures/Command.js'